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
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
- Copy the source into
components/ui/slider.tsx:
- Update the import paths to match your project.
Usage
Pass defaultValue or value as an array: one number for a single thumb, two for a range. min defaults to 0 and max to 100; use step to snap to increments. Use onValueChange with value to control it, and set orientation="vertical" for a vertical slider.
Examples
Range
Uses two values to select a range with two thumbs.
Steps
Moves in increments of 10.
Vertical
Runs vertically.
Disabled
Disables interaction and removes the thumb from the tab order.
API Reference
Slider
The complete slider: track, filled range and thumbs.
Also accepts the props of the primitive part it wraps.
Accessibility
- Each thumb has the
sliderrole witharia-valuenowandaria-orientation. aria-labelandaria-labelledbyonSliderare passed to every thumb, so each thumb is named.- 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.
Notes
- If neither
valuenordefaultValueis an array, the slider renders two thumbs. Always pass an array. - Parts carry
data-slotattributes:slider,slider-track,slider-rangeandslider-thumb. - The range uses
bg-primary, the track usesbg-border, and disabled sliders are dimmed withopacity-50. - Thumbs use
thumbAlignment="edge", so they stay inside the track at both ends.
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.











