Skip to content

fix(theme): align the checkbox recipes with Open Components - #375

Merged
alexgrozav merged 2 commits into
align-component-styles-uxf-487from
checkbox-styles-uxf-494
Oct 29, 2026
Merged

alexgrozav merged 2 commits into
align-component-styles-uxf-487from
checkbox-styles-uxf-494

Conversation

@alexgrozav

Copy link
Copy Markdown
Contributor

Description

Brings useCheckboxRecipe and useCheckboxFieldRecipe in line with the stylesheet rules of the Open Components Checkbox page, so a checkbox built on them is easy to see, press and read in every state and setting.

  • Contrast. The unchecked border is @color.gray-450 on light surfaces and @color.gray-500 on dark ones (was gray-300 and gray-600, about 1.5:1), so it has 3:1 against the page in both themes. checkboxContrast.test.ts checks the border, fill, mark, invalid border, label and focus ring for every color in both themes.
  • Focus. The ring is a 2px solid outline in @color.focus, 2px outside the box.
  • Size and layout. The box is sized in rem (same values at 16px). The wrapper draws a 1.5rem hit area around the box with &:before, placed with inset-inline-start, and pads each label to that height. The box sits beside the label's first line, so a long label wraps beside it, in either direction.
  • States. Read-only comes from [aria-readonly="true"] (dashed border, default cursor) and invalid from [aria-invalid="true"] (@color.error border plus a second inset pixel), never from :read-only or :invalid. No state changes the box's size.
  • Adaptive. contrast-more draws the border at full strength. In forced colors mode a checked box is filled with Highlight, its mark gets a dark outline so it shows on any highlight colour, the ring is Highlight, and disabled shows GrayText instead of an opacity.
  • Disabled look. A disabled box inside the wrapper no longer dims twice (the box was at 25% opacity).

Storybook gains read-only, invalid, focus and long-label stories, and the docs page's Accessibility section describes all of the above. No variant name, value, default or export changes.

Related issue

None.

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 (all pass except 8 @styleframe/playground tests in test/theme.test.ts, which fail the same way on the base branch: localStorage is undefined under the local Node version)
  • 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 (it targets the align-component-styles-uxf-487 integration branch, and stays focused in scope)

Notes / screenshots

Two recommended looks from the page are met differently, without breaking a rule:

  • Read-only checked keeps the @color.primary fill and white mark inside a dashed border, rather than dropping the fill and drawing the check in the text colour. The mark is a white SVG background image, so a text-coloured check would need a second hardcoded colour per theme. The dashed border tells it apart, in forced colors mode too.
  • Hover. The recipes have no hover styles, which meets checkbox/hover-capable as it stands.

The label's height comes from padding-block: max(0px, …) rather than min-height, so the label's first line and the box share one 1.5rem band at every size.

The checkbox and checkbox-field recipes now meet the stylesheet rules
of the Open Components Checkbox page. The focus ring uses color.focus,
and the unchecked border moves to gray-450 and gray-500, so it has 3:1
against the page in both themes.

The box is sized in rem, the wrapper draws a 1.5rem hit area around it
and pads each label to that height, and a wrapping label keeps the box
beside its first line in either direction. Read-only and invalid come
from aria-readonly and aria-invalid, never :read-only or :invalid.
More contrast draws the border at full strength, and forced colors
mode marks checked, focus and disabled with system colours. A disabled
box inside the wrapper no longer dims twice.
@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 4:17pm UTC
styleframe-dev-storybook Ready Ready Preview Oct 29, 2026 4:17pm UTC

Request Review

Assert every forced-colors block of the checkbox field exactly, the
neutral dark re-assertions included, and pin the checked and
indeterminate marks to their own paths, so swapping a mark or dropping
a re-assertion fails. Assert each size's hit-area position.

Re-assert the invalid border on checked and indeterminate boxes instead
of relying on emission order, take the dashed read-only border from the
border-style token, and match the double-dim reset to the label's
descendant selector. The docs show the alignment the recipe emits and
say which states need wiring.
@alexgrozav
alexgrozav merged commit 3521fa4 into align-component-styles-uxf-487 Oct 29, 2026
3 checks passed
@alexgrozav
alexgrozav deleted the checkbox-styles-uxf-494 branch October 29, 2026 18:19

This branch was successfully deployed

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