
Bs5 Range in Bootstrap
Sure! Here’s a quick guide to Bootstrap 5 Range inputs — basically styled sliders for numeric input.
?? Bootstrap 5 Range Input
Range inputs let users select a value from a range by sliding a handle.
1. Basic Range Input
<input type="range" class="form-range" min="0" max="100" id="customRange1">
Use
<input type="range">
Add
.form-range
class for Bootstrap stylingmin
andmax
attributes set the range limits
2. Range Input with Labels
<label for="customRange2" class="form-label">Example Range input</label><input type="range" class="form-range" min="0" max="5" id="customRange2">
3. Disabled Range Input
<input type="range" class="form-range" min="0" max="10" disabled>
4. Steps and Value
Control step intervals with step
attribute:
<input type="range" class="form-range" min="0" max="10" step="2" id="stepRange">
5. Vertical Range Input (Custom CSS Needed)
Bootstrap doesn’t provide vertical range styles by default, but you can customize with CSS.
6. Example with Current Value Display (JS)
<label for="customRange3" class="form-label">Select value: <span id="rangeValue">50</span></label><input type="range" class="form-range" min="0" max="100" id="customRange3" value="50"><script> const rangeInput = document.getElementById('customRange3'); const rangeValue = document.getElementById('rangeValue'); rangeInput.addEventListener('input', () => { rangeValue.textContent = rangeInput.value; });</script>
Summary
Attribute/Class | Description |
---|---|
.form-range | Bootstrap styling for range input |
min | Minimum value |
max | Maximum value |
step | Step interval |
disabled | Disable the input |
Want help building a custom slider or integrating it with forms? Just ask!