Skip to content

Commit

Permalink
feat(range): provide an example to display the value
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond committed Dec 16, 2022
1 parent c661309 commit 7b1cfcf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions site/content/docs/5.2/forms/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ 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 better usability, it is recommended most of the time to display the current selected value.

This requires extra JavaScript code.

{{< example >}}
<div class="d-flex w-100 justify-content-between">
<label for="customRange4" class="form-label">Example range</label>
<label id="customRange4ValueLabel" for="customRange4" class="form-label"></label>
</div>
<input type="range" class="form-range" min="0" max="100" step="1" id="customRange4" onchange="updateLabelValue()">

<script>
function updateLabelValue() {
document.getElementById('customRange4ValueLabel').innerHTML = document.getElementById('customRange4').value;
}

updateLabelValue()
</script>
{{< /example >}}

## Sass

### Variables
Expand Down

0 comments on commit 7b1cfcf

Please sign in to comment.