Focus
Components: Button, Card, CardContent, Input, Textarea, InputGroup, Checkbox, Radio
+8 more
Switch, DropdownMenu, DropdownMenuItem, Select, SelectOption, NavRail, Slider, Link
Keyboard focus is a 3px ring in a translucent focus color, shown on :focus-visible.
DS components draw it already. Write a ring only on elements your app builds.
What you use
Rules
- Use
focus-visible:, notfocus:. The ring is for keyboard focus only. - Pair the ring with
outline-none, so the browser outline and the ring never show together. - Use
ring-3. Never copyring-2from Card, Resizable, CodeEditor or SimpleCharts: it is known drift. - Always set a
ring-focus-*color.ring-3alone draws the default color. - Keep the element's radius; the ring follows it.
- If a parent has
overflow-hidden, addring-inset. - If the control is brand-colored (
Buttonwithcolor='brand'in any variant, a checked or indeterminate Checkbox, a checked Radio or Switch), usering-focus-brand. Neutral controls (Buttonwithcolor='neutral'or'neutral-alt', unchecked Checkbox, Radio or Switch, tabs, tags, inputs) usering-focus-primary. - If the control is destructive (
Buttonwithcolor='destructive', any variant), usering-focus-destructive. - If you build a text field, match
Input: on focus,focus-visible:not-disabled:border-border-strong-primaryplusring-focus-primary. Invalid: keepborder-border-strong-danger, ringring-focus-destructive, hoverring-focus-destructive-hover. - If an input sits inside a styled wrapper, put the ring on the wrapper.
- If focus moves by arrow keys (menu, listbox), the highlighted row is the indicator.
DropdownMenuItemandSelectOptionusebg-states-primary-hover; brand and danger items usebg-states-brand-hoverandbg-states-danger-hover. NavRailitems show an overlay (overlay-states-primary-hover); theSliderthumb scales up with a shadow. Neither gets a ring.- Never add a ring to a menu item or listbox option.
- Never add a ring to a popover, dialog or drawer surface (
DropdownMenu,Selectcontent,Drawer). - Never use
outline-noneon an interactive element without a replacement indicator. - Never use a border color,
ring-border-*or a raw palette color as a focus ring. - Never use
ring-focus-ring-primary. The token exists but nothing uses it. - Never add
ring-offset-*. DS rings sit flush. - Never override a DS component's ring through
className. Pick thecolorprop.
What does not exist
- No bare
ring-focustoken; always add a suffix. - No
--ringor ring-width token. Width is thering-3utility. - No
focusRingprop on any component. - No exported focus-ring class helper. Write the class string.
Linkhas no focus-visible style, onlyoutline-none. This is a known gap.
Examples
A DS button picks its ring color from color; no class needed.
A card becomes focusable and draws its ring once it has a click handler.
An app-built control uses the standard recipe.
A row inside a scroller with overflow-hidden uses an inset ring.
Reference
ring-* widths are px in Tailwind v4 (ring-3 is 3px) and do not scale with --spacing.