DevTools Logo

Focus Ring Generator

Focus Ring Generator

Design accessible :focus-visible indicators with real contrast checks and a live tab-through demo.

Runs in your browserWCAG SC 1.4.11
Try an example

Ring builder

outline

Contrast compares the composited indicator color with the page background and, where the ring touches it, the element surface. A pass means ≥ 3:1 under WCAG SC 1.4.11.

CSS and preview

1/1 contrast checks pass

Ring vs page background · effective #1d4ed86.70:1 pass

:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

:focus-visible {
  outline: 3px solid rgb(29, 78, 216);
  outline-offset: 2px;
}

Press Tab inside these controls to see the generated ring.

Page background

Link

Dark surface

Link

Examples

WCAG-safe outline

Input
:focus-visible {
  outline: 3px solid rgb(29, 78, 216);
  outline-offset: 2px;
}

A 3 px ring with a 2 px gap passes 3:1 non-text contrast on a white page.

Brand shadow ring

Input
:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 0px;
  box-shadow: 0 0 0 3px rgb(124, 58, 237);
}

The transparent outline is a high-contrast-mode safety net while the shadow carries the visual style.

Forced-colors fallback

Input
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid Highlight; box-shadow: none; }
}

Windows forced-colors mode drops box-shadow, so the fallback restores a visible system-color outline.

About this tool

Pick a focus indicator style and its color, width, offset and opacity. The tool emits a :focus-visible CSS block (optionally as tokens, with a scoped selector, a pointer-focus reset and a forced-colors fallback) and checks the indicator against the page background and the element surface. Translucent colors are composited in sRGB before luminance is computed. A split demo lets you tab through real controls on light and dark surfaces.

Everything runs locally in your browser — your inputs stay on your device and are never uploaded to a server.

What this tool does not do

  • Processes only the inputs provided in this session without connecting to external accounts or background servers.
  • Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.

How to use this tool

  1. Pick outline, shadow, or dual ring

    Customize ring color, width, offset, and surface colors.

  2. Verify 3:1 WCAG contrast

    Check computed contrast ratios on light and dark backgrounds and tab through the live demo.

  3. Copy :focus-visible CSS

    Copy production CSS including optional forced-colors high-contrast fallbacks.

Use cases

WCAG-safe outline

A 3 px ring with a 2 px gap passes 3:1 non-text contrast on a white page.

Brand shadow ring

The transparent outline is a high-contrast-mode safety net while the shadow carries the visual style.

Forced-colors fallback

Windows forced-colors mode drops box-shadow, so the fallback restores a visible system-color outline.

Common mistakes

Mistake:What contrast ratio does WCAG require for focus indicators?

Fix:WCAG 2.1/2.2 Non-text Contrast (1.4.11) and Focus Appearance guidance look for at least a 3:1 contrast ratio between the focus indicator and adjacent background colors.

Mistake:Why include a transparent outline when using box-shadow rings?

Fix:Windows High Contrast (forced-colors) mode strips box-shadow declarations; keeping outline: 2px solid transparent (or a @media (forced-colors: active) rule) preserves a visible system focus ring.

Frequently asked questions

Why prefer :focus-visible over :focus?

:focus-visible shows prominent focus rings for keyboard navigation (Tab, arrow keys) while avoiding persistent rings after routine mouse clicks on buttons.

What contrast ratio does WCAG require for focus indicators?

WCAG 2.1/2.2 Non-text Contrast (1.4.11) and Focus Appearance guidance look for at least a 3:1 contrast ratio between the focus indicator and adjacent background colors.

Why include a transparent outline when using box-shadow rings?

Windows High Contrast (forced-colors) mode strips box-shadow declarations; keeping outline: 2px solid transparent (or a @media (forced-colors: active) rule) preserves a visible system focus ring.

Does this guarantee full page accessibility compliance?

It verifies color math against the surfaces you test here, but real-world compliance also depends on tab order, focus traps, and variable page backgrounds.