suiss/ui · Component
Slider
A track with one or more draggable thumbs for choosing a value or range.
Slider is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Slider wraps the slider primitive of the chosen base in a single component. It renders the track, the filled range and one thumb per value. The thumb is a wide capsule that stretches while it's dragged or pressed.
Use a slider when an approximate value within a range matters more than a precise number, such as volume or brightness. For exact numbers, use a number field or Input.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Examples
Range
Pass two values in defaultValue to select a range with two thumbs.
Steps
Set step to 10 so the thumb moves in increments of 10.
Vertical
Set orientation="vertical" to run the slider vertically. Vertical sliders use the up and down arrow keys.
Disabled
Set disabled to turn off interaction and remove the thumb from the tab order.
Set isDisabled to turn off interaction and remove the thumb from the tab order.
Accessibility
- Each thumb has the
sliderrole witharia-valuenowandaria-orientation.
aria-labelandaria-labelledbyonSliderare passed to every thumb, so each thumb is named.
aria-labelandaria-labelledbyonSlidername the slider group, and every thumb is labelled by the group.
- Arrow keys move the focused thumb by one step;
HomeandEndjump to the minimum and maximum. Vertical sliders use the up and down arrow keys. - In a range,
Tabmoves between thumbs, and each thumb moves independently. - A disabled slider can't be focused.
API Reference
Slider
The complete slider: track, filled range and thumbs.
| Prop | Type | Default |
|---|---|---|
defaultValue | number[] | — |
value | number[] | — |
onValueChange | (value: number[]) => void | — |
min | number | 0 |
max | number | 100 |
step | number | 1 |
orientation | "horizontal" | "vertical" | "horizontal" |
disabled | boolean | false |
| Prop | Type | Default |
|---|---|---|
defaultValue | number[] | — |
value | number[] | — |
onChange | (value: number[]) => void | — |
minValue | number | 0 |
maxValue | number | 100 |
step | number | 1 |
orientation | "horizontal" | "vertical" | "horizontal" |
isDisabled | boolean | false |
Also accepts the props of the primitive part it wraps.
Pass defaultValue or value as an array with one number per thumb: one for a single thumb, two for a range. The number of thumbs follows the array length; without an array the slider renders one thumb, so always pass one. Control it with value and onValueChange, which is called when a thumb moves. step is the increment the thumbs snap to.
Thumbs use thumbAlignment="edge", so they stay inside the track at both ends.
Pass defaultValue or value as an array with one number per thumb: one for a single thumb, two for a range. The number of thumbs follows the array length. Control it with value and onChange, which is called when a thumb moves. step is the increment the thumbs snap to.
Each part sets a data-slot, such as slider-thumb or slider-range, for styling. Disabled sliders are dimmed with opacity-50.
Web preview
Slider renders a thin track, a filled indicator and one thumb per value. Pass a number for a single value, or an array for a range or several thumbs. The active thumb widens while it is dragged. It works horizontally or vertically.
Thumbs are aligned to the edges of the track, so they stay within it at min and max.
Installation
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/slider.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/slider.tsx:
- Update the import paths to match your project setup.
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/slider.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Controlled
A controlled slider that shows the live value and the value committed when a drag ends.

Range
A two-thumb price range that snaps to a step and keeps a minimum gap between the thumbs.
Web preview
Multiple thumbs
Pass three values for three thumbs. Set thumbCollisionBehavior="swap" so they swap when they cross.
Step
Set step to a decimal so the slider moves in decimal steps.
Web preview
Vertical
Set orientation="vertical" to run single and range sliders vertically.
Web preview
Disabled
A disabled slider with muted colors that ignores input.
Web preview
The React Native tab shows 2 more examples.
The React Native tab shows 2 more examples.
Accessibility
- Each thumb has the
adjustablerole with its min, max and current value, so VoiceOver and TalkBack users can swipe up or down to change it. accessibilityLabelonSlideris passed to every thumb; set it, since the slider has no visible label.- Disabled thumbs report
disabledin their accessibility state.
API Reference
Slider
The complete slider: track, filled range and thumbs.
Also accepts the props of SliderPrimitive.RootProps<Value>.
Use defaultValue for an uncontrolled slider, or value with onValueChange to control it. onValueCommitted runs when a drag or track press ends, which suits saving or fetching. Set min, max and step to define the range; min defaults to 0 and max to 100. The number of thumbs comes from the array length of value or defaultValue. For ranges, minStepsBetweenValues keeps thumbs apart and thumbCollisionBehavior decides whether thumbs push each other, swap, or stop (none). The slider is shown at opacity-50 when disabled.
ValueSlider
| Parameter | Type | Default |
|---|---|---|
value | Binding<Value> | - |
in | ClosedRange<Value> | 0...1 |
step | Value.Stride? | nil |
onEditingChanged | (Bool) -> Void | { _ in } |
RangeSlider
| Parameter | Type | Default |
|---|---|---|
value | Binding<ClosedRange<Value>> | - |
in | ClosedRange<Value> | 0...1 |
step | Value.Stride? | nil |
onEditingChanged | (Bool) -> Void | { _ in } |
Slider
The complete slider: track, filled range and thumbs.
| Parameter | Type | Default |
|---|---|---|
value | Float | - |
onValueChange | (Float) -> Unit | - |
modifier | Modifier | Modifier |
enabled | Boolean | LocalFieldState.current.enabled |
valueRange | ClosedFloatingPointRange<Float> | 0f..100f |
step | Float | 1f |
onValueChangeFinished | (() -> Unit)? | null |
contentDescription | String? | null |
RangeSlider
| Parameter | Type | Default |
|---|---|---|
value | ClosedFloatingPointRange<Float> | - |
onValueChange | (ClosedFloatingPointRange<Float>) -> Unit | - |
modifier | Modifier | Modifier |
enabled | Boolean | LocalFieldState.current.enabled |
valueRange | ClosedFloatingPointRange<Float> | 0f..100f |
step | Float | 1f |
onValueChangeFinished | (() -> Unit)? | null |
contentDescription | String? | null |
