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.
Primary Class
.range-sliderCommon 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 & Classes
| Variant | Description |
|---|---|
| Range Slider Default | Standard range slider with Bootstrap's default styling. |
| Range Slider Responsive | Responsive variant that adapts to different screen sizes. |
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 Framework Variants
The Canvas template extends Bootstrap 5 with 1,658+ component variants. Generate any of these using Canvas Builder:
- ✓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.