CSS Checkbox
Also see /react/checkbox
React component
Custom icons
Since it's practically impossible to style the native browser checkbox element, we have opted to replace it with custom icons instead.
The .bf-checkbox-unchecked icon will be hidden as long as the checkbox is
:checked (and vice versa for .bf-checkbox-checked).
We recommend
fa-solid fa-square-check
when checked, and
fa-regular fa-square
for the unchecked state.
<div class="bfl-inline"> <label class="bf-checkbox"> <input type="checkbox" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Checkbox left </label> <label class="bf-checkbox bf-checkbox-right"> <input type="checkbox" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Checkbox right </label> </div>
Button styling
<label class="bf-checkbox bf-checkbox-button"> <input type="checkbox" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Checkbox button styling </label> <label class="bf-checkbox bf-checkbox-button"> <input type="radio" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-circle-dot"></i> <i class="bf-checkbox-unchecked fa-regular fa-circle"></i> </span> Radio button styling </label>
Small button size
<label class="bf-checkbox bf-checkbox-button bf-checkbox-small"> <input type="checkbox" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Small button size </label>
Hidden label
- Apply
.bf-checkbox-hidelabelon the wrapper - Omit the text inside
<label> - Apply an
aria-labelto the<input>for accessibility
<label class="bf-checkbox bf-checkbox-hidelabel"> <input type="checkbox" aria-label="Checkbox label" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> </label>
Alert state
Use .bf-checkbox-alert on the wrapper to apply alert state styling.
<label class="bf-checkbox bf-checkbox-alert"> <input type="checkbox" /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Checkbox alert state </label>
Disabled
<label class="bf-checkbox"> <input type="checkbox" disabled /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Disabled </label> <label class="bf-checkbox"> <input type="checkbox" disabled checked /> <span class="bf-checkbox-icon"> <i class="bf-checkbox-checked fa-solid fa-square-check"></i> <i class="bf-checkbox-unchecked fa-regular fa-square"></i> </span> Disabled checked </label>