Search
Search pages, pieces and blocks.
Focus
Keyboard only, never after a click. One outline for things you press, one darker edge for things you type in, and the order follows the page.
- Width
- 1.5, --size-focus
- Offset
- 1
- Colour
- --ring
In a real piece
A dialog with the Email field focused. Numbers are the Tab order, read from the DOM. Hover one.
6 stops, top to bottom, left to right. Nothing is skipped and nothing jumps.
- 1CloseOutline
- 2NameField
- 3Email, focused nowField
- 4Can issue refundsOutline
- 5CancelOutline
- 6Send inviteOutline
Invite an instructor
They can see their lessons and message students.
Three indicators
From the Focus E block in globals.css. It sits outside any layer, so it wins over the stock ring utilities.
Outline
Buttons, links, Checkbox, Radio, Switch, tabs. 1.5 solid ring, 1 away from the edge.
outline: var(--size-focus) solid var(--ring)Field
Input, Textarea, Select, Native Select, Input Group, Combobox. The edge darkens to field-focus and a soft 3px halo grows outside, on any focus, a click included.
border-color: var(--field-focus); --tw-ring-color: var(--halo)| MR-2041 | Tomás Amaro | €90.00 |
Row
A clickable table row. The same outline, drawn inside so the table frame never clips it.
outline-offset: calc(var(--size-focus) * -1)Contrast
A focus indicator needs 3:1 against what is next to it.
| Indicator | Tokens | Day | Night | WCAG 2.2, 1.4.11 |
|---|---|---|---|---|
| Outline on the page | ring on background | 12.26 | 12.72 | Passes 3:1 |
| Outline on a hover fill | ring on muted | 11.54 | 10.92 | Passes 3:1 |
| Field edge | field-focus on background | 3.27 | 3.56 | Passes 3:1 |
| Unfocused Checkbox edge | mark-edge on background | 3.94 | 3.56 | Passes 3:1 |
| Halo | halo, 9% | 1.17 | 1.26 | Decorative, the edge carries it |
Overlays trap focus
Dialog, Alert Dialog, Sheet and Drawer are modal: focus moves in, stays in, and goes back. App Shell's takeover does the same with its own trapTab.
Invite an instructor
Tab from the last control wraps to the first. Shift Tab wraps back.
- 1 Opens: focus moves into the dialog
- 2 Tab stays inside
- 3 Esc or Cancel: focus returns to Invite
Do and don't
Rules
- 1Use focus-visible, never focus. A click should not leave a ring behind.
- 2Never remove the outline without a replacement that reaches 3:1.
- 3Tab order is DOM order. Do not use a positive tabindex to fix a layout.
- 4An overlay takes focus on open, keeps it while open, and returns it to the trigger on close. A confirm puts it on Cancel.