Under Construction: The content on this site draft material. It is not the official content of this site and should not be followed at this time.

Not Legal Advice: The content on this site is provided for informational purposes only and does not constitute legal advice. Consult a qualified attorney for advice specific to your situation.

Purpose

A slider lets users select a numeric value by dragging a control along a track. Use sliders for settings like volume, price ranges, or confidence levels.

Usage Guidance

  • Use native <input type="range"> whenever possible
  • Always show the current value adjacent to the slider
  • Label the slider with a visible <label>
  • Consider whether a numeric input is more appropriate for precise values

Keyboard Support

Key Action
Arrow Right / Arrow Up Increase value by one step
Arrow Left / Arrow Down Decrease value by one step
Page Up Increase value by a larger step
Page Down Decrease value by a larger step
Home Set to minimum value
End Set to maximum value

Screen Reader Behavior

Screen readers announce the label, current value, and the min/max range when a slider receives focus.

ARIA Requirements

Native <input type="range"> requires no ARIA. For custom sliders:

  • role="slider" on the draggable element
  • aria-valuenow set to current value
  • aria-valuemin set to minimum
  • aria-valuemax set to maximum
  • aria-valuetext when the numeric value needs a human-readable representation

Common Mistakes

  • Not updating aria-valuenow dynamically as the value changes
  • Missing visible current value indicator
  • Custom sliders without keyboard support

Live Example

0%50%100%

Code Example

<label for="confidence">
  Confidence Level:
  <span id="confidence-value" aria-live="polite">50%</span>
</label>
<input
  id="confidence"
  type="range"
  min="0"
  max="100"
  value="50"
  step="5"
>

<script>
  var slider = document.getElementById('confidence');
  var output = document.getElementById('confidence-value');
  slider.addEventListener('input', function() {
    output.textContent = slider.value + '%';
  });
</script>