Skip to content

Commit 1e05eba

Browse files
committed
docs(Range): add example of showing the dynamic range value with output
1 parent 2ea459f commit 1e05eba

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/content/forms/range.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ By default, range inputs "snap" to integer values. To change this, you can speci
4444
<input type="range" class="form-range" min="0" max="5" step="0.5" id="customRange3">
4545
{{< /example >}}
4646

47+
## Output value
48+
49+
The value of the range input can be shown using the `output` element and a bit of JavaScript.
50+
51+
{{< example >}}
52+
<label for="customRange4" class="form-label">Example range</label>
53+
<input type="range" class="form-range" min="0" max="100" value="50" id="customRange4">
54+
<output for="customRange4" id="rangeValue" aria-hidden="true"></output>
55+
<script>
56+
// This is an example script, please modify as needed
57+
const rangeInput = document.getElementById('customRange4');
58+
const rangeOutput = document.getElementById('rangeValue');
59+
// Set initial value
60+
rangeOutput.textContent = rangeInput.value;
61+
rangeInput.addEventListener('input', function() {
62+
rangeOutput.textContent = this.value;
63+
});
64+
</script>
65+
{{< /example >}}
66+
4767
## Customizing
4868

4969
### SASS variables

0 commit comments

Comments
 (0)