Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(range): provide an example to display the value #1714

Merged
merged 8 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
22 changes: 22 additions & 0 deletions site/content/docs/5.3/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>
<output id="customRange4ValueText" for="customRange4" class="fw-bold" aria-hidden="true"></output>
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved
</div>
<input type="range" class="form-range" min="0" max="100" step="1" id="customRange4" onchange="updateLabelValue()">
julien-deramond marked this conversation as resolved.
Show resolved Hide resolved

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

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

## CSS

### Sass variables
Expand Down
2 changes: 2 additions & 0 deletions site/content/docs/5.3/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Learn more by reading the new [color modes documentation]({{< docsref "/customiz

- Form validation `border-color` and text `color` states now respond to dark mode, thanks to new Sass and CSS variables.

- <span class="badge bg-success">New</span> Our range documentation now provides an example which displays the current selected value for better usability, but with some extra JavaScript code.

### Helpers and utilities

- <span class="badge bg-success">New</span> `.border-{color}-subtle`.
Expand Down