Checkbox and radio button switch

Github Page

The simple example demonstrates how to style checkbox and radio button elements to look like on/off switches.

Examples

An unstyled checkbox

A checkbox switch

A radio button switch

A pre-checked switch

A disabled switch

A switch set to XL size

A switch set to LG size

A switch set to MD size

A switch set to SM size (default)

A switch set to XS size


Code

Markup
<div class="switch">
  <input
    class="switch__control"
    type="checkbox"
    name="example01"
    id="example01">
  <label class="switch__label" for="example01">
    <span class="switch__content">Label content</span>
  </label>
</div>

Github Page