Checkbox

Tick an option. Optional, it lights up white; required, green.

Resources

Subscribe to the newsletter

Topics (optional)

Optional boxes light up white; required, green.

Frames
0
Active effects
0
Renderer
none

When to use it

  • For an independent option (newsletter), or a required agreement with required (terms and conditions).
  • Not for an exclusive choice: use radio buttons. Not for a setting that applies at once: use a switch (switch variant, coming soon).

Recommendations

  • indeterminate for a partly ticked "select all" box.
  • To match the ticked color to your brand, use --sui-color-checked, without green, coral or violet: they are reserved for meaning.

Accessibility

The library

  • Native <input type="checkbox"> element: label click, space, indeterminate, screen readers.
  • Ticked, the box is filled: a shape, not just a color, with 3:1 contrast.
  • Click area of at least 24 px (44 px on mobile).
  • High contrast: back to the system's native control.

Integration

  • A tied label.
  • A group of boxes in a <fieldset> with a <legend>. On error: aria-invalid on the <fieldset> and an error text, since a group has no native validation.

WCAG 2.2 criteria: Use of Color · Non-text Contrast · Target Size (Minimum) · Error Identification

Props

PropTypePurpose
requiredbooleanRequired: ticked, it lights up green; unticked on submit, it pulses coral.
aria-invalidbooleanError set by your validation. On a <fieldset>: coral line under the legend.
effects, onEffectEnd, refSame as the input.

Spec

The normative spec for this component: Formulaire

Availability and resources

Status
available · open source
Packages
@shader-ui/react (React, Next.js)
@shader-ui/core (TypeScript, plain HTML)
Source code
choice.ts (core) · Choice.tsx (React)