Skip to content

feat(theme): align the switch recipes with the Open Components Switch page - #372

Merged
alexgrozav merged 2 commits into
align-component-styles-uxf-487from
align-switch-recipes-uxf-500
Oct 29, 2026
Merged

alexgrozav merged 2 commits into
align-component-styles-uxf-487from
align-switch-recipes-uxf-500

Conversation

@alexgrozav

Copy link
Copy Markdown
Contributor

Description

Brings useSwitchRecipe and useSwitchFieldRecipe in line with the stylesheet rules on the Open Components Switch page, without renaming or removing any recipe, axis, value or default.

  • Contrast. Each off track keeps 3:1 against the page in light and dark mode, and its knob 3:1 against the track: neutral is gray-450 in both modes, light is a gray-200 track with a gray-500 border and a gray-600 knob, and dark gets a gray-450 border. switchContrast.test.ts checks every color, on and off, in both themes, plus the focus ring and the error border.
  • Focus. The ring is @color.focus, 2px solid with a 2px offset, in every state.
  • States. Invalid comes from aria-invalid="true" (an error border doubled by a 1px inset shadow), read-only from aria-readonly="true" (a dashed border that shows against the page), and disabled from :disabled. None of them changes the switch's size.
  • Size and direction. Track and knob sizes are in rem, with the same pixel values at 16px. The knob is now a radial-gradient() background, so it takes color tokens, and it starts at the inline start, so it mirrors in right-to-left layouts. The wrapper label is at least 24px tall, and 44px on touch screens, which gives the switch its hit area.
  • Media. The knob jumps rather than slides with prefers-reduced-motion. In forced colors mode the field opts out with forced-color-adjust: none and draws every state in system colors. With prefers-contrast: more, the off border takes the text color.
  • Storybook and docs. New ReadOnly, ReadOnlyChecked, Invalid and Focus stories, read-only and invalid rows in AllStates, and an updated Switch page with an Accessibility section.

Related issue

Part of the work to align the component recipes 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 build, lint (217 warnings, as on the base), typecheck and every package's tests pass, apart from apps/playground/test/theme.test.ts: its 8 tests fail on localStorage.clear on the base branch too.
  • This PR targets the integration branch for the component alignment work, not main.
  • Every Should rule in scope is met, so none is declined. The switch has no hover style of its own, so switch/hover-capable holds with nothing behind the modifier.
  • Visual changes for consumers: the neutral off track is a mid gray in both modes instead of gray-300 / gray-700, the light knob is gray while off, and the wrapper label grows to a 24px minimum height.

… page

Each off track now keeps 3:1 against the page in both themes, with a knob
at 3:1 against it, and the focus ring is color.focus. The field takes its
invalid and read-only looks from aria-invalid and aria-readonly, sizes in
rem, mirrors its knob in right-to-left layouts and stops sliding with
reduced motion. The wrapper label gives a 24px hit area, 44px on touch
screens. Forced colors and more contrast draw the switch in system and
full-strength colors.
@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 3:20pm UTC
styleframe-dev-storybook Ready Ready Preview Oct 29, 2026 3:20pm UTC

Request Review

@alexgrozav
alexgrozav merged commit b2f39a6 into align-component-styles-uxf-487 Oct 29, 2026
3 checks passed
@alexgrozav
alexgrozav deleted the align-switch-recipes-uxf-500 branch October 29, 2026 18:54

This branch was successfully deployed

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