Skip to content

Checkbox, radio and switch

Checkboxes and radios with custom marks, and role="switch" to turn a checkbox into a switch.

Put the input inside its label. The label lines up with the box and the whole label is clickable.

Notifications
Plan

Switch

role="switch" on a checkbox draws a switch. Screen readers announce it as on or off.

Colors

Checked boxes, radios and switches use the primary color. A color class on the input changes it.

Indeterminate

A checkbox for a partly selected list shows a dash. Set indeterminate from a script, since there is no attribute for it.

document.getElementById("select-all").indeterminate = true;

Disabled

Variables

VariableDefault
--i-checkbox-radio-border-width0.125rem
--i-switch-border-width0.1875rem
--i-switch-thumb-shadow0 0 0 #0000
--i-switch-color-backgroundlight-dark(#8790a3, #5f6880)
--i-switch-color-thumbvar(--i-color-white)