Style native range inputs as sliders with a consistent track and thumb across browsers, with min, max, and step configuration.
Introduction
A range input is a slider for choosing a numeric value between two bounds. The .form-range class styles the native <input type="range"> element: it draws the same track and thumb in every browser and adds the focus ring of the form controls.
Basic structure
Add .form-range to an <input type="range"> and connect it to a <label>.
<label for="rangeExample" class="form-label">Basic range slider</label>
<input type="range" class="form-range" id="rangeExample">Disabled state
Add the disabled attribute to a range input to make it unavailable. The thumb takes its disabled color, pointer events are removed, and the browser skips the input in the tab order.
<label for="disabledRange" class="form-label">Disabled range slider</label>
<input type="range" class="form-range" id="disabledRange" disabled>Range configuration
The native min, max, and step attributes set the bounds of the slider and the increment between its values.
Min and max values
A range input runs from 0 to 100 by default. Set min and max for another scale.
<label for="customRange" class="form-label">Custom range (0-5)</label>
<input type="range" class="form-range" min="0" max="5" id="customRange">Step increments
A range input moves in steps of 1 by default. Set step to a decimal value for finer increments.
<label for="preciseRange" class="form-label">Range with 0.5 step increments</label>
<input type="range" class="form-range" min="0" max="5" step="0.5" id="preciseRange">Contextual usage
Range inputs combine with other elements of a form: an output that shows the current value, and grid columns that place the slider next to other controls.
With value display
A slider does not show its value. Pair it with an <output> element that a script updates on the input event.
<div class="d-flex">
<label for="rangeWithOutput" class="form-label">Temperature (°C)</label>
<output for="rangeWithOutput" id="rangeOutput" class="ms-auto">22</output>
</div>
<input type="range" class="form-range" min="15" max="30" value="22" id="rangeWithOutput"
oninput="rangeOutput.value = this.value">Form layouts
Use the grid system and the layout utilities to arrange range inputs alongside other form controls.
<div class="grid gap-md">
<div class="col-span-full md:col-span-6">
<label for="volumeRange" class="form-label">Volume</label>
<input type="range" class="form-range" min="0" max="100" value="75" id="volumeRange">
</div>
<div class="col-span-full md:col-span-6">
<label for="brightnessRange" class="form-label">Brightness</label>
<input type="range" class="form-range" min="0" max="100" value="50" id="brightnessRange">
</div>
</div>Accessibility
A range input is a native control with the slider role, so the markup only has to supply its name and, where needed, a readable value:
- Always associate a visible
<label>with the input using theforattribute so the control has an accessible name. - Use
aria-valuetextwhen the numeric value alone doesn't convey meaning to the user — for example, a satisfaction scale where1should be announced as "Very dissatisfied" rather than "1". - Use
aria-describedbyto associate a.form-helpelement with the input when additional context is needed, so screen readers announce the description when the field receives focus. - Pair range inputs with a visible value display (such as an
<output>element) so sighted users can see the exact value while adjusting the slider. - Range inputs are keyboard-navigable by default: arrow keys adjust by one step, and
Home/Endjump to the minimum and maximum values.
CSS
The Form Range component can be customized through Sass variables at compile time.
Custom properties
The Form Range component exposes CSS custom properties to control its appearance at runtime.
--form-range-track-color: #{$form-range-track-color};
--form-range-thumb-color: #{$form-range-thumb-color};
--form-range-thumb-disabled: #{$form-range-thumb-disabled};
--form-range-thumb-active: #{$form-range-thumb-active};
--form-range-thumb-width: #{$form-range-thumb-width};
--form-range-thumb-height: #{$form-range-thumb-height};
--form-range-thumb-border: #{$form-range-thumb-border};
--form-range-thumb-border-radius: #{$form-range-thumb-border-radius};
--form-range-thumb-box-shadow: #{$form-range-thumb-box-shadow};
--form-range-thumb-transition: #{$form-range-thumb-transition};
--form-range-track-width: #{$form-range-track-width};
--form-range-track-height: #{$form-range-track-height};
--form-range-track-border-radius: #{$form-range-track-border-radius};
--form-range-track-cursor: #{$form-range-track-cursor};
--form-range-track-box-shadow: #{$form-range-track-box-shadow};Sass variables
The Form Range component uses Sass variables in scss/config/_defaults.scss to define its defaults; they are also exposed as CSS custom properties using the --cx- prefix for runtime override — $variable-name becomes --cx-variable-name. See the component anatomy page.
$form-range-track-color: var(--default-bg-evident);
$form-range-thumb-color: var(--primary-bg-idle);
$form-range-thumb-disabled: var(--default-bg-disabled);
$form-range-thumb-active: var(--primary-bg-press);
$form-range-track-box-shadow: none; // var(--box-shadow-inset);
$form-range-track-width: 100%;
$form-range-track-height: .5rem;
$form-range-track-cursor: pointer;
$form-range-track-border-radius: 1rem;
$form-range-thumb-width: 1rem;
$form-range-thumb-height: $form-range-thumb-width;
$form-range-thumb-border: 0;
$form-range-thumb-border-radius: 1rem;
$form-range-thumb-box-shadow: var(--box-shadow-sm);
$form-range-focus-ring-offset: 1px;
$form-range-thumb-transition: background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;