This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Reference Expo UI Jetpack Compose Slider A Jetpack Compose Slider component for selecting values from a range.
Recommended version:
~58.1.0
For cross-platform usage, see the universal Slider — it renders the appropriate native component per platform.
Expo UI Slider matches the official Jetpack Compose Slider API and allows selecting values from a bounded range.
Installation
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui
If you are installing this in an existing React Native app , make sure to install expo in your project.
Usage
Basic slider
import { useState } from 'react' ;
import { Host , Slider } from '@expo/ui/jetpack-compose' ;
export default function BasicSliderExample ( ) {
const [ value, setValue] = useState ( 0.5 ) ;
return (
< Host
matchContents = { { vertical: true } }
style = { { width: '100%' } } >
< Slider value = { value} onValueChange = { setValue} />
</ Host >
) ;
}
Slider with custom range
Use the min and max props to define the slider's value range.
CustomRangeSliderExample.tsx import { useState } from 'react' ;
import { Host , Slider } from '@expo/ui/jetpack-compose' ;
export default function CustomRangeSliderExample ( ) {
const [ value, setValue] = useState ( 50 ) ;
return (
< Host
matchContents = { { vertical: true } }
style = { { width: '100%' } } >
< Slider
value = { value}
min = { 0 }
max = { 100 }
onValueChange = { setValue}
/>
</ Host >
) ;
}
Slider with steps
Use the steps prop to define discrete increments. Set steps to 0 for continuous values.
import { useState } from 'react' ;
import { Host , Slider } from '@expo/ui/jetpack-compose' ;
export default function SteppedSliderExample ( ) {
const [ value, setValue] = useState ( 0 ) ;
return (
< Host
matchContents = { { vertical: true } }
style = { { width: '100%' } } >
< Slider
value = { value}
min = { 0 }
max = { 100 }
steps = { 10 }
onValueChange = { setValue}
/>
</ Host >
) ;
}
Custom colors
Use the colors prop to override the default Material3 colors for the slider's thumb, track, and tick marks.
CustomColorsSliderExample.tsx import { useState } from 'react' ;
import { Host , Slider } from '@expo/ui/jetpack-compose' ;
export default function CustomColorsSliderExample ( ) {
const [ value, setValue] = useState ( 0.5 ) ;
return (
< Host
matchContents = { { vertical: true } }
style = { { width: '100%' } } >
< Slider
value = { value}
colors = { {
thumbColor: '#6200EE' ,
activeTrackColor: '#6200EE' ,
inactiveTrackColor: '#E0E0E0' ,
} }
onValueChange = { setValue}
/>
</ Host >
) ;
}
Custom thumb and track
Use both Slider.Thumb and Slider.Track slots for a fully custom slider appearance.
FullyCustomSliderExample.tsx import { useState } from 'react' ;
import {
Host ,
Slider ,
Shape ,
Row ,
Box ,
} from '@expo/ui/jetpack-compose' ;
import {
fillMaxWidth,
height,
weight,
size,
clip,
background,
Shapes ,
} from '@expo/ui/jetpack-compose/modifiers' ;
export default function FullyCustomSliderExample ( ) {
const [ value, setValue] = useState ( 0.5 ) ;
return (
< Host
matchContents = { { vertical: true } }
style = { { width: '100%' } } >
< Slider value = { value} onValueChange = { setValue} >
< Slider.Thumb >
< Box
modifiers = { [
size ( 24 , 24 ) ,
clip ( Shapes . Circle ) ,
background ( '#6200EE' ) ,
] }
/>
</ Slider.Thumb >
< Slider.Track >
< Row modifiers = { [ fillMaxWidth ( ) , height ( 8 ) ] } >
< Shape.RoundedCorner
color = " #6200EE"
cornerRadii = { { topStart: 4 , bottomStart: 4 } }
modifiers = { [ weight ( Math . max ( value, 0.01 ) ) , height ( 8 ) ] }
/>
< Shape.RoundedCorner
color = " #BDBDBD"
cornerRadii = { { topEnd: 4 , bottomEnd: 4 } }
modifiers = { [
weight ( Math . max ( 1 - value, 0.01 ) ) ,
height ( 8 ) ,
] }
/>
</ Row >
</ Slider.Track >
</ Slider >
</ Host >
) ;
}
Vertical slider
Use VerticalSlider to select a single value along a vertical track. Set reverseDirection to make values increase from bottom to top instead of top to bottom.
VerticalSliderExample.tsx import { useState } from 'react' ;
import { Host , VerticalSlider } from '@expo/ui/jetpack-compose' ;
import { height } from '@expo/ui/jetpack-compose/modifiers' ;
export default function VerticalSliderExample ( ) {
const [ value, setValue] = useState ( 0.5 ) ;
return (
< Host matchContents >
< VerticalSlider
value = { value}
reverseDirection
onValueChange = { setValue}
modifiers = { [ height ( 240 ) ] }
/>
</ Host >
) ;
}
API
import { Slider , VerticalSlider } from '@expo/ui/jetpack-compose' ;
Components Type: React.Element < SliderProps >
A slider component that wraps Material3's Slider.
Optional • Type:
ReactNode Slot children for custom thumb and track.
Optional • Type:
SliderColors Colors for slider elements. Maps to Material3's SliderDefaults.colors().
Optional • Type: boolean • Default: true
Whether the slider is enabled for user interaction.
Optional • Type: number
Lower limit the user can drag the thumb to. The visible track still
spans min..max, but the thumb stops at lowerLimit during drag.
Optional • Type: number • Default: 1
The maximum value of the slider. Updating this value does not trigger callbacks if the current value is above max.
Optional • Type: number • Default: 0
The minimum value of the slider. Updating this value does not trigger callbacks if the current value is below min.
Optional • Type: ModifierConfig[]
Modifiers for the component.
Optional • Type: ( value: number ) => void
Callback triggered on dragging along the slider.
Optional • Type: ( ) => void
Callback triggered when the user finishes changing the value (for example, lifts a finger).
Maps to Material3's onValueChangeFinished.
Optional • Type: number • Default: 0
The number of steps between the minimum and maximum values, 0 signifies infinite steps.
Optional • Type: number
Upper limit the user can drag the thumb to. The visible track still
spans min..max, but the thumb stops at upperLimit during drag.
Optional • Type: number • Default: 0
The current value of the slider.
Type: React.Element < VerticalSliderProps >
A vertical slider component that wraps Material3's VerticalSlider.
Optional • Type: boolean • Default: false
Whether the direction of the slider is reversed. By default, values increase from top to bottom.
Types Colors for slider elements. Maps directly to Material3's SliderDefaults.colors().