Skip to main content
⌘K

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-2041Tomá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.

IndicatorTokensDayNightWCAG 2.2, 1.4.11
Outline on the pagering on background12.2612.72Passes 3:1
Outline on a hover fillring on muted11.5410.92Passes 3:1
Field edgefield-focus on background3.273.56Passes 3:1
Unfocused Checkbox edgemark-edge on background3.943.56Passes 3:1
Halohalo, 9%1.171.26Decorative, 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.

Instructors

Invite an instructor

Tab from the last control wraps to the first. Shift Tab wraps back.

  1. 1 Opens: focus moves into the dialog
  2. 2 Tab stays inside
  3. 3 Esc or Cancel: focus returns to Invite

Do and don't

After a click
After Tab
Dofocus-visible: the ring appears for the keyboard and stays away for the mouse.
After a click
After Tab
Don'tA cobalt glow on click, and outline: none with nothing in its place for the keyboard.

Rules

  1. 1Use focus-visible, never focus. A click should not leave a ring behind.
  2. 2Never remove the outline without a replacement that reaches 3:1.
  3. 3Tab order is DOM order. Do not use a positive tabindex to fix a layout.
  4. 4An overlay takes focus on open, keeps it while open, and returns it to the trigger on close. A confirm puts it on Cancel.