Skip to content
⚠ TESTING ENVIRONMENT You are viewing a testing copy of Tolioo. Changes here do not affect the live website.

Focus Indicator Generator

Design an accessible CSS focus ring, test it with your keyboard, check the WCAG contrast and copy the code. Fast, free and no signup.

  • 100% free
  • WCAG contrast check
  • CSS and Tailwind code

Focus style

3 px
2 px
ADVERTISEMENT
Demo Ad 728 x 90

How to create an accessible focus indicator

1Design the ring

Pick a preset or set the thickness, offset and colors.

2Test it

Press Tab in the preview and read the contrast checks.

3Copy the code

Paste the CSS or Tailwind classes into your project.

FOCUS STYLES GUIDE

Focus Indicator Generator – Create an Accessible CSS Focus Ring (:focus-visible) with WCAG Contrast Checks

Looking for a free focus indicator generator? Design a clear, accessible CSS focus ring in seconds. Choose the thickness, offset, color and style of the outline, try a ready-made preset such as a double ring, a glow or a thick block, and see the result on real buttons, links, inputs, checkboxes and cards. Press the Tab key in the live preview to test it the way keyboard users do. The tool checks the contrast of your focus color against the page and the component, reports whether it meets WCAG 1.4.11 and the thickness guidance of WCAG 2.4.13, and then gives you clean :focus-visible CSS, with optional high contrast mode support, or ready-to-use Tailwind classes. A visible focus style is one of the simplest and most important accessibility fixes for any website. There is no signup and nothing to install, and everything runs in your browser.

Test with the Keyboard

Use the Tab key in the live preview to see your focus ring on buttons, links, form fields and custom cards, or show focus on all of them at once.

WCAG Contrast Checks

See the contrast ratio of the ring against the background and the component, and get clear pass and warning messages.

CSS and Tailwind Code

Copy production-ready :focus-visible CSS or Tailwind classes, with an optional forced-colors rule for Windows high contrast mode.

What Is a Focus Indicator?

A focus indicator, also called a focus ring, focus outline or focus state, is the visual cue that shows which element has keyboard focus. When a person presses the Tab key to move through links, buttons and form fields, the focus indicator shows where they are on the page. It is essential for people who cannot use a mouse, including people with motor disabilities, people who use a keyboard or switch device, and screen reader users who also see the screen, as well as power users who simply prefer the keyboard. Without a visible focus indicator, keyboard navigation turns into guesswork.

How to Use the Focus Indicator Generator

  1. Pick a preset or start from scratch: Presets such as Classic, Two-tone, Glow and Thick give you a good starting point.
  2. Set thickness and offset: Use at least 2 pixels, and preferably 3, with a small offset so that the ring does not blend into the element.
  3. Choose your colors: Set the ring color, the page background and the component color to match your design. For a two-tone ring, also choose the inner ring color.
  4. Test with the keyboard: Click in the preview and press Tab. Switch on Show focus on all to compare every element at once.
  5. Fix any warnings and copy the code: When the checks look good, copy the CSS or Tailwind classes into your project.

How to Style Focus with :focus-visible

The :focus-visible pseudo-class is the modern way to style keyboard focus. It is supported in all current browsers, and it shows the ring when the browser decides that an indicator is useful, which is mainly during keyboard navigation. A basic accessible focus style looks like this:

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

The outline follows the shape of the element, including rounded corners in modern browsers, and the outline-offset property adds a gap between the element and the ring, which makes the indicator easier to see. Using outline instead of border or width changes also means that the ring does not shift the layout when it appears.

:focus vs :focus-visible vs :focus-within

CSS has several focus-related selectors. Knowing the difference helps you pick the right one for each job.

SelectorWhen it matchesUse it for
:focus Matches whenever an element has focus, including after a mouse click A fallback for very old browsers
:focus-visible Matches when the browser decides a visible indicator is helpful, mostly keyboard use The best choice for most focus rings
:focus-within Matches a container when it or any child has focus Highlighting a form group, card or search box
:focus:not(:focus-visible) Matches focus that came from a mouse or touch Removing the ring for pointer users, if a design needs it

WCAG Requirements for Focus Indicators

Several success criteria in the Web Content Accessibility Guidelines (WCAG) deal with focus. Together they describe a focus indicator that is present, easy to see and not hidden.

