fix(core): align checkbox, radio, and switch control sizes - #4497
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsCheckboxInput · View in Storybook
RadioList · View in Storybook
Switch · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. RadioList - 1 issue(s)
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.
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.
|
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. |
What
Aligns the sizing of the three selection controls —
CheckboxInput,RadioList, andSwitch— and adds a Storybook view for comparing them side by side.Component changes (
@astryxdesign/core):sm, 24px atmd) instead of being inset 2px inside the hit-target wrapper.smtrack is narrowed to 32px wide (was 34px) with a 2px inset (was 3px). Thesmthumb grows from 14px (off) to 16px (on).Storybook:
Why
The selection controls share a
sizeAPI (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:
Testing
pnpm -F @astryxdesign/coreunit tests for CheckboxInput, RadioList, and Switch pass.typecheck:docspass.