Mastering Your Shopify Cart Drawer: Freezing Backgrounds and Adding Overlays for Enhanced UX
Hey everyone! As a Shopify migration expert and someone who spends a lot of time digging through community discussions, I often see recurring questions that, once solved, can make a huge difference in your store's user experience. Today, I want to talk about a common cart drawer quirk, especially for those of you using the Horizon theme, and how a couple of community members brilliantly tackled it.
The Cart Drawer Conundrum: What's the Problem?
Recently, a store owner named saintmessi posted in the Shopify community about an issue with their cart drawer on the Horizon 4.2.0 theme. When customers clicked to open the cart, the page behind it remained fully scrollable, and there was no dimmed background overlay. This meant shoppers could still interact with the main store page while the cart was open, which isn't ideal for a focused checkout process.
Here's how saintmessi described it:
When I click on the cart, the left side of the page is still scrollable, and the background doesn’t freeze. There is also no background overlay, and the scrollbar on the left side is still movable.
I’m using Horizon theme 4.2.0
This is a fantastic example of a seemingly small UI/UX detail that can significantly impact a customer's journey. A cart drawer that doesn't properly isolate itself from the main content can distract users, making them less likely to complete their purchase. It breaks the expected behavior of a modal or drawer, where the background typically dims and becomes unscrollable, directing full attention to the cart.
Understanding the Horizon Theme's Default Behavior
Before diving into the fixes, it's important to understand why this happens. As jowel-66, another helpful community member, pointed out, this behavior isn't a bug but rather how the Horizon 4.2.0 theme is designed to work on desktop:
- Desktop (990px wide or more): The cart opens as a side panel, pushing the page over instead of covering it. There's no dark overlay, and the page remains scrollable, allowing shoppers to continue browsing. The drawer also stays open if they navigate to another page.
- Mobile/Tablet (under 990px): The same drawer opens as an overlay, with a dimmed background and the page behind it locked.
This design choice aims to offer a different experience on larger screens, but for many merchants, the consistent, focused overlay experience across all devices is preferred. Fortunately, the Shopify community provided two excellent solutions to achieve this.
Solution 1: Adding a Dimmed Overlay with Custom CSS (Quick Fix)
Ploqo offered a straightforward CSS solution that adds the missing dark overlay, enhancing the visual separation of the cart drawer. This method is quick and effective if your primary goal is just the dimmed background.
Steps to Implement the Custom CSS Overlay:
- Go to your Shopify Admin, navigate to Online Store.
- Click Edit theme on your current theme (Horizon).
- On the left sidebar, click the Theme settings icon.
- Scroll down and click Custom CSS.
- Paste the following code into the box:
.theme-drawer__dialog::backdrop { background: rgb(0 0 0 / 0.5); }
- Click Save.
Note: For a lighter overlay, simply change 0.5 to 0.3 (or any value between 0 and 1). This solution primarily adds the visual dimming but might not fully freeze the background scrolling, depending on your theme's specific JavaScript implementation. It's a great initial step for visual improvement.
Solution 2: Full Cart Drawer Behavior Change with Code Edits (Comprehensive Fix)
For a complete solution that mimics the mobile experience on desktop—meaning a dimmed background, a frozen page, and the cart closing when clicking outside or pressing Esc—jowel-66 provided a more in-depth code modification. This involves adjusting the theme's JavaScript and Liquid files.
Important Precaution: Always Duplicate Your Theme!
Before making any code edits, it is absolutely crucial to create a backup of your theme. This ensures you can easily revert to a working version if anything goes wrong.
- Go to Online Store. Next to your Horizon theme, click the 3-dot menu and select Duplicate.
- On the theme you want to change (the duplicated one, or your live theme if you're confident), click the 3-dot menu > Edit code.
- Open
assets/theme-drawer.js. Near the top (around line 7), find:
and change it to:const MODAL_BREAKPOINT = 990;
const MODAL_BREAKPOINT = 99999; - Open
snippets/theme-drawer.liquidand search for(min-width: 990px). It typically appears twice (around lines 33 and 86). Change both instances to(min-width: 99999px). - Save both files, then hard-refresh your store to see the changes.
Optional: Darkening the Built-in Overlay
After these code edits, the cart will open with a dimmed background. If you find the default dimming too light (around 15% opacity), you can make it darker:
- Go to Theme settings > Custom CSS.
- Add the following code:
#cart-drawer .theme-drawer__dialog::backdrop {
background: rgb(0 0 0 / 0.4);
}
Considerations for Code Edits:
- If you use Shopify’s chat drawer, it shares the same drawer code, so it will also open as an overlay with the new behavior.
- Theme updates often overwrite code edits, meaning you may need to reapply these changes after updating your Horizon theme.
Why This Matters for Your E-commerce Store
Optimizing your cart drawer's behavior is more than just a visual tweak; it's a critical component of your store's user experience (UX) and conversion funnel. A well-designed cart drawer:
- Reduces Distraction: A dimmed, frozen background keeps the customer's focus squarely on their cart contents and the next steps towards checkout.
- Enhances Professionalism: Consistent and predictable UI behavior across devices builds trust and makes your store feel more polished.
- Improves Conversion Rates: By minimizing friction and guiding users efficiently, you increase the likelihood of them completing their purchase.
Whether you're just starting your journey with Shopify or looking to refine your existing setup, paying attention to these small details can yield significant returns. As migration experts at Shopping Cart Mover, we understand that every element of your store contributes to its overall success. Ensuring a seamless and intuitive shopping experience, from product browsing to checkout, is paramount.
Don't let minor UI quirks deter your customers. With these simple adjustments, you can ensure your Shopify store offers a top-notch experience that encourages conversions and keeps shoppers coming back. Happy selling!