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>
<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>
<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>
<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-hidelabel
on the wrapper - Omit the text inside
<label>
- Apply an
aria-label
to 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>
<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>
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>
<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>