Skip to content
IndexRequest a UIAboutContact

Checkbox

A checkbox with a drawn tick, an indeterminate parent and a select-all pattern.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a checkbox group with a parent "Select all" and three children (Email, SMS, Push). Each checkbox is a real input type="checkbox" hidden visually, with a custom 22px box (6px radius, 1.5px border) and an SVG tick drawn with stroke-dasharray 24. When checked the box fills with the accent colour and the tick animates stroke-dashoffset from 24 to 0 over 220ms ease-out. The parent shows an indeterminate dash (set input.indeterminate = true) when only some children are checked, and checking the parent checks or clears all children. Rows are at least 44px tall and the whole label is clickable. Include hover tone, a 2px focus-visible ring and a disabled child. Under prefers-reduced-motion show the tick without animation.

About this pattern

Definition

A square control that lets a person choose zero or more options from a set. The tick draws itself on check. A parent checkbox can show an indeterminate state when only some children are checked.

Purpose & UX principles

  • Use checkboxes for independent choices that are confirmed later; use a switch for settings that apply instantly.
  • Indeterminate shows partial selection and lets one control select or clear the whole group.
  • The clickable area includes the label text, not just the 20px box.

Interaction states

  • Unchecked, checked, indeterminate, hover, focus-visible, disabled.
  • Parent checkbox reflects the children and toggles them all when activated.

Motion specification

  • Box fill: 140ms.
  • Tick: stroke-dashoffset from 24 to 0 in 220ms ease-out.
  • Reduced motion: tick appears without drawing.

Responsive behaviour

  • Visual box 22px inside a row at least 44px tall so the whole row is a comfortable touch target.

Code

HTML
<fieldset class="g"><legend>Notify me by</legend>
  <label class="c"><input type="checkbox" id="all"><i><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i><span>Select all</span></label>
  <label class="c"><input type="checkbox" class="ch" checked><i><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i><span>Email</span></label>
  <label class="c"><input type="checkbox" class="ch"><i><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i><span>SMS</span></label>
  <label class="c"><input type="checkbox" class="ch"><i><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i><span>Push</span></label>
  <label class="c off"><input type="checkbox" disabled><i><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i><span>Carrier pigeon</span></label>
</fieldset>

Related patterns

Radio Button

↗
Radio ButtonInputs & Forms

Toggle Switch

↗
Toggle SwitchInputs & Forms

Validation States

↗
Validation StatesInputs & Forms