Skip to content

feat(theme): add the focus colour and accessibility modifiers - #365

Merged
alexgrozav merged 2 commits into
align-component-styles-uxf-487from
focus-modifiers-uxf-491
Oct 29, 2026
Merged

alexgrozav merged 2 commits into
align-component-styles-uxf-487from
focus-modifiers-uxf-491

Conversation

@alexgrozav

@alexgrozav alexgrozav commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the shared pieces the component recipes need to meet the Open Components accessibility guidelines, so each component change can stay inside its own recipe folder.

  • color.focus: a reference to @color.primary in the light and dark themes, emitted as --color--focus: var(--color--primary). The focus.outline-color default now points at it, so focus rings look the same as before. Without a color.focus variable, the default falls back to @color.primary. Reference colours get no level, shade or tint keys in the useDesignTokensPreset return type, which matches what the preset generates.
  • Five modifiers, each with its own composable and registered through useModifiersPreset:
    • hover-capable: @media (hover: hover)
    • any-pointer-coarse: @media (any-pointer: coarse)
    • aria-invalid: &[aria-invalid="true"]
    • readonly-attr: &[readonly]. The existing readonly and read-only modifiers still emit :read-only.
    • data-loading: &[data-loading]
  • position-try-fallbacks utility, beside position-area, registered in useUtilitiesPreset without defaults. Custom @position-try rules stay on atRule.
  • Docs: the design-token preset's colour list now matches colorValues, the modifier pages and the layout utilities page cover the additions, and the focus state page shows the new default.

A test compiles a recipe with &:hover-capable:hover and &:dark:hover-capable:hover and checks the nested CSS.

Related issue

None on GitHub.

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 PR targets the integration branch for the accessibility alignment, not main, so CI runs on the integration PR.
  • pnpm build:nodocs, pnpm lint, pnpm typecheck and pnpm format:check pass. pnpm test passes in every package except @styleframe/playground, whose test/theme.test.ts fails the same 8 tests on the base branch (localStorage is undefined under Node 26), so it isn't from this change.
  • When a project replaces the default colours and defines no focus colour, the focus.outline-color default falls back to @color.primary, so those configurations keep building as before.

Components need one colour for every focus ring, and state hooks the
Open Components pages style from: hover only where a pointer can hover,
larger hit areas for coarse pointers, and the aria-invalid, readonly
and data-loading attributes.

color.focus is a reference to color.primary in the light and dark
themes, and the focus.outline-color default points at it, so focus
rings look the same. Reference colours get no level, shade or tint
keys in the preset's return type, matching what it generates. The new
modifiers are hover-capable, any-pointer-coarse, aria-invalid,
readonly-attr and data-loading; readonly and read-only still emit
:read-only. The position-try-fallbacks utility sits beside
position-area and ships without defaults.
@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 8:54am UTC
styleframe-dev-storybook Ready Ready Preview Oct 29, 2026 8:54am UTC

Request Review

A project that replaces the default colours and defines no focus colour threw on the new @color.focus default, so useFocusState now references @color.primary there, as it did before. The colour docs now say the focus token colours the global focus ring, and that colors and themes.dark.colors each set one theme.
@alexgrozav
alexgrozav merged commit 12ff89d into align-component-styles-uxf-487 Oct 29, 2026
3 checks passed
@alexgrozav
alexgrozav deleted the focus-modifiers-uxf-491 branch October 29, 2026 09:17

This branch was successfully deployed

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