Switch
An on/off toggle for a setting that takes effect immediately.
How to use it
Copy any example below and paste it in- Markup
.switchlabel,sr-onlycheckbox,.switch-track, then the visible text.- Switch or checkbox
- A switch applies at once; a checkbox is a choice you later submit. Do not put switches in a form with a Save button.
- RTL
- The knob travels the other way automatically.
Settings list
<div class="flex flex-col gap-4">
<label class="switch">
<input type="checkbox" checked>
<span class="switch-track" aria-hidden="true"></span>
<span>Require two-factor authentication</span>
</label>
<label class="switch">
<input type="checkbox">
<span class="switch-track" aria-hidden="true"></span>
<span>Show the weekly digest in the sidebar</span>
</label>
<label class="switch">
<input type="checkbox" checked>
<span class="switch-track" aria-hidden="true"></span>
<span>Collapse the sidebar on small screens</span>
</label>
</div>