Skip to content

Focus rings: 1px, with a 1px offset on filled buttons (2.6.1) - #130

Merged
DerekAgility merged 1 commit into
mainfrom
dlo/focus-ring-1px-no-offset
Sep 29, 2026
Merged

DerekAgility merged 1 commit into
mainfrom
dlo/focus-ring-1px-no-offset

Conversation

@DerekAgility

Copy link
Copy Markdown
Contributor

Thins the keyboard focus rings from 2.6.0. Version bumped to 2.6.1.

What changes

The focus ring on buttons and other non-text controls was ring-2 ring-offset-2: a 2px ring with a 2px white gap, which read as a thick double outline. It is now 1px. Rings still show for keyboard focus (focus-visible) only, never on mouse click.

Control Before After
Outlined Button (secondary, alternative, danger-secondary), Checkbox, Radio, ToggleSwitch, Badge 2px ring + 2px offset 1px ring on the edge, no offset
Filled Button (primary, danger, warning), Capsule primary / danger, primary ButtonDropdown trigger 2px ring + 2px offset 1px ring + 1px white offset

Applies to both Button variants (<button> and asLink) and both halves of ButtonDropdown.

Why filled buttons keep an offset: without a gap, a purple or red ring against a fill of the same colour is invisible, which would fail WCAG 2.4.7. We also tried an inset white ring, but the offset looked better and doesn't need a transparent border that narrows the label area.

Text inputs and select triggers are unchanged: they already focus with a single 1px violet-700 border.

For review

  • Warning: the 1px yellow-500 ring is faint against a white page (about 1.6:1 contrast). This isn't new with this change, but it's more noticeable at 1px. A darker ring colour would fix it if we want to.
  • ButtonDropdown: each half's ring overlaps the divider or the other half on the joining edge.

Testing

  • Measured in headless Chrome with focus-visible focus. Filled buttons render a 1px white offset plus a 1px ring, outlined controls a single 1px ring, and buttons stay 36px tall.
  • Tests updated. A new guard fails if any ring or ring offset is wider than 1px. Other checks cover the offset on filled buttons and no offset on outlined ones.
  • yarn test: 109 passed. tsc --noEmit: clean. yarn build: clean.
  • The Form Control States story text has been updated.

🤖 Generated with Claude Code

Keyboard focus rings on Button, both ButtonDropdown halves, Capsule,
ToggleSwitch, Checkbox, Radio and Badge were 2px with a 2px white offset.
They are now 1px, still focus-visible only.

Outlined controls put the 1px ring directly on the edge with no offset.
Filled buttons (Button primary/danger/warning, Capsule primary/danger, the
primary ButtonDropdown trigger) keep a 1px white offset, because a ring in
the fill's own colour with no gap is invisible.

Bumps the version to 2.6.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
plenum-ui Ready Ready Preview Sep 29, 2026 1:14pm UTC

Request Review

@5PK 5PK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DerekAgility
DerekAgility merged commit 437d3e3 into main Sep 29, 2026
4 checks passed
@DerekAgility
DerekAgility deleted the dlo/focus-ring-1px-no-offset branch September 29, 2026 13:36

This branch was successfully deployed

1 active deployment
Preview — efa95297 Deployed Sep 29, 2026 by vercel[bot]
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.

2 participants