Slider picks one number between min and max. Drag anywhere on the track and the thumb follows your finger, landing on a multiple of step. Screen readers announce it as an adjustable control and change it by step with a swipe up or down. For a range with two thumbs, use RangeSlider. See the web Slider for the browser version.
Without value the slider keeps its own state, starting at defaultValue (or min). showValue prints the value beside the label.
Pass value and update it in onChange to own the state. onChange gets a number on every step of the drag.
step can be a fraction. Values snap to multiples of step from min, without floating-point noise. Use ariaLabel when there is no visible label.
- The thumb follows a drag anywhere on the track, through a PanResponder. Once a drag starts, a scroll view around the slider cannot take it over; a vertical swipe that starts on the slider still scrolls the page.
- The track has no hover state. The thumb grows while it is dragged, as on the web.
- There is no hidden <input type="range">, so the native HTML input props (name, id, onInput…) are gone. Use ariaLabel for the accessible name when there is no label.
- Screen readers adjust the slider with the platform's increment and decrement actions instead of the arrow keys.