Bootstrap 5 Range Slider
The Bootstrap 5 Range Slider is a form input element that lets users select a numeric value by dragging a handle along a horizontal track. It is built using the native HTML input[type='range'] element, styled with the .form-range class for consistent cross-browser rendering. Use it when you need users to pick a value within a defined min/max boundary, especially where approximate precision is acceptable.
Bootstrap class
.form-rangeCommon use cases
- A mortgage calculator where users drag to set a loan amount between £50,000 and £1,000,000 in £5,000 steps
- A product filter on an e-commerce site letting shoppers set a maximum price before results update dynamically
- A video or audio player volume control embedded in a custom media player interface
- A quiz or survey tool where respondents rate their confidence or satisfaction on a 0 to 10 scale
Variants and classes
| Variant | Description and classes |
|---|---|
| Default | Styled native range input.form-range + type="range" |
| Min, max and step | Sets the range and increments.min / max / step attributes |
| With value label | Current value shown beside the slider.d-flex justify-content-between + output |
| Disabled | Visible but cannot be moved.form-range + disabled attribute |
Code example
<div class="mb-3">
<label for="priceRange" class="form-label">Maximum Price: <span id="priceValue">£500</span></label>
<input
type="range"
class="form-range"
id="priceRange"
min="0"
max="1000"
step="50"
value="500"
oninput="document.getElementById('priceValue').textContent = '£' + this.value"
>
<div class="d-flex justify-content-between">
<small class="text-muted">£0</small>
<small class="text-muted">£1,000</small>
</div>
</div>Live examples
Basic Range Slider
Canvas template variants
Canvas Builder builds pages on the Canvas HTML template, which adds its own styled versions of Bootstrap 5 components. Variants you can ask for in a prompt:
- Canvas Builder generated range slider with custom colours
- Range Slider with interactive states
- Responsive range slider for all screen sizes
Best practices
Always show the current value in real time
Link the slider to a visible output using a short oninput handler or JavaScript event listener so users always know the exact value they have selected, not just the approximate position of the handle.
Set meaningful step values to reduce input errors
Use the step attribute to constrain snapping points. For a salary range of £20,000 to £100,000, a step of 1000 prevents confusing fractional values and makes the slider easier to control with keyboard arrow keys.
Add min/max labels below the track
Bootstrap does not render tick marks or boundary labels by default, so pair your .form-range with a flex row of small text nodes showing the minimum and maximum values to give users clear reference points.
Test keyboard accessibility explicitly
The range input is natively focusable and responds to arrow keys, Home, and End, but verify that your visible value display updates correctly on keyboard interaction and that the label association via the for attribute is correct.