StartFoundationsComponentsContent

Checkbox

A checkbox turns one option on or off in a form. Group related checkboxes in tk-checkbox-group.

Stable Figma
OverviewUsageAPIAccessibility
Product updates Events and meetups Research invitations
<tk-checkbox-group label="Email notifications" helper="Select all that apply">
  <tk-checkbox name="topics" value="product" checked>Product updates</tk-checkbox>
  <tk-checkbox name="topics" value="events">Events and meetups</tk-checkbox>
  <tk-checkbox name="topics" value="research">Research invitations</tk-checkbox>
</tk-checkbox-group>

Anatomy

Part What it is
tk-checkbox one option and its own form control; one Tab stop
default slot the label, required; it is the accessible name and can hold a link
box 16px; shows a check or a minus when on
helper an optional hint under the label
error message an optional message under the label, on a single checkbox only
tk-checkbox-group the group; adds no Tab stop and submits nothing itself
group label the legend: the category or the question, required
group helper and error under the group label, above the options
group default slot the tk-checkbox items, stacked vertically

The whole row, box and label, is one click target.

States

Remember me Product updates All files Security alerts
<tk-checkbox>Remember me</tk-checkbox>
<tk-checkbox checked>Product updates</tk-checkbox>
<tk-checkbox indeterminate>All files</tk-checkbox>
<tk-checkbox disabled checked>Security alerts</tk-checkbox>

On hover, a checked box's fill changes; an unchecked box stays the same. Keyboard focus shows a ring around the box.

  • checked: the initial state. Clicking toggles it; read the live state from the checked property.
  • indeterminate: a parent whose children are partly selected. Set it from your code; a click clears it and toggles checked. The select-all logic is yours.
  • disabled: can't be focused or changed, and isn't submitted. Checked and unchecked disabled boxes differ only by a faint check mark, so if "on and locked" matters, say it in text. Prefer an active checkbox.

Required and error

On a single checkbox, required means it must be checked before the form submits, and adds an asterisk. error shows your message under it and a red border on an unchecked box.

I agree to the Terms of Service
<tk-checkbox name="terms" required error="Agree to the Terms of Service to continue">
  I agree to the <a href="/terms">Terms of Service</a>
</tk-checkbox>

The checkbox doesn't validate. You set error and clear it. In a group, set error on the group, not on the items.

Group

Design Code Research
<tk-checkbox-group label="Topics" required error="Select at least one topic">
  <tk-checkbox name="topics" value="design">Design</tk-checkbox>
  <tk-checkbox name="topics" value="code">Code</tk-checkbox>
  <tk-checkbox name="topics" value="research">Research</tk-checkbox>
</tk-checkbox-group>
  • label is required. label-hidden hides it on screen and keeps it for screen readers.
  • The group error sits above the options, so it stays in view on a long list. It doesn't color any box.
  • required only adds the asterisk. Check "at least one" yourself and show the result through error.
  • disabled disables every checkbox in the group.
  • Each checkbox submits its own name and value; the group has no value.