This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
滑块
用于从范围中选择值的 Jetpack Compose 滑块组件。
关于跨平台用法,请参阅通用
Slider— 它会根据平台呈现相应的原生组件。
Expo UI Slider 与官方 Jetpack Compose Slider API 相匹配,并允许从有限范围内选择值。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基本滑块
自定义范围的滑块
使用 min 和 max 属性定义滑块的取值范围。
带步进的滑块
使用 steps 属性定义离散增量。将 steps 设为 0 可使用连续值。
自定义颜色
使用 colors 属性覆盖滑块拇指、轨道和刻度的默认 Material3 颜色。
自定义拇指和轨道
同时使用 Slider.Thumb 和 Slider.Track 插槽,可完全自定义滑块外观。
垂直滑块
使用 VerticalSlider 沿垂直轨道选择单个值。设置 reverseDirection,可使值从下往上递增,而不是从上往下递增。
API
import { Slider, VerticalSlider } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<SliderProps>
A slider component that wraps Material3's Slider.
SliderColorsColors for slider elements. Maps to Material3's SliderDefaults.colors().
boolean • Default: trueWhether the slider is enabled for user interaction.
numberLower limit the user can drag the thumb to. The visible track still
spans min..max, but the thumb stops at lowerLimit during drag.
number • Default: 1The maximum value of the slider. Updating this value does not trigger callbacks if the current value is above max.
number • Default: 0The minimum value of the slider. Updating this value does not trigger callbacks if the current value is below min.
(value: number) => voidCallback triggered on dragging along the slider.
() => voidCallback triggered when the user finishes changing the value (for example, lifts a finger).
Maps to Material3's onValueChangeFinished.
number • Default: 0The number of steps between the minimum and maximum values, 0 signifies infinite steps.
numberUpper limit the user can drag the thumb to. The visible track still
spans min..max, but the thumb stops at upperLimit during drag.
Type: React.Element<VerticalSliderProps>
A vertical slider component that wraps Material3's VerticalSlider.