Slider
Drag to set values, vertically or horizontally
Slider lets users set one or more values with pointer, touch, or keyboard input in horizontal and vertical layouts.
Features
Sizing and theming with controlled or uncontrolled state
Multiple thumb support
Configurable steps and keyboard controls
Accessible, composable, and customizable
Installation
Slider is already installed in tamagui, or you can install it independently:
yarn
npm
bun
pnpm
Usage
Slider comes as multiple components that ship with default styles and are sizable. The size prop on <Slider /> will automatically pass size down to all the sub-components.
You can also optionally style any component, either using inline style props or by wrapping with styled:
Vertical slider on iOS
When using a vertical slider on iOS, you need to pass safe area insets to TamaguiProvider for proper pointer position calculation. Without this, the slider thumb may not track your finger correctly due to iOS safe area offsets.
Then you can use vertical sliders normally:
This is only required on iOS. On Android and web, the slider works correctly without passing insets.
API reference
Slider
Contains every component for the slider.
Props
size
'xs' | 'sm' | 'md' | 'lg' | 'xl'
Controls the size of every component.
name
string
For usage with forms. On web, renders one hidden input per thumb under this name, so multi-thumb values submit as repeated entries readable via FormData.getAll(name).
value
number[]
Controlled value.
defaultValue
number[]
Uncontrolled starting value.
onValueChange
(value: number[]): void
Callback called when the value changes.
disabled
boolean
Disables interaction.
orientation
"horizontal" | "vertical"
Default:
horizontalDirection of the slider.
dir
"ltr" | "rtl"
Controls the side the active track appears on.
min
number
Minimum value.
max
number
Maximum value.
step
number
Minimum thumb move distance.
minStepsBetweenThumbs
number
Minimum steps between thumbs.
onSlideStart
(event: GestureReponderEvent, value: number, target: 'thumb' | 'track') => void
Called on slide start.
onSlideMove
(event: GestureReponderEvent, value: number) => void
Called on slide move.
onSlideEnd
(event: GestureReponderEvent, value: number) => void
Called on slide end.
Slider.Track
Slider.Track inherits YStack, extending all the default props.
Slider.TrackActive
Slider.TrackActive inherits View, extending all the default props.
Slider.Thumb
Slider.Thumb inherits YStack, extending all the default props, adding:
Props
index (required)
number
Corresponds to the index of `value` or `defaultValue`. Use to correlate thumbs to each value in the array.