Demystifying the Double Box: Fixing Unwanted Focus Outlines in Shopify's Baseline Theme Cart Drawer

Hey store owners! Ever open your cart drawer on your Shopify store, especially if you're rocking the Baseline theme, and notice a strange, persistent "double box" outline around buttons, even though you haven't touched your keyboard? It's a surprisingly common head-scratcher, and it recently sparked a lively discussion in the Shopify community that I want to dive into.

The Mystery of the Rogue Focus Box

Our community member, @fifth, brought this exact issue to the forefront. They were seeing a persistent double outline box in their Baseline theme's cart drawer. Initially, it was around the 'X' button to close the drawer. After trying an AI-suggested code fix, it just moved to the 'Continue Shopping' button. What's more, this wasn't happening because they were tabbing through elements with the keyboard; it just appeared automatically when the drawer opened.

Here's a look at what @fifth shared:

It turned out this issue was primarily happening in Safari and, crucially, @fifth even confirmed it happens on the Baseline theme's demo store. This is a big clue, suggesting it might be a theme-specific quirk or a browser rendering difference rather than something broken in their specific store setup.

Accessibility vs. Annoyance: The Community Weighs In

This kind of problem always brings up a critical discussion point: accessibility. That outline box is there for a good reason – it helps users who navigate with a keyboard (or other assistive technologies) know which element they're currently focused on.

One community member, @Maximus3, was quick to point out that this is an accessibility feature and strongly advised against removing it with CSS code. Their concern is valid: blindly removing focus outlines can severely hinder navigation for some users.

However, the key here is that @fifth wasn't *keyboard tabbing* into the element; it was appearing automatically. This suggests the outline was being triggered inappropriately, making it more of a visual bug than a helpful accessibility indicator in this specific context.

The ':focus-visible' Trick to the Rescue (Carefully!)

Several helpful members offered solutions that aim to address the visual annoyance without completely sacrificing accessibility. The modern CSS pseudo-class :focus-visible is a game-changer here. It allows browsers to apply focus styles only when the user is navigating via keyboard, not when they simply click an element (which often triggers the :focus state unnecessarily).

@tim_1 was the first to suggest this approach, providing a general CSS snippet:

:focus:not(:focus-visible) {
    outline: none !important;
}

This code tells the browser: "If an element has focus, but it's *not* due to keyboard navigation (i.e., :focus-visible is false), then remove its outline." It's a clever way to keep the outline for keyboard users while hiding it for mouse clicks.

@ShopIntegrations then chimed in with a more targeted solution specifically for the cart drawer, which is fantastic because it limits the scope of the change:

.cart-drawer button:focus-visible, 
.cart-drawer a:focus-visible {
outline: none !important;
box-shadow: none !important;
}

This snippet targets buttons and links specifically within the .cart-drawer and removes their outline and box-shadow *only when they are focus-visible*. Wait, did I say :focus-visible? Yes! The idea here is that if the browser *is* showing the focus-visible outline automatically and incorrectly, this code attempts to override it. However, it's worth noting @ShopIntegrations also cautioned that removing focus outlines completely can "ding your accessibility score a bit." This is a crucial point to remember.

How to Tackle the Double Box in Your Baseline Theme

Given the community insights, here's my advice on how to approach this, balancing aesthetics and accessibility:

Step 1: Contact Theme Developers (First and Best Option)

Since @fifth confirmed this happens on the Baseline theme's demo store, the absolute best first step is to reach out to the theme developers. This isn't just a random bug in your store; it's likely a theme-level issue, possibly a default styling conflict or an oversight in how the theme handles focus states in Safari. They are in the best position to provide an official, robust fix that won't compromise accessibility.

Step 2: Implement a Targeted CSS Fix (Use with Caution)

If reaching out to the developers isn't yielding a quick solution, or if you prefer a DIY approach, you can try one of the CSS solutions. Remember the accessibility warnings!

Instructions for Adding Custom CSS:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find your Baseline theme, click Actions > Edit code.
  3. In the left sidebar, look for a file like theme.css, base.css, or custom.css under the 'Assets' folder. If you can't find a specific custom CSS file, you can often add it to the very bottom of theme.css or base.css. Alternatively, many themes have a 'Custom CSS' box directly in the Theme Editor (Online Store > Themes > Customize > Theme settings > Custom CSS). This is usually the safest place to add custom code without directly modifying core theme files.
  4. Add one of the following code snippets to the file you've chosen.

Option A: General ':focus:not(:focus-visible)' Fix (from @tim_1)

This attempts to remove outlines for non-keyboard focus events universally:

:focus:not(:focus-visible) {
    outline: none !important;
}

Option B: Cart-Drawer Specific Fix (from @ShopIntegrations)

This targets only elements within your cart drawer. It tries to override the focus outline and box-shadow if they are being incorrectly applied:

.cart-drawer button:focus-visible, 
.cart-drawer a:focus-visible {
outline: none !important;
box-shadow: none !important;
}

After adding the code, save your changes and test your cart drawer extensively in Safari (and other browsers!) to ensure the double box is gone and that keyboard navigation still provides a clear focus indicator where appropriate.

Ultimately, while these CSS snippets can help clean up an unwanted visual glitch, it's always a delicate balance. We want our stores to look polished, but never at the expense of making them difficult for some customers to use. The conversation in the community highlights the importance of understanding *why* something is happening before we jump to a fix. For persistent visual quirks like this in a specific theme and browser, the theme developer is often your best friend. Happy optimizing!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools