# 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).

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/glossary/focus-visible/

*The kit's focus rule from kit.css, and the ring colour the palette generates for each theme.*

```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);
}
```

## 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](https://meadowstack.com/glossary/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.

## 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.

## Sources

- [MDN, :focus-visible](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible), checked 2 December 2026
- [WCAG 2.2, 2.4.7 Focus Visible and 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/), checked 2 December 2026

## Related

- [GanttChart: a project schedule with its links and key dates](https://meadowstack.com/components/gantt-chart/) (Components)
- [Heatmap: when the work happens, by weekday and hour](https://meadowstack.com/components/heatmap/) (Components)
- [Notice: messages by importance, in one frame](https://meadowstack.com/components/notice/) (Components)
- [ResourceTimeline: bookings across resources, hour by hour](https://meadowstack.com/components/resource-timeline/) (Components)
- [SortableBoard: a kanban board that works from the keyboard](https://meadowstack.com/components/sortable-board/) (Components)
- [StatusLabel: a status as a glyph and a word](https://meadowstack.com/components/status-label/) (Components)
