Material Design Lite
Banner
Bottom sheet
Date picker
Expansion Panel
Image list
Grid list
Menu
Ripple
Select
Stepper
Sort header
Tree
View on Material.io

Preview

Installation

To import just the component styles, copy the following into your project’s styles.css file:

/* Core Styles */
@import url('https://kherrick.github.io/material-design-lite/css/core.css');
/* Material Icons */
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
/* Roboto Font */
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap');
/* Component Styles */
@import url('https://kherrick.github.io/material-design-lite/css/components/switch/style.css');

Usage

Start with a input element and add the switch class name:

<input class="switch" type="checkbox" />

Variants

Default

Default switch styling.

<input class="switch" type="checkbox" />

Icon Selected

Switch with icon selected styling.

<input class="switch icon-selected" type="checkbox" />

Icon Unselected

Switch with icon unselected styling.

<input class="switch icon-selected icon-unselected" type="checkbox" />

Design Tokens

TokenDescriptionDefault
--md-sys-comp-switch-thumb-sizeThe size of the thumb16px
--md-sys-comp-switch-track-widthThe width of the track52px
--md-sys-comp-switch-track-heightThe height of the track32px
--md-sys-comp-switch-border-widthThe width of the border2px

Resources

Playground

See the Pen Switch by Rody Davis (@kherrick ) on CodePen.