CriterionLevelWhat it asksHow this tool helps
2.4.7 Focus Visible AA Every keyboard-operable control must have a visible focus indicator The live preview shows the ring on real controls
1.4.11 Non-text Contrast AA UI components and states need a 3:1 contrast with adjacent colors The contrast checker tests the ring against the page and the component
2.4.11 Focus Not Obscured (Minimum) AA (WCAG 2.2) A focused element must not be completely hidden by other content Use scroll-padding and check sticky headers (see the guide)
2.4.13 Focus Appearance AAA (WCAG 2.2) A strong indicator: at least 2 CSS px thick perimeter and a 3:1 change in contrast The thickness check follows this guidance
1.4.1 Use of Color A Color alone must not be the only way to show information Prefer an outline or ring over a color change alone

Many accessibility laws and standards refer to WCAG, including the ADA in the United States, Section 508 and the European standard EN 301 549. This page is general information and not legal advice.

Focus Indicator Contrast: How to Get 3:1

A focus indicator has two neighbors: the page background on the outside and the component on the inside. The ring needs enough contrast against the colors it touches. A color such as medium blue works on a white page but can fade on a dark blue button, and a light ring works on dark backgrounds but disappears on white. The most reliable solution is a two-tone ring: an outer outline in one color and an inner ring in a strongly contrasting color. At least one band always stands out, whatever the background is.

:focus-visible {
  outline: 2px solid #1e3a8a;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #ffffff;
}

In this example, the 2 pixel box-shadow fills the gap created by the 2 pixel outline offset, which gives a white inner band and a dark blue outer band.

Never Use outline: none Without a Replacement

One of the most common accessibility mistakes is to remove the focus outline because the default ring looks ugly or appears when a button is clicked. The better solution is to use :focus-visible, so that the ring shows for keyboard users only, and to design a ring that fits your brand. If you do remove the default outline, always add another clear visible style, such as a thick outline, a ring made with box-shadow or a strong border change. Remember that box-shadow and background changes are removed in some high contrast modes, so keep an outline in the rule.

Support for Windows High Contrast Mode (forced-colors)

People who use Windows high contrast or other forced color modes see the page with a limited set of system colors. In this mode, most author colors and shadows are replaced, but outlines are kept. Adding a forced-colors rule helps you make sure the focus ring uses a system color that stands out.

@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid CanvasText;
    outline-offset: 2px;
  }
}

Focus Styles for Buttons, Links, Inputs and Cards

Different components call for slightly different treatments. Use one shared focus style across your site so that it is consistent and easy to recognize, and adjust the offset or color only where needed.

ComponentRecommended focus styleNote
Links An outline with a 2 px offset, or a thick underline plus an outline The default ring is often enough, make sure it has contrast
Buttons A 3 px outline with a 2 px offset. A two-tone ring works on colored buttons Do not rely on a background color change alone
Text inputs and selects A visible outline or a thicker colored border plus a ring Keep the border contrast at 3:1 as well
Checkboxes and radios A ring around the custom control, not only the hidden input Style the visible control when the real input has focus
Cards and custom widgets Use :focus-visible on the container with tabindex="0" and a visible ring Make sure the whole card shows the focus
Dark backgrounds A light ring, or a two-tone ring with a dark inner band Test again on every dark theme color

Focus Not Obscured: Sticky Headers and Banners

A good focus ring is useless if the focused element is hidden under a sticky header, a cookie banner or a chat widget. WCAG 2.2 criterion 2.4.11 asks that a focused element is not entirely hidden by other content. You can fix the most common case with scroll-padding, which tells the browser to keep space at the top of the scroll area when it brings a focused element into view.

html {
  scroll-padding-top: 80px; /* height of your sticky header */
}

Skip Links and Focus Order

Focus indicators work together with a logical tab order. Keep the order of focusable elements in line with the visual order, avoid positive tabindex values, and add a skip link at the top of the page so that keyboard users can jump past the navigation. Make sure the skip link becomes visible when it receives focus.

<a class="skip-link" href="#main">Skip to main content</a>
...
<main id="main" tabindex="-1">...</main>

Common Focus Indicator Mistakes

MistakeProblemFix
outline: none with no replacement Keyboard users cannot see where they are Add a visible outline, ring or other clear style
A very thin or faint ring Hard to see, especially for low vision users Use at least 2 px, ideally 3 px, with 3:1 contrast
A ring with the same color as the background The indicator disappears on some components Use a two-tone ring or test against every background
Only a subtle color change on focus Fails for color blindness and low contrast Add an outline or border change
Hiding focus for everyone with :focus Removes the indicator for keyboard users too Use :focus-visible and keep the ring for keyboard focus
Focus ring clipped by overflow: hidden The ring is cut off at the container edge Use outline-offset carefully or add padding to the container
Focused item hidden under a sticky header The user cannot see the focused element Add scroll-padding-top equal to the header height
Different styles on every component Users have to relearn the focus style Define one consistent focus style in a shared rule

