Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions site/content/docs/5.3/forms/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ By default, range inputs "snap" to integer values. To change this, you can speci
<input type="range" class="form-range" min="0" max="5" step="0.5" id="customRange3">
{{< /example >}}

# Usability

For improved usability, it is recommended most of the time to display the current selected value in text form

{{< example >}}
<div class="d-flex w-100 justify-content-between">
<label for="customRange4" class="form-label">Example range</label>
<output for="customRange4" class="fw-bold" aria-hidden="true"></output>
</div>
<input type="range" class="form-range" min="0" max="100" step="1" id="customRange4">

<script>
function updateLabelValue() {
document.querySelector(`output[for="${this.id}"]`).innerHTML = "Value: " + this.value;
}
window.addEventListener('load', function () {
Array.from(document.getElementsByClassName('form-range')).forEach(function (element) {
if (document.querySelector(`output[for="${element.id}"]`)) {
element.addEventListener('input', updateLabelValue)
updateLabelValue.call(element)
}
})
})
</script>
{{< /example >}}

## CSS

### Sass variables
Expand Down