Skip to content

Glossary

Focus visible

Focus visible means the element that has keyboard focus is clearly marked, usually with a ring, so a person using the keyboard always knows where they are. In CSS, `:focus-visible` applies that style only when the browser judges the focus should be shown, as after a Tab press, and not after every mouse click on a button. WCAG 2.2 requires a visible focus indicator at level AA (2.4.7).

By Bohuslav PoláčekChecked

css
/* packages/kit/src/styles/kit.css */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* packages/kit/src/styles/palette.css (generated) */
:root {
  --ring: oklch(0.4 0 0);
}
.dark {
  --ring: oklch(0.82 0 0);
}
The kit's focus rule from kit.css, and the ring colour the palette generates for each theme.

Why it matters in a business app

People who process a queue all day often work from the keyboard: arrows down the list, Enter to open, a shortcut to approve. Without a visible ring they lose their place after the first action. The same goes for anyone who cannot use a mouse.

Teams remove focus rings because they appear after mouse clicks and look like a bug. :focus-visible answers that: the browser shows the ring for keyboard focus and for text fields, and generally not when a button was clicked with a pointer.

How Meadowstack handles it

  • One rule. kit.css sets a 2px outline in --ring with a 2px offset on :focus-visible, for every element. Components do not draw their own.
  • Neutral, never blue. AGENTS.md: focus is a dark neutral ring (outline-ring), like the rest of the chrome, which has no accent.
  • A contrast floor. The palette generator pushes the ring until it reaches 3:1 on every surface a focused control can sit on (frame, canvas, surface, the selected row, raised panels), and npm run check:contrast checks those pairs in both themes (WCAG 1.4.11).
  • No animation. The motion guard makes every state change move, except outline and ring utilities under focus-visible: a focus ring must appear at once.
  • Not hidden. Rows under a sticky header retire their controls, so focus is never left under it.

Common mistakes

  • outline: none with nothing instead. The commonest way to fail 2.4.7.
  • Styling :focus only. Rings then show on every click, and the next designer removes them.
  • A brand-coloured ring. It may pass on white and fail on a grey sidebar or a selected row.
  • A ring clipped by overflow: hidden. The offset puts it outside the control; give the container room or an inset ring.

Sources

Questions

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

:focus matches whenever an element has focus, however it got it. :focus-visible matches only when the browser decides the focus should be shown, such as after keyboard navigation or in a text field.

Do all browsers support :focus-visible?

Yes. MDN lists it as Baseline, widely available across browsers since March 2022.

How much contrast does a focus ring need?

WCAG 2.2 at level AA asks for 3:1 against adjacent colours for the visual parts of components and their states (1.4.11). Meadowstack's palette holds the ring at 3:1 or more on every surface a control can sit on.

Should the focus ring animate in?

No. It has to be there the moment focus arrives, so Meadowstack's motion guard leaves focus rings out of its rule that everything else must transition.

Two ways

Build it yourself, or have it built

  • Build it yourself

    Build your app on the framework

    Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.

    One payment, lifetime updates

    Get the framework
  • Have it built

    Have us build your app

    Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.

    After launch, Care keeps it improving, from €99 a month.

    from €1,990

    Describe your app