Focus Ring in Tailwind CSS

Tailwind provides the focus-visible variant, so you can write a focus ring directly in your class list, for example focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2. The Tailwind tab of this generator creates classes with arbitrary values for your exact thickness, offset and colors. For a two-tone ring, it adds a box-shadow class as well. If you use Tailwind v4, check the outline utilities in your version, because the base outline class changed.

How to Test Focus Indicators

  • Use only the keyboard: Press Tab and Shift+Tab through your page. You should always know where the focus is.
  • Check every component: Test links, buttons, form fields, menus, modals, custom widgets and the skip link.
  • Test on every background: Check light sections, dark sections, images and colored buttons.
  • Force the state in DevTools: In browser developer tools you can force the :focus-visible state on an element to inspect it.
  • Run an automated audit: Tools such as axe, WAVE and Lighthouse find some focus problems, but they cannot judge visibility, so test by hand too.
  • Try zoom and high contrast: Zoom to 200% and try a forced colors or high contrast mode.

Free and Private Focus Ring Generator

This CSS focus ring generator is free to use as often as you like, with no signup and no limits. It runs entirely in your browser, so your colors and settings are never sent to our server. Design your focus style, test it with the Tab key, check the contrast and copy the code to make your website easier to use for everyone.

ADVERTISEMENT
Demo Ad 300 x 250
COMMON QUESTIONS

Frequently Asked Questions About Focus Indicators

Find answers to common questions about focus rings, :focus-visible, contrast and WCAG.

What is a focus indicator?

A focus indicator is the visual outline or highlight that shows which element on a page currently has keyboard focus, such as a link, button or form field. When someone presses the Tab key to move through a page, the focus indicator tells them where they are. Browsers show a default focus ring, and you can replace it with your own CSS style, as long as it stays clearly visible.

How do I create an accessible focus style in CSS?

Use the :focus-visible pseudo-class and give it a clear outline, for example :focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }. Make the indicator at least 2 pixels thick, give it a color contrast of at least 3:1 against the colors next to it, and never remove the default outline with outline: none unless you provide a better replacement. This generator builds the CSS for you and checks the contrast.

What is the difference between :focus and :focus-visible?

The :focus pseudo-class matches an element whenever it has focus, including after a mouse click. The :focus-visible pseudo-class matches only when the browser decides that a visible indicator is helpful, which is usually when the user navigates with the keyboard. Using :focus-visible lets you show a strong ring for keyboard users without showing it on every mouse click on a button.

What contrast ratio does a focus indicator need?

WCAG 1.4.11 Non-text Contrast (Level AA) asks for a contrast ratio of at least 3:1 for the visual information that identifies user interface components and their states, which includes focus indicators. The ring should have at least 3:1 contrast against the colors it touches, such as the page background and the component itself. A two-tone ring, with a light and a dark band, is a reliable way to meet this on any background.

Is outline: none bad for accessibility?

Yes, if you remove the outline and do not replace it. Keyboard users then cannot see where they are on the page, which fails WCAG 2.4.7 Focus Visible (Level AA). If you want a different look, replace the outline with your own visible style, for example a thicker outline, a box-shadow ring or a color change. Never leave an interactive element with no visible focus state.

What do WCAG 2.4.11 and 2.4.13 require?

WCAG 2.2 added two focus criteria. 2.4.11 Focus Not Obscured (Minimum), Level AA, requires that a focused element is not completely hidden by other content such as a sticky header or a cookie banner. 2.4.13 Focus Appearance, Level AAA, describes a strong indicator: an area at least as large as a 2 CSS pixel thick perimeter of the element, with a contrast change of at least 3:1 between the focused and unfocused states. Following the AAA guidance is a good target even if you only need AA.

Is this focus indicator generator free and private?

Yes. It is free, needs no signup and runs entirely in your browser. Your colors and settings are not sent to our server. You can press the Tab key in the preview to see your focus style on real elements, check the contrast results, and copy the CSS or the Tailwind classes into your project.

ADVERTISEMENT
Demo Ad 320 x 50

All Tools, One Place

Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.

Explore All Tools →