Skip to content

No.83 · Controls

Fraction Checkbox

A select-all checkbox that tells the truth about partial states: its box fills in proportion to how many items are checked, and the count rolls beside it.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

The design brief behind this component — reuse it to regenerate, remix, or explain it.

Design a 'select all' checkbox that shows how partial the selection is. It's a real tri-state control (checked when all are, indeterminate when some are), but its 20px box is a tiny gauge: an accent fill rises from the bottom to exactly the fraction of children checked (520ms expo-out), with a faint meniscus line at the level; only at 100% does the ring turn accent and a tick draw in. Beside it: the group title and a mono count ('2 of 5') whose number rolls in on change. Children are ordinary checkboxes (hidden native input + drawn box): the box fills with the accent and the tick draws; the row's label brightens; an optional mono meta sits on the right. Everything is inside a fieldset with a legend. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Toggle individual items or the parent; the parent's fill tracks the fraction. Motion: Level 520ms expo-out; tick draws 320ms (the parent's after the fill arrives); count roll 320ms. Accessibility: Native checkboxes in a fieldset/legend; the parent sets .indeterminate for assistive tech and is described by the live count; focus-visible outlines the whole row. Reduced motion makes it instant. Responsive behavior: Fluid to 22rem. Touch: Whole rows are tap targets. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Toggle individual items or the parent; the parent's fill tracks the fraction.
Motion
Level 520ms expo-out; tick draws 320ms (the parent's after the fill arrives); count roll 320ms.
Accessibility
Native checkboxes in a fieldset/legend; the parent sets .indeterminate for assistive tech and is described by the live count; focus-visible outlines the whole row. Reduced motion makes it instant.
Responsive
Fluid to 22rem.
On touch
Whole rows are tap targets.