Slider
Pick a single value or a range by dragging.
Installation
npx axiom add sliderpnpm dlx axiom add slideryarn dlx axiom add sliderbun x axiom add sliderInstalls: react-native-reanimated, react-native-worklets, react-native-gesture-handler.
The value logic and gestures live in use-slider.ts, shared by every styling variant. Colors come from slider.default.{default,disabled}.{track,fill,thumb} in the component tokens.
Usage
import { Slider } from '@/components/ui/slider';
<Slider value={volume} onValueChange={setVolume} />
<Slider value={[min, max]} onValueChange={setPriceRange} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | [number, number] | — | A number for one thumb, a tuple for a range with two thumbs. |
defaultValue | number | [number, number] | min | Initial value when the slider manages its own state. |
onValueChange | (value) => void | — | Called continuously while dragging. Runs on the JS thread, so keep it cheap. |
onSlidingComplete | (value) => void | — | Called once when the finger lifts. Use it for expensive work: a request, a refetch. |
min | number | 0 | Lowest value. |
max | number | 100 | Highest value. |
step | number | 1 | Increment the value snaps to. 0 means continuous. |
minRange | number | 0 | Smallest gap between the two thumbs of a range. |
showSteps | boolean | false | Draws a tick for each step. Only use it when there are few steps. |
disabled | boolean | false | Blocks dragging and dims the slider. |
accessibilityLabel | string | — | What the slider controls. Screen reader users change it with swipe up and down, by one step. |
getAccessibilityValue | (value) => string | — | Text announced for the value, such as "5 kilometers". |
style | StyleProp<ViewStyle> | — | Extra styles for the container. |
The thumb is 20pt but its touch area is 44pt, and the whole track accepts a tap to jump to a value.
Use cases
Media volume
A continuous slider between two icons that show the direction.
<Slider
value={volume}
onValueChange={setVolume}
min={0}
max={1}
step={0}
accessibilityLabel="Volume"
getAccessibilityValue={(v) => `${Math.round(v * 100)} percent`}
/>Price range filter
Two thumbs with a minRange, and the request only sent when the user lets go.
<Slider
value={range}
onValueChange={setRange}
onSlidingComplete={(r) => refetch({ minPrice: r[0], maxPrice: r[1] })}
min={0}
max={500}
step={10}
minRange={20}
/>Discrete steps
A small step count with showSteps, for a value with a few meaningful levels.
<Slider
min={0}
max={3}
step={1}
showSteps
value={level}
onValueChange={setLevel}
accessibilityLabel="Text size"
/>