Slider
Choose a numeric value or range by moving one or more thumbs.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/sliderComplete the one-time setup first. Registry JSON lists source files and dependencies.
For this page’s examples, also install:
pnpm dlx shadcn@4.18.0 add @siteplane/button @siteplane/form @siteplane/inputField is installed with Input.
Usage
import { Slider } from "@/siteplane/components/slider";
<Slider defaultValue={40} aria-label="Volume" />;Composition
Slider
├── SliderValue (optional child)
└── built-in control, track and thumbsControlled range
An array creates one thumb per value. The application owns the selected range.
Scale labels
Use labels to mark positions on the scale; they sit below the track and are hidden for vertical sliders. Each label stays on one line, and labels at the ends stay within the slider’s edges. They don’t name the slider, so still give it a label.
Orientation and disabled
Vertical controls need enough space for their minimum height.
Sizes
Omit size to inherit the provider's control size. The track and thumbs grow with the size; the value and the scale labels keep 12px text at every size.
Form integration
Give the surrounding Field a name to submit the slider value with the form; a range submits one entry per thumb.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
Slider. | sm | md | lg | xl | provider / lg | Control, track, thumb and label sizes. |
Slider. | readonly {label: ReactNode; value: number}[] | unset | Horizontal scale labels on one line; positions clamp to the range and end labels stay within the slider. |
Slider. | number | number[] | unset (one thumb at min) | Controlled or initial values; one thumb per value. |
Slider. | number | 0 / 100 | Range bounds. |
Slider. | horizontal | vertical | horizontal | Control direction. |
Slider. | foundation alignment | edge | Forwarded override can replace the edge default. |
Slider. | string | unset | Applied to every generated thumb. |
Slider. | (value, eventDetails) => void | unset | Live edit callback. |
Slider. | (value, eventDetails) => void | unset | Committed edit callback. |
Slider | sm | md | lg | xl | root / provider / lg | Size context of the value. Its text is 12px at every size, like the scale labels. |
SliderProps, SliderValueProps and SliderPrimitive are exported. Slider
always renders its own control/track/indicator/thumbs; children supplement them,
not replace them. SliderValue formats the current value using the Base UI
Slider Value contract. Other step,
form, disabled, keyboard and validation props are inherited. The wrapper does
not expose a separate label per thumb; the supplied aria-label is repeated.
Scale labels are not public components.
Usage notes
Arrow keys adjust the focused thumb; Home/End move to bounds. Do not use scale labels as the only accessible name. Use NumberField if precise typed entry is necessary. The application owns business validation and persistence.