Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Foundation Switch

Foundation Switch

A switch toggles between the "On" and "Off" states when clicked with the mouse (tapped with a finger):

To toggle a switch, use

.
add a with a unique id inside , element's for attribute needs to match the id of :

Example

<

div

class=

"switch"

<

input

id=

"mySwitch"

type=

"checkbox"

<

label

for=

"mySwitch"

<

/label

<

/div

Try it »


Switch size

Use .large, .small or .tiny class to set the switch size:

Example

<

div

class=

"switch large"

...

<

/div

<

div

class=

"switch"

...

<

/div

<

div

class=

"switch small"

...

<

/div

<

div

class=

"switch tiny"

...

<

/div

Try it »


Rounded toggle switch

Use .radius and .round class to set a rounded toggle switch:

Example

<

div

class=

"switch"

...

<

/div

<

div

class=

"switch radius"

...

<

/div

<

div

class=

"switch round"

...

<

/div

Try it »


Switch group

You can set up a single option by using radio buttons (radio).Note: Note that each option's name attribute must be consistent (in the example it is "myGroup").

Example

<

div

class=

"switch"

<

input

id=

"mySwitch1"

type=

"radio"

name=

"myGroup"

<

label

for=

"mySwitch1"

<

/label

<

/div

<

div

class=

"switch"

<

input

id=

"mySwitch2"

type=

"radio"

name=

"myGroup"

checked

<

label

for=

"mySwitch2"

<

/label

<

/div

Try it »