Forms
Checks & radios
Gold checkboxes, radios, switches and toggle buttons — with a navy check mark and no script.
How it works in this theme
Bootstrap's .form-check replaces the browser's checkbox and radio with a 1 em box drawn in CSS.
The theme sets:
- Unchecked:
cream-50box, 1 pxnavy-400(#4a6398) border, 2 px radius for checkboxes, round for radios. - Checked:
primarygold fill and border —gold-700in light mode,gold-500in dark mode — with anavy-900check mark or dot. - Focus: the same gold ring as every other control.
- Switches: a 2 em pill with a
navy-300knob; checked, the knob turns white on gold. - Toggle buttons:
.btn-check+label.btn. The theme removes the label's bottom margin so toggles sit level with ordinary buttons.
All of it is CSS on native inputs. There is nothing to initialise.
Approach
Browser default checkboxes and radios are replaced with the help of .form-check, a series of
classes for both input types that improves the layout and behaviour of their HTML elements. Checkboxes are
for selecting one or several options in a list, while radios are for selecting one option from many.
Structurally, the <input> and <label> are siblings, as opposed to an
<input> within a <label>. This is slightly more verbose, but the
sibling selector is what lets CSS style the label from the input's state (:checked,
:disabled, :user-invalid).
Checks
HTML
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-default" />
<label class="form-check-label" for="checks-default">Default checkbox</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-checked" checked />
<label class="form-check-label" for="checks-checked">Checked checkbox</label>
</div>Indeterminate
Checkboxes can use the :indeterminate pseudo-class. The theme styles it: a gold box with a
horizontal dash. But there is no HTML attribute for it — indeterminate is a
DOM property that only a script can set. Without JavaScript, a checkbox is never indeterminate, so this
page cannot show one live. The CSS is still emitted for applications that do run a script.
.form-check-input[type=checkbox]:indeterminate {
background-color: #b8941f; /* gold-700; gold-500 in dark mode */
border-color: #b8941f;
--bs-form-check-bg-image: url("…stroke='%23fff'…d='M6 10h8'…");
}
Disabled
Add the disabled attribute and the associated <label>s are automatically
styled to match with a lighter colour (opacity: .5) to help indicate the input's state.
HTML
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-disabled" disabled />
<label class="form-check-label" for="checks-disabled">Disabled checkbox</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-disabled-checked" checked disabled />
<label class="form-check-label" for="checks-disabled-checked">Disabled checked checkbox</label>
</div>Radios
HTML
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-radio-default" id="checks-radio-1" />
<label class="form-check-label" for="checks-radio-1">Default radio</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-radio-default" id="checks-radio-2" checked />
<label class="form-check-label" for="checks-radio-2">Default checked radio</label>
</div>Disabled
HTML
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-radio-disabled" id="checks-radio-disabled" disabled />
<label class="form-check-label" for="checks-radio-disabled">Disabled radio</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-radio-disabled" id="checks-radio-disabled-checked" checked disabled />
<label class="form-check-label" for="checks-radio-disabled-checked">Disabled checked radio</label>
</div>Switches
A switch has the markup of a custom checkbox but uses the .form-switch class to render a toggle
switch. Switches also support the disabled attribute. Add role="switch" so
assistive technologies announce it as a switch.
HTML
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="checks-switch-default" />
<label class="form-check-label" for="checks-switch-default">Default switch checkbox input</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="checks-switch-checked" checked />
<label class="form-check-label" for="checks-switch-checked">Checked switch checkbox input</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="checks-switch-disabled" disabled />
<label class="form-check-label" for="checks-switch-disabled">Disabled switch checkbox input</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="checks-switch-disabled-checked" checked disabled />
<label class="form-check-label" for="checks-switch-disabled-checked">Disabled checked switch checkbox input</label>
</div>
Safari supports a native <input type="checkbox" switch> attribute that renders the
platform toggle. The theme sets appearance: none on
.form-switch .form-check-input[switch], so you can add the attribute for its semantics and still
get the Bootstrap look everywhere.
HTML
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" switch role="switch" id="checks-switch-native" checked />
<label class="form-check-label" for="checks-switch-native">Native <code>switch</code> attribute, Bootstrap look</label>
</div>
In dark mode the unchecked knob changes to rgba(255, 255, 255, .25) so it shows against the
dark track; checked switches are already white-on-gold.
Default (stacked)
By default, any number of checkboxes and radios that are immediate siblings will be vertically stacked and appropriately spaced with .form-check.
HTML
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-stacked-1" />
<label class="form-check-label" for="checks-stacked-1">Default checkbox</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checks-stacked-2" disabled />
<label class="form-check-label" for="checks-stacked-2">Disabled checkbox</label>
</div>HTML
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-stacked-radio" id="checks-stacked-radio-1" />
<label class="form-check-label" for="checks-stacked-radio-1">Default radio</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-stacked-radio" id="checks-stacked-radio-2" checked />
<label class="form-check-label" for="checks-stacked-radio-2">Second default radio</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="checks-stacked-radio" id="checks-stacked-radio-3" disabled />
<label class="form-check-label" for="checks-stacked-radio-3">Disabled radio</label>
</div>Inline
Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check. Each inline item gets 1 rem of right margin.
HTML
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="checks-inline-1" value="option1" />
<label class="form-check-label" for="checks-inline-1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="checks-inline-2" value="option2" />
<label class="form-check-label" for="checks-inline-2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="checks-inline-3" value="option3" disabled />
<label class="form-check-label" for="checks-inline-3">3 (disabled)</label>
</div>HTML
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="checks-inline-radio" id="checks-inline-radio-1" value="option1" />
<label class="form-check-label" for="checks-inline-radio-1">Face</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="checks-inline-radio" id="checks-inline-radio-2" value="option2" />
<label class="form-check-label" for="checks-inline-radio-2">Heel</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="checks-inline-radio" id="checks-inline-radio-3" value="option3" disabled />
<label class="form-check-label" for="checks-inline-radio-3">Tweener (disabled)</label>
</div>Reverse
Put your checkboxes, radios, and switches on the opposite side with the .form-check-reverse modifier class.
HTML
<div class="form-check form-check-reverse">
<input class="form-check-input" type="checkbox" value="" id="checks-reverse-1" />
<label class="form-check-label" for="checks-reverse-1">Reverse checkbox</label>
</div>
<div class="form-check form-check-reverse">
<input class="form-check-input" type="checkbox" value="" id="checks-reverse-2" disabled />
<label class="form-check-label" for="checks-reverse-2">Disabled reverse checkbox</label>
</div>
<div class="form-check form-switch form-check-reverse">
<input class="form-check-input" type="checkbox" role="switch" id="checks-reverse-switch" />
<label class="form-check-label" for="checks-reverse-switch">Reverse switch checkbox input</label>
</div>Without labels
Omit the wrapping .form-check for checkboxes and radios that have no label text. Remember to
still provide some form of accessible name for assistive technologies (for instance, using
aria-label).
HTML
<div>
<input class="form-check-input" type="checkbox" id="checks-no-label-1" value="" aria-label="Checkbox without a visible label" />
</div>
<div>
<input class="form-check-input" type="radio" name="checks-no-label-radio" id="checks-no-label-2" value="" aria-label="Radio without a visible label" />
</div>Toggle buttons
Create button-like checkboxes and radio buttons by using .btn styles rather than
.form-check-label on the <label> elements. The input is hidden with
.btn-check; the checked state is styled by the .btn-check:checked + .btn rule,
so this is pure CSS. See Buttons for the button styles.
Checkbox toggle buttons
HTML
<input type="checkbox" class="btn-check" id="checks-btn-check" autocomplete="off" />
<label class="btn btn-primary" for="checks-btn-check">Single toggle</label>HTML
<input type="checkbox" class="btn-check" id="checks-btn-check-2" checked autocomplete="off" />
<label class="btn btn-primary" for="checks-btn-check-2">Checked</label>HTML
<input type="checkbox" class="btn-check" id="checks-btn-check-3" autocomplete="off" disabled />
<label class="btn btn-primary" for="checks-btn-check-3">Disabled</label>Radio toggle buttons
HTML
<input type="radio" class="btn-check" name="checks-btn-radio" id="checks-btn-radio-1" autocomplete="off" checked />
<label class="btn btn-secondary" for="checks-btn-radio-1">Face</label>
<input type="radio" class="btn-check" name="checks-btn-radio" id="checks-btn-radio-2" autocomplete="off" />
<label class="btn btn-secondary" for="checks-btn-radio-2">Heel</label>
<input type="radio" class="btn-check" name="checks-btn-radio" id="checks-btn-radio-3" autocomplete="off" />
<label class="btn btn-secondary" for="checks-btn-radio-3">Tweener</label>Outlined styles
Different variants of .btn, such as the various outlined styles, are supported. In dark mode
the checked .btn-outline-primary fills with gold-500.
HTML
<input type="checkbox" class="btn-check" id="checks-btn-outline-check" autocomplete="off" />
<label class="btn btn-outline-primary" for="checks-btn-outline-check">Single toggle</label><br />
<input type="checkbox" class="btn-check" id="checks-btn-outline-check-2" checked autocomplete="off" />
<label class="btn btn-outline-secondary" for="checks-btn-outline-check-2">Checked</label><br />
<input type="radio" class="btn-check" name="checks-btn-outline-radio" id="checks-btn-outline-radio-1" autocomplete="off" checked />
<label class="btn btn-outline-success" for="checks-btn-outline-radio-1">Clean finish</label>
<input type="radio" class="btn-check" name="checks-btn-outline-radio" id="checks-btn-outline-radio-2" autocomplete="off" />
<label class="btn btn-outline-danger" for="checks-btn-outline-radio-2">DQ</label>Sass variables
From scss/_variables.scss:
$form-check-input-border-radius: $border-radius-sm; // 2px (checkboxes only)
$form-check-input-border: 1px solid $rb-navy-400;
$form-check-input-checked-bg-color: $primary; // gold-700
$form-check-input-checked-color: $rb-navy-900; // check mark / dot
$form-switch-color: $rb-navy-300; // unchecked knob
$form-check-input-bg inherits $input-bg (cream-50).
$form-switch-checked-color stays Bootstrap's white. The dark-mode gold-500 fill for
:checked, :indeterminate and .btn-check:checked + .btn-outline-primary
is emitted from scss/_tokens.scss.
The two theme-level rules in scss/components/_forms.scss:
label.btn { margin-bottom: 0; }
.form-switch .form-check-input[switch] { appearance: none; }