Switch
Also see /react/checkbox#switch-toggle
React component
Basic switch
A switch is an alternative styling for
<input type="checkbox">
<label class="bf-checkbox bf-switch-wrapper"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
<label class="bf-checkbox bf-switch-wrapper"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
Right-align
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-right"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-right"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
Button styling
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-button"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-button"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> Switch label </label>
Hidden label text
Wrap the label text in .bf-checkbox-text
and use .bf-checkbox-hidelabel
on the outer wrapper.
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-hidelabel"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> <span class="bf-checkbox-text">Switch label</span> </label>
<label class="bf-checkbox bf-switch-wrapper bf-checkbox-hidelabel"> <input type="checkbox" /> <span class="bf-switch"> <span class="bf-switch-thumb"> <i class="bf-checkbox-checked fa-solid fa-check"></i> </span> </span> <span class="bf-checkbox-text">Switch label</span> </label>