Skip to content

fix(focus): no outline on text fields, a muted keyboard ring, keycaps that fit filled buttons - #37

Merged
uzayer merged 3 commits into
mainfrom
uzayermasud/focus-ring-kbd
Nov 11, 2026
Merged

uzayer merged 3 commits into
mainfrom
uzayermasud/focus-ring-kbd

Conversation

@uzayer

@uzayer uzayer commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Two visual bugs, both seen in Atlas desktop.

Text fields drew a thick white outline

:focus-visible matches a text field on every focus, mouse and autoFocus included, so the global 2px ring (pure white in Atlas dark) drew around every Input, Textarea and InputGroup on click.

The rule now (decision 31, in utilities.css):

  • A text field draws no outline. input (text types), textarea, [contenteditable] and [role=textbox] are excluded from the global rule. Input, Textarea, InputGroup, ComboboxChips and the DataTable search lift their border to --ring on focus instead. That border clears 3:1 against the field's fill, where border-strong was about 1.8:1.
  • Everything else gets one keyboard ring: 2px solid --ring, offset 2px (was 1px). The gap is the surface colour, so the ring's contrast is measured against the surface, and it never runs into a filled control's edge.

A muted ring in the Atlas themes

theme was now on background on popover on a pressed popover row
atlas dark #ffffff #808080 5.32 4.32 3.43
atlas light #000000 #757575 4.61 4.04 3.39
atlas-mono dark #ffff00 #8f8f00 6.10 4.00 3.30
chyral dark #c9a35a #9f8047 5.45 4.63 3.80
phosphor dark #ff9500 #c27100 5.47 4.84 4.17

sidebar-ring follows. The light variants of atlas-mono, chyral and phosphor (#8a7500, #8a6a1f, #a85f00) were already muted and pass at least 3.3:1 on the same surfaces, so they are unchanged. Ported third-party themes keep their own ring.

Keycaps in filled buttons

A plain Kbd inside a default or destructive Button now draws in the button's text colour (border-current/25 bg-current/10 text-current), so it no longer reads as a hole in the fill. secondary, outline, ghost and link variants keep the plain cap. There is a new WithKeycaps story showing every variant.

Tests

  • New play tests: Button/KeyboardFocus checks the 2px ring with a 2px offset. Textarea/Clicked and InputGroup's Autofocused/Clicked check for no outline and a ring-coloured border.
  • bun run typecheck, bun run test (652), bun run test:storybook (856, axe colour-contrast included) and bun run format:check all pass.

Browsers match :focus-visible on a text field however it was focused, so
every click into an Input, Textarea or InputGroup drew the 2px ring. Text
inputs, textareas, contenteditable and role=textbox are now excluded from
the global rule, and a field shows focus with its border in the ring's
colour. Everything else keeps the keyboard ring: 2px of --ring, now offset
2px so it is measured against the surface and never touches a filled
control's edge.
The ring was the ink (white, black) or the full accent. It is now a muted
tone that clears 3:1 on every surface, including a pressed popover row:
atlas #808080 / #757575, atlas-mono dark #8f8f00, chyral dark #9f8047,
phosphor dark #c27100. The light variants of atlas-mono, chyral and
phosphor were already muted and are unchanged. Ported themes keep their
own ring.
A plain keycap is a card-coloured box in a muted ink, which on a white
primary or a red destructive button read as a hole. Inside those two
variants a Kbd now draws in the button's text colour, thinned for its fill
and edge. Other variants keep the plain cap. New story: WithKeycaps.
@uzayer
uzayer merged commit 06f7f69 into main Nov 11, 2026
1 check passed
@uzayer
uzayer deleted the uzayermasud/focus-ring-kbd branch November 11, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant