This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

RangeSlider

A Jetpack Compose RangeSlider component for selecting two values on a track.

Android
Included in Expo Go

RangeSlider wraps the Material 3 RangeSlider. It lets users select a start and end value on one track. For a single value, use Slider.

Installation

Terminal
- 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

Select a range

Render RangeSlider inside a Host. Use startValue and endValue for the selected endpoints and trackRange for the bounds of the entire track. Both bounds are inclusive.

import { useState } from 'react'; import { Host, RangeSlider, type RangeSliderRange, Text, Column, } from '@expo/ui/jetpack-compose'; export default function RangeSliderExample() { const [range, setRange] = useState<RangeSliderRange>({ start: 20, endInclusive: 80, }); return ( <Host matchContents={{ vertical: true }} style={{ width: '100%' }}> <Column> <Text> {Math.round(range.start)}–{Math.round(range.endInclusive)} </Text> <RangeSlider startValue={range.start} endValue={range.endInclusive} trackRange={{ start: 0, endInclusive: 100 }} onValueChange={setRange} /> </Column> </Host> ); }

onValueChange receives { start, endInclusive } as the user changes either endpoint. Compose keeps the endpoints within the track bounds and prevents the thumbs from crossing. Native interaction works without updating React state on every change. Changing the endpoint props updates the selection when the user is not dragging.

Use onValueChangeFinished for work that should run after an interaction, such as saving a filter. It has no value argument. Read the selection from onValueChange. With a keyboard, the completion callback runs each time the user releases a key that moves a thumb.

Select discrete values

steps counts the selectable positions between the track bounds. On a track from 0 to 100, steps={9} allows 0, 10, 20, and so on through 100. Use steps={0}, the default, for continuous selection.

<RangeSlider startValue={20} endValue={80} trackRange={{ start: 0, endInclusive: 100 }} steps={9} />

Customize colors

Use colors to override the thumb, track, and tick colors. RangeSlider shares SliderColors with Slider and VerticalSlider. The active track is the section between the thumbs. Omitted colors use the Material theme. Set enabled={false} to disable interaction and use the disabled colors.

<RangeSlider startValue={0.2} endValue={0.8} colors={{ thumbColor: '#6750A4', activeTrackColor: '#6750A4', inactiveTrackColor: '#E8DEF8', disabledThumbColor: '#79747E', disabledActiveTrackColor: '#938F99', }} />

Customize thumbs and track

Use RangeSlider.StartThumb, RangeSlider.EndThumb, and RangeSlider.Track to replace each visual part independently. Any slot you omit keeps its native appearance.

import { Box, Host, RangeSlider } from '@expo/ui/jetpack-compose'; import { background, clip, Shapes, size, } from '@expo/ui/jetpack-compose/modifiers'; export default function CustomThumbsExample() { return ( <Host matchContents={{ vertical: true }} style={{ width: '100%' }}> <RangeSlider startValue={0.2} endValue={0.8}> <RangeSlider.StartThumb> <Box modifiers={[ size(24, 24), clip(Shapes.Circle), background('#6750A4'), ]} /> </RangeSlider.StartThumb> <RangeSlider.EndThumb> <Box modifiers={[ size(24, 24), clip(Shapes.Circle), background('#006A60'), ]} /> </RangeSlider.EndThumb> </RangeSlider> </Host> ); }

A custom RangeSlider.Track replaces the entire track, including its active section and tick marks. Use the selection from onValueChange if your track needs to reflect the selected range.

API

import { RangeSlider } from '@expo/ui/jetpack-compose';

Component

RangeSlider

Android

Type: React.Element<RangeSliderProps>

A Material 3 slider for selecting two values on a bounded track. It works only inside a Host component.

RangeSliderProps

children

Android
Optional • Type: ReactNode

Custom content wrapped in RangeSlider.StartThumb, RangeSlider.EndThumb, or RangeSlider.Track.

colors

Android
Optional • Type: SliderColors

Colors for the thumbs, track, and tick marks. Omitted colors use the Material theme.

enabled

Android
Optional • Type: boolean • Default: true

Whether the slider responds to user interaction.

endValue

Android
Optional • Type: number • Default: 1

The selected end value. Changing this prop updates the native selection when the user is not dragging.

modifiers

Android
Optional • Type: ModifierConfig[]

Modifiers for the component.

onValueChange

Android
Optional • Type: (range: RangeSliderRange) => void

Called with both endpoints when the user changes the selection.

onValueChangeFinished

Android
Optional • Type: () => void

Called when the user finishes changing the selection. It has no value argument. onValueChange reports the selection.

startValue

Android
Optional • Type: number • Default: 0

The selected start value. Changing this prop updates the native selection when the user is not dragging.

steps

Android
Optional • Type: number • Default: 0

The number of selectable positions between the track bounds. Must be a nonnegative integer. 0 means continuous selection.

trackRange

Android
Optional • Type: RangeSliderRange • Default: { start: 0, endInclusive: 1 }

The bounds of the entire track. The slider clamps values outside these bounds.

Types

RangeSliderRange

Android

An inclusive numeric range for RangeSlider.

PropertyTypeDescription
endInclusivenumber

The end of the range, included in the selection.

startnumber

The start of the range.

SliderColors

Android

Colors for slider elements. Maps directly to Material3's SliderDefaults.colors().

PropertyTypeDescription
activeTickColor(optional)ColorValue

The active tick color when enabled.

activeTrackColor(optional)ColorValue

The active track color when enabled.

disabledActiveTickColor(optional)ColorValue

The active tick color when disabled.

disabledActiveTrackColor(optional)ColorValue

The active track color when disabled.

disabledInactiveTickColor(optional)ColorValue

The inactive tick color when disabled.

disabledInactiveTrackColor(optional)ColorValue

The inactive track color when disabled.

disabledThumbColor(optional)ColorValue

The thumb color when disabled.

inactiveTickColor(optional)ColorValue

The inactive tick color when enabled.

inactiveTrackColor(optional)ColorValue

The inactive track color when enabled.

thumbColor(optional)ColorValue

The thumb color when enabled.

Reference version