Focus Indicator CSS: WCAG 2.2-Ready Patterns for Every Component
Last updated: November 30, 2026
Focus indicator CSS in 2026 means a visible, 3:1-contrast ring on every focusable element β via `:focus-visible`, not the default outline a designer stripped and never replaced β that still shows up behind sticky headers and under Windows High Contrast mode. WCAG 2.2's 2.4.11 raised the bar: a ring that exists but sits hidden behind a sticky nav no longer passes. Below: copy-paste patterns for what a real storefront throws at a focus ring.
Key numbers: WCAG 2.2 governs focus indicators through three criteria in force at Level AA β 2.4.7 Focus Visible, 1.4.11 Non-text Contrast, and the new 2.4.11 Focus Not Obscured (Minimum) β three of 86 criteria the standard enforces overall (W3C). 95.9% of the top one million home pages carried a detectable WCAG failure in 2026, averaging 56.1 errors per page (WebAIM Million, 2026). Shipping `outline: none` with no replacement is among the most common findings in TestParty's Shopify audits, out of the 35 million-plus issues remediated across 100+ brands as of 2026 (TestParty internal data). Shopify's Theme Store requirements cover only 16β22% of WCAG 2.2's criteria, so a custom section rarely faces any focus-indicator standard before it ships (TestParty audit data, 2026).
What does WCAG require of focus indicators?
WCAG requires three things at once: a focus indicator must exist (2.4.7), it can't be fully hidden by sticky UI (2.4.11), and it must contrast at least 3:1 against whatever sits next to it (1.4.11).
2.4.7 Focus Visible (AA) is the oldest and loosest of the three β some visible change on keyboard focus, no rule on size, shape, or color. 2.4.11, new in 2.2, closes the gap that let 2.4.7 pass on paper and fail in practice: a sticky header, cookie banner, or chat launcher can no longer fully cover the focused element. 1.4.11 Non-text Contrast supplies the number 2.4.7 never gave: a focus indicator is a UI component boundary, needing 3:1 against adjacent colors, not the 4.5:1 text gets.
Two AAA criteria go further, as aspirational guidance most sites skip: 2.4.12 Focus Not Obscured (Enhanced) requires zero pixels hidden, and 2.4.13 Focus Appearance adds a minimum size β roughly a 2 CSS-pixel perimeter β atop the same 3:1 rule. TestParty's breakdown of WCAG 2.2's new success criteria covers all four in depth.
Against that stack, the most-shipped CSS crime is `outline: none` with nothing to replace it β stripped because the default ring looks "messy," with the fix never landing. That one line fails 2.4.7 outright, and by definition 2.4.11 and 1.4.11 too: nothing is left to obscure or contrast-check.
What's the modern baseline pattern?
`:focus-visible` is the 2026 baseline: a keyboard-driven ring governed by the browser's own heuristic, with support solid enough across evergreen browsers that a `:focus` fallback is no longer worth writing.
The heuristic isn't a pure "keyboard versus mouse" switch. A browser shows the ring on Tab-driven focus, skips it on a mouse click to a button or link, and still shows it after a mouse click to a text input, since typing is the expected next action either way. That nuance is built into the pseudo-class, not something to replicate by hand.
/* Fixes WCAG 2.4.7: ring shown for keyboard focus, skipped on a plain
mouse click to a button or link */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
outline: 3px solid #1a56db;
outline-offset: 2px;
}
/* a:focus { outline: none; } */ /* the most-shipped CSS crime β instant 2.4.7 fail */Outline beats box-shadow as the base mechanism for two reasons: it never affects layout or triggers reflow the way adding a border would, and β covered in full below β it keeps working in forced-colors mode, where box-shadow is suppressed entirely.
How do you make indicators meet contrast everywhere?
A single-color ring only clears 1.4.11's 3:1 threshold against the specific background it was tuned for β pair it with a second, opposite-toned ring so the indicator supplies its own contrast against light backgrounds, dark sections, and brand colors alike.
The pattern is a halo: a thin light outline against the element, backed by a thin dark shadow one step out. Wherever it lands, one of the two rings has a light-to-dark transition against the surface underneath, so the 3:1 check passes without a background-specific override anywhere in the theme.
/* Fixes 1.4.11 everywhere: a halo that hits 3:1 on light backgrounds,
dark sections, and mid-tone brand colors alike β no per-background override */
:focus-visible {
outline: 2px solid #ffffff;
outline-offset: 1px;
box-shadow: 0 0 0 4px #0b0b0c;
}Test the result the way a contrast audit tests text: sample the actual pairs a ring sits against, rather than trusting the halo by eye. In TestParty's audits, the most common indicator-contrast finding isn't a missing ring β it's a brand-colored ring, chosen to "match the brand," that measures under 3:1 on that same brand's own colored button (TestParty internal data). The halo above is TestParty's first fix once that happens, since it stops depending on which color a component sits on.
How do you handle the hard components?
Sitewide rules cover most elements; a handful of components need their own pattern, because the ring has to land somewhere other than the element that literally received focus.
Cards and product tiles. A stretched-link card β the whole tile is clickable, one `<a>` supplies the tab stop β puts a plain `:focus-visible` ring on a pixel-thin, invisible element. Move the ring to the card itself:
/* Fixes 2.4.7 on stretched-link cards β :has() rings the card only on
true keyboard focus; :focus-within alone would also ring on a click */
.product-card { position: relative; }
.product-card__link { position: absolute; inset: 0; }
.product-card__link:focus-visible { outline: none; } /* ring moves to the card */
.product-card:has(.product-card__link:focus-visible) {
outline: 3px solid #1a56db;
outline-offset: 2px;
}Form inputs. Border-color alone fails the moment a field's default and "focused" borders are close in hue β pair the color change with a real outline so the state doesn't rely on one signal:
/* Fixes 1.4.11: a color-only focus state fails if default and focused
borders are close in hue β the outline supplies a second signal */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
border-color: #1a56db;
outline: 2px solid #1a56db;
outline-offset: 2px;
}Buttons across dark and light sections. A ring color tuned for the default section fails once a merchant assigns a dark scheme to a promo block. Give each Shopify color scheme its own `--focus-ring` value, checked against that scheme's background β the same custom-property approach TestParty's Shopify color contrast guide uses for text tokens:
/* Fixes 1.4.11 per scheme β not one ring color guessed to fit every section */
.color-scheme-1 { --focus-ring: #1a56db; } /* light section: ~8:1 */
.color-scheme-2 { --focus-ring: #ffd166; } /* dark section: ~9:1 */
button:focus-visible,
a:focus-visible {
outline: 3px solid var(--focus-ring, #1a56db);
outline-offset: 2px;
}Sticky headers and 2.4.11. A sticky header can cover the exact element a shopper just tabbed to. Reserve space equal to its height, either on the focusable elements (`scroll-margin-top`) or once on the scroll container (`scroll-padding-top`), so focus lands clear of it:
/* Fixes WCAG 2.4.11: reserves space so focus scrolls clear of a sticky
header instead of landing underneath it */
:root { --sticky-header-h: 64px; }
:is(a, button, input, [tabindex]):focus-visible {
scroll-margin-top: var(--sticky-header-h);
}Skip targets. `tabindex="-1"` makes a skip link's destination focusable by script without joining the normal Tab order β it doesn't exempt that target from 2.4.7. TestParty's skip-to-content link guide covers placement and testing in full.
What about forced-colors and Windows High Contrast?
`forced-colors: active` keeps `outline` visible β the browser repaints its color from the user's system palette β while it suppresses `box-shadow` entirely, so a ring built only from a shadow disappears for Windows High Contrast users regardless of how it looks normally.
The fix for a ring built from box-shadow or background color is a transparent outline: invisible in normal mode, since the shadow supplies the real ring, but forced-colors mode overrides that transparent value with a system color as long as `outline-style` isn't `none` β a real ring for high-contrast users, for free.
/* Fixes 2.4.7/1.4.11 under forced-colors: box-shadow is suppressed, but
outline-color still gets forced to a system value as long as
outline-style isn't none β a transparent outline costs nothing normally */
.card:focus-visible {
outline: 2px solid transparent;
outline-offset: 2px;
box-shadow: 0 0 0 3px #1a56db; /* the visible ring in normal color mode */
}How do you roll this out theme-wide?
Rolling this out theme-wide means defining the ring once as a token, applying it to every interactive selector in a single rule, and writing down exceptions instead of letting each component drift on its own.
That's the `--focus-ring` custom property from above, generalized: one variable at `:root` (or overridden per scheme), consumed by a single selector list covering links, buttons, inputs, and any `[tabindex]` element β a themer changes the ring in one place, not forty. Shopify's own Dawn theme is a reasonable baseline: TestParty's Dawn theme accessibility audit found a documented `:focus-visible` implementation out of the box, though that coverage rarely survives once a merchant adds custom sections or app widgets that never inherited it.
Document every exception on purpose, rather than letting a missing rule pass as an oversight nobody caught. Automated scanners are a weak regression check: they flag `outline: none` in source, but whether a ring survives a sticky header, whether `:has()` fires instead of `:focus-within`, and whether the halo still hits 3:1 on a new brand color all need a manual Tab-key pass. TestParty's keyboard accessible navigation guide has that walkthrough, plus the other four keyboard criteria a ring alone doesn't satisfy.
Frequently Asked Questions
Does :focus-visible replace :focus entirely? No β keep `:focus` for states that should persist regardless of input method, like a field flagged invalid mid-form. For the ring itself, `:focus-visible` is the right default: the browser's own keyboard-versus-pointer heuristic, not a hand-built detector.
Why does a box-shadow-only focus ring fail some users? Box-shadow is suppressed entirely in forced-colors mode, so a ring built only from it disappears for Windows High Contrast users. Outline survives, since its color gets forced to a system value as long as `outline-style` isn't `none` β an accessible ring should always include a real outline, even a transparent one.
Does WCAG 2.2 require a minimum focus-ring thickness? Only at Level AAA, under 2.4.13 Focus Appearance, which adds a minimum size on top of a 3:1 contrast rule. No AA-level criterion sets a thickness: 2.4.7 only requires an indicator exists, and 1.4.11 requires 3:1 contrast wherever it does.
Can an automated scanner catch a missing or hidden focus indicator? Only partially. A scanner flags `outline: none` in source, but whether the replacement ring is visible against every background, whether a sticky header covers it, and whether a card rings on a plain mouse click all need a manual Tab-key pass β why TestParty pairs automated scans with manual review on every audit.
Does a custom-styled checkbox or radio button need its own focus ring? Yes. Hiding the native input with `appearance: none` or `opacity: 0` removes its default focus ring along with its look, so the `<span>` or `<label>` standing in for it needs its own `:focus-visible` rule wired to that input β otherwise a keyboard user loses the indicator once the control gets restyled.
Like everything at TestParty, this article reflects our cyborg philosophy: AI handles the heavy lifting, humans bring the expertise. The data and opinions here are based on publicly available sources as of publication. TestParty is a participant in the accessibility market β we believe in transparency, so we encourage you to cross-reference our claims and evaluate all options for your business.
Stay informed
Accessibility insights delivered
straight to your inbox.


Automate the software work for accessibility compliance, end-to-end.
Empowering businesses with seamless digital accessibility solutionsβsimple, inclusive, effective.
Book a Demo