Skip to main content

Checkbox

One or many independent on or off choices, usually sent with a form.

In Content first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Content first: Picking topics, where many may be true and the choice waits for the form. Not for a setting that applies at once.

  • Use it when: Agreeing, picking many, optional extras; the choice waits for the form.
  • Not when: Exactly one of a short set (radio group), or a setting that applies at once (switch).

Instead:

Words​

  • Write to one person: "you", not "users".
  • Short sentences with room to breathe.
  • Explain why before asking for anything.
  • Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Not now
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Browse guides

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedSpace checks and unchecks.undefined

Test before you ship:

  • Each checkbox has a visible label that is part of the hit area. undefined

Use it in code​

npx open-ds add checkbox

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Checkbox reads 11 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Checkbox's tokens to change Checkbox alone.

Changes with theme

Content first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Shared
Button focus ring
Changes with theme
on focus
component.button.focus-ringcolor.border.focusvar(--button-focus-ring)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Input background
Changes with theme
component.input.backgroundcolor.surface.defaultvar(--input-background)Lightstone.light.0:#FFFFFFDarkstone.dark.50:#1F1B16
Control checked
Changes with theme
when on
component.control.checkedcolor.action.primaryvar(--control-checked)Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4
Control track
Changes with theme
component.control.trackcolor.border.strongvar(--control-track)Lightstone.light.500:#7A7062Darkstone.dark.400:#A39A8B
Control thumb
Changes with theme
when on
component.control.thumbcolor.surface.defaultvar(--control-thumb)Lightstone.light.0:#FFFFFFDarkstone.dark.50:#1F1B16
Control radiuscomponent.control.radiusradius.badgevar(--control-radius)radius.999:9999px
Checkbox
Sizecomponent.checkbox.sizesize.iconvar(--checkbox-size)size.16:1rem
Border widthcomponent.checkbox.border-widthborder-width.defaultvar(--checkbox-border-width)border-width.1:1px
Focus
on focus
component.checkbox.focusborder-width.focusvar(--checkbox-focus)border-width.2:2px
Disabled
when disabled
component.checkbox.disabledopacity.disabledvar(--checkbox-disabled)opacity.40:0.4
Canvas
Changes with theme
on focus
component.checkbox.canvascolor.surface.canvasvar(--checkbox-canvas)Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D