React Native · Components
Slider
Slider: a single value or a range.
4 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Volume: a single value, bubble on hover
Storage: marks only (1, 2, 4, 8, 16 GB)
Balance: fill in both directions from the middle (origin)
Working hours: three thumbs, value always visible
Vertical: equalizer
Controlled: catch the value with onValueCommit
Live: [25,75] · On release: [25,75]
Import
Slider
componentSlider: a single value or a range. Same calculations (@yasinsensoy/core/slider-math) and same look as the web Slider. Tapping anywhere on the track moves the nearest thumb there; dragging locks vertical scrolling while moving horizontally. With a screen reader, swiping up/down changes it step by step.
Examples
SliderMark
interfaceA mark on the slider. Label is the label type (ReactNode on web and React Native).
| Name | Type | Description |
|---|---|---|
value | number | Value of the mark. |
label? | Label | Label written under the mark (beside it when vertical). Only a dot is drawn when omitted. |
SliderValue
typeSlider value: a single number or a range ([20, 80]).
SliderProps
interfaceSlider props.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
value? | V | Value (controlled). With an array, one thumb is drawn per element. | |
defaultValue? | V | min | Initial value (uncontrolled). |
onValueChange? | (value: V) => void | Whenever the value changes (every step while dragging). | |
onValueCommit? | (value: V) => void | With the final value when the finger lifts; for expensive work such as server requests. | |
min? | number | 0 | Minimum value. |
max? | number | 100 | Maximum value. |
step? | number | 1 | Step size. |
minStepsBetween? | number | 0 | Minimum number of steps kept between thumbs in a range. |
marks? | boolean | readonly (number | SliderMark<ReactNode>)[] | Marks on the track: true a dot at every step, a number array dots only, a { value, label } array also draws labels below. | |
snapToMarks? | boolean | false | The value can only be one of the marks; marks are spaced evenly. |
valueLabel? | "auto" | "always" | "never" | "auto" | Value bubble above the thumb: "auto" while dragging. |
format? | Intl.NumberFormatOptions | ((value: number) => ReactNode) | How the value is written: Intl.NumberFormat options or a function. | |
locale? | string | {@link UIProvider} `locale | Language of the numbers. |
orientation? | "horizontal" | "vertical" | "horizontal" | Orientation; vertical increases bottom to top (height via style). |
origin? | number | min | Value where the fill starts with a single thumb (0 for -50…50). |
tone? | Tone | "primary" | Color. |
size? | Size | "md" | Thickness and thumb size (16, 20, 24 px). |
readOnly? | boolean | The value is visible but cannot be changed. | |
thumbLabels? | readonly string[] | "Başlangıç" / "Bitiş" for a range | Thumb names for screen readers. |
style? | StyleProp<ViewStyle> | Container style. |