Skip to content

fix(theme): align the button recipe with Open Components - #374

Merged
alexgrozav merged 4 commits into
align-component-styles-uxf-487from
align-button-uxf-492
Oct 29, 2026
Merged

alexgrozav merged 4 commits into
align-component-styles-uxf-487from
align-button-uxf-492

Conversation

@alexgrozav

@alexgrozav alexgrozav commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Brings useButtonRecipe in line with the stylesheet rules of the Open Components Button page, without renaming or removing any color, variant, size, default or export.

  • Contrast. Every label keeps 4.5:1 at rest, on hover, when active, pressed and expanded, in both themes. solid hovers darken (shade) instead of lightening, warning takes a dark label, and the transparent variants use lighter levels in the dark theme. Every border keeps 3:1 against the page, so subtle, neutral and warning borders change level. A new buttonContrast.test.ts checks all 540 label cases and 54 borders from the token values, plus the focus ring at 3:1. Hover blocks set the label color, so an <a href> button keeps it over the global a:hover on hover-capable devices.
  • Focus. The ring is @color.focus, 2px solid with a 2px offset. The &:focus blocks that copied the hover background are gone.
  • Target size and resizing. Each size sets min-height and min-width through spacing multipliers (24px at xs), labels can wrap (white-space: nowrap removed), and &:any-pointer-coarse:before grows the hit area to 44 × 44px.
  • States. aria-disabled mirrors :disabled, aria-pressed and aria-expanded mirror :active, and data-loading keeps the size, keeps a disabled loading button at full opacity and centers a .spinner child over the hidden content. Disabled buttons no longer set pointer-events: none: they keep their cursor, clicks don't fall through, and trailing compound variants put their resting colors back, so hover and press change nothing.
  • Hover, forced colors, more contrast, RTL. Every hover is &:hover-capable:hover. In forced colors the ring is Highlight, disabled and loading are GrayText, pressed and expanded are Highlight/HighlightText (a disabled toggle keeps the background), and link gets a border. outline and subtle borders become currentColor with prefers-contrast: more. Horizontal padding is padding-inline.
  • Link. Underlined at rest, thicker underline on hover.
  • Storybook gains Focus, Pressed, Expanded and Loading stories. The docs page's Accessibility section is rewritten.

Related issue

Part of the integration stack that aligns component styles with Open Components.

Type of change

  • 🐞 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📖 Documentation
  • ♻️ Refactor / internal (no functional change)
  • 🔧 Build / tooling / CI

Checklist

  • My commits follow Conventional Commits with a package scope (e.g. feat(theme): …)
  • I ran pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm test and everything passes
  • I added a changeset (pnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/tests
  • I added or updated tests where relevant
  • I updated documentation where relevant
  • I did not edit generated files (dist/, .styleframe/)
  • My PR targets main and stays focused in scope

Notes / screenshots

  • The gate ran: build, lint, format check, typecheck pass. pnpm test passes except 8 @styleframe/playground tests in test/theme.test.ts (localStorage is undefined), which fail the same way on the base branch.
  • This PR targets the integration branch, not main, so it gets no CI of its own.
  • light and dark colors. They keep one look in both themes, so a transparent variant (outline, ghost, link) with a fixed label can't reach 4.5:1 on both a light and a dark page. The recipe treats light as a color for dark surfaces and dark as one for light surfaces, the contrast test checks them there, and the docs and the variants story say so. Their link hovers, which turned the label white on light surfaces and dark on dark ones, now keep it readable.
  • Rule order. Setup selectors are emitted before recipe utilities, so the forced colors rules use :root .button.button.button.button selectors (0,6,0) that outrank every state class and disabled reset. The more-contrast borders and the disabled resets are trailing compound variants, so their rules follow every rule they override; a test checks that order in the emitted CSS.
  • A tapped <a href> button on a touch screen can still take the global a:hover color, because the link element's a:hover isn't inside @media (hover: hover) and this recipe may not add a bare &:hover.

Meet the Open Components Button page's stylesheet rules in
useButtonRecipe: label contrast in every state and theme, a color.focus
ring, an underlined link variant, min-height sizing with wrapping labels,
logical inline padding, a 44px touch hit area, hover only on devices that
can hover, and disabled, pressed and loading styled from their
attributes, with forced colors and more contrast handling.

Add the recipe's tests, a contrast test, focus, pressed and loading
stories, and an Accessibility section on the docs page.
Style aria-expanded like pressed, give each size a min-width matching its min-height, color and size the loading spinner from the button, and let the forced colors disabled rule outrank the dark theme's pressed rules.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
styleframe-dev Ready Ready Preview Oct 29, 2026 7:00pm UTC
styleframe-dev-storybook Ready Ready Preview Oct 29, 2026 7:00pm UTC

Request Review

Drop pointer-events: none from the disabled states, and put each
button's resting colors back while it's disabled through trailing
compound variants, so hover and press change nothing. Keep the pressed
background on a disabled toggle in forced colors and turn loading
buttons GrayText, as the reference CSS does.

Give every border 3:1 against the page, set the label color in every
hover block so an <a href> button keeps it over the global a:hover
styles, and test the borders and the rule order.
The active modifier also emits &:focus:active, which outranked the
disabled resets on a focused aria-disabled button, so add resets under
&:aria-disabled:active in both themes. Raise the forced colors rules to
(0,6,0) so they still outrank those resets, and correct the docs and
changeset sentences that overstated the hover, border and disabled
behaviour.
@alexgrozav
alexgrozav merged commit bdc21fd into align-component-styles-uxf-487 Oct 29, 2026
3 checks passed
@alexgrozav
alexgrozav deleted the align-button-uxf-492 branch October 29, 2026 19:25

This branch was successfully deployed

2 active deployments
Preview – styleframe-dev — 7e934267 Deployed Oct 29, 2026 by vercel[bot]
Preview – styleframe-dev-storybook — 7e934267 Deployed Oct 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.

1 participant