Skip to content

fix(core): align checkbox, radio, and switch control sizes - #4497

Merged
ernestt merged 4 commits into
mainfrom
feat/control-size-comparison-story
Jul 29, 2026
Merged

fix(core): align checkbox, radio, and switch control sizes#4497
ernestt merged 4 commits into
mainfrom
feat/control-size-comparison-story

Conversation

@cixzhang

@cixzhang cixzhang commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Aligns the sizing of the three selection controls — CheckboxInput, RadioList, and Switch — and adds a Storybook view for comparing them side by side.

Component changes (@astryxdesign/core):

  • Checkbox & Radio — the visible control now fills its size exactly (20px at sm, 24px at md) instead of being inset 2px inside the hit-target wrapper.
  • Switch — the sm track is narrowed to 32px wide (was 34px) with a 2px inset (was 3px). The sm thumb grows from 14px (off) to 16px (on).

Storybook:

  • New Core/Control Size Comparison view: All Sizes (all three grouped by size), plus Small and Medium single-row stories.

Why

The selection controls share a size API (sm / md) but their proportions were inconsistent — the checkbox/radio glyph was inset 2px inside its wrapper. This lands the intended, consistent sizes and gives a comparison view to keep them honest.

Before → after:

Control sm control md control
Checkbox 18px → 20px 22px → 24px
Radio 18px → 20px 22px → 24px
Switch 34×20 track, 3px inset, 12/16px thumb → 32×20 track, 2px inset, 14/16px thumb 40×24 track, 4px inset, 16/20px thumb (unchanged)

Testing

  • pnpm -F @astryxdesign/core unit tests for CheckboxInput, RadioList, and Switch pass.
  • Core build + typecheck:docs pass.
  • Prettier, sync, and changeset checks clean (patch changeset included).

Add a Storybook view that renders CheckboxInput, RadioList, and Switch
together at matching sizes, making it easy to observe the selection
controls side by side and spot size inconsistencies between them.
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 29, 2026 7:04pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 29, 2026
github-actions Bot added a commit that referenced this pull request Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

CheckboxInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 449 -
Complexity N/A Very High (45) -
RadioList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 521 -
Complexity N/A Very High (50) -
Switch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 437 -
Complexity N/A Very High (43) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

RadioList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/12 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Add an ExactSizes story that removes the 2px hit-target buffer so the
visible checkbox and radio controls hit exactly 20px (sm) and 24px (md),
with inner marks scaled to match.
Make the visible checkbox and radio controls fill their size exactly
(20px at sm, 24px at md) instead of being inset 2px inside the wrapper.

For Switch, use the same thumb size across both variants and narrow the
sm track to 32px wide.

Also remove the exact-size demo overrides from the control comparison
story now that the components render at the intended sizes.
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 29, 2026
@cixzhang cixzhang changed the title feat(storybook): add control size comparison story fix(core): align checkbox, radio, and switch control sizes Jul 29, 2026
github-actions Bot added a commit that referenced this pull request Jul 29, 2026
Grow the sm switch thumb from 14px (off) to 16px (on) and reduce the
track inset to 2px, recomputing thumb travel to keep the on-state gap
consistent.
@ernestt

ernestt commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Yes I think this is a good consistency change. Agreeing with the scaling of switch proportionally down to achieve "sm". Side question, if "sm" and "md" would conflict with the size tokens sm (28), md (32). and lg (36) values? Would xs and xxs make more sense since the sizings are going down in 4px increments already.

@ernestt
ernestt merged commit 08bb53c into main Jul 29, 2026
19 checks passed
@cixzhang

Copy link
Copy Markdown
Contributor Author

Yes I think this is a good consistency change. Agreeing with the scaling of switch proportionally down to achieve "sm". Side question, if "sm" and "md" would conflict with the size tokens sm (28), md (32). and lg (36) values? Would xs and xxs make more sense since the sizings are going down in 4px increments already.

At the moment controls don't align with sizes from inputs and this seems to be intentionally -- they're generally smaller. We were on the fence around having > 1 sizes for controls generally but IIRC we're at 2 sizes to conform with expectations from other systems and to support dense views alongside marketing views. I believe @rubyycheung explored larger sizes for controls but they ended up looking way too big.

For adding more sizes, I would probably suggest taking a more holistic view over all of icons, spinners, avatars, etc. All of these are slightly different and controls maybe feel closer in family to those than input sizes.

@github-actions
github-actions Bot deleted the feat/control-size-comparison-story branch July 30, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants