fin1te/dsv1.0.0
  1. ds
  2. Components
  3. Checkbox and switch

Checkbox and switch

Native checkboxes in the accent, and a switch.

Checkbox

Code
<label class="chk"><input type="checkbox" checked /> Show inspector panel</label>
<label class="chk"><input type="checkbox" checked /> Show legend</label>
<label class="chk"><input type="checkbox" /> Snap to grid</label>

Native checkboxes, coloured with accent-color. They stay fast, accessible and consistent with the platform.

Switch

Code
<label class="chk"><input class="switch" type="checkbox" role="switch" checked /> Animate links</label>
<label class="chk"><input class="switch" type="checkbox" role="switch" /> Camera mode</label>
<label class="chk"><input class="switch" type="checkbox" role="switch" disabled /> Unavailable</label>

Use a switch when the change applies immediately (a setting). Use a checkbox when the choice is submitted later or is one of several.

Toggle button

For a toggle inside a toolbar, use a button with aria-pressed.

API

ClassOnWhat it does
.chklabelInline label with a checkbox or switch.
.switchinput[type=checkbox]Draws a track and knob. Add role="switch".