Forms
Range
Sliders with a cream track and a gold thumb.
How it works in this theme
.form-range restyles the native <input type="range"> through its
vendor pseudo-elements. The theme sets:
- Track:
.5remtall,cream-300(#d9cdb0), pill-rounded. - Thumb: 1 rem circle in
gold-700;gold-500in dark mode. While dragging it lightens to a 70 % tint of gold. - Focus: the gold ring around the thumb, separated from it by a 1 px
cream-100gap. - Disabled: the thumb takes
--bs-secondary-colorand pointer events are removed.
Only the thumb and the track are styled. The browser still draws the filled portion of the track (where it does) and handles keyboard arrows, so there is no script.
Overview
Create custom <input type="range"> controls with .form-range. The track is
styled to appear the same in WebKit and Firefox.
HTML
<label for="range-default" class="form-label">Crowd heat</label>
<input type="range" class="form-range" id="range-default" />Disabled
Add the disabled boolean attribute on an input to give it a greyed-out appearance, remove pointer events, and prevent focusing.
HTML
<label for="range-disabled" class="form-label">Disabled range</label>
<input type="range" class="form-range" id="range-disabled" disabled />Min and max
Range inputs have implicit values for min and max — 0 and
100, respectively. You may specify new values for those using the min and
max attributes.
HTML
<label for="range-minmax" class="form-label">Rounds (0–5)</label>
<input type="range" class="form-range" min="0" max="5" id="range-minmax" />Steps
By default, range inputs "snap" to integer values. To change this, you can specify a step
value. In the example below, the number of steps is doubled by using step="0.5".
HTML
<label for="range-step" class="form-label">Star rating (0–5, half stars)</label>
<input type="range" class="form-range" min="0" max="5" step="0.5" id="range-step" />Sass variables
From scss/_variables.scss:
$form-range-thumb-bg: $primary; // gold-700
$form-range-track-bg: $rb-cream-300;
Inherited from Bootstrap's defaults and resolved against the theme:
$form-range-track-height: .5rem;
$form-range-track-border-radius: 1rem;
$form-range-thumb-width: 1rem;
$form-range-thumb-active-bg: tint-color($component-active-bg, 70%);
$form-range-thumb-disabled-bg: var(--#{$prefix}secondary-color);
$form-range-thumb-focus-box-shadow: 0 0 0 1px $body-bg, $input-focus-box-shadow; // cream-100 gap + gold ring
The dark-mode gold-500 thumb is a static override on
.form-range::-webkit-slider-thumb and ::-moz-range-thumb in
scss/_tokens.scss, because Bootstrap bakes $form-range-thumb-bg into the
pseudo-element rather than a custom property.