Slider
stableAn input where the user selects a value from within a given range.
Basic usage
Examples
Range slider
Pass two default values to create a range slider with two thumbs.
20 – 80
Range and vertical sliders
Slider supports multiple thumbs, step intervals and orientation changes.
Semantic colors
Color prop tints the slider track and thumb to match semantic intent.
Features
- Can be controlled or uncontrolled.
- Supports multiple thumbs.
- Supports keyboard and touch.
- Supports a stepped interval and min/max.
Installation
bash
pnpm dlx structyl add sliderAPI Reference
Slider
A range input supporting one or more thumbs.
| Prop | Type | Default |
|---|---|---|
| value | number[]Controlled value(s). One entry per thumb. | — |
| defaultValue | number[]Initial value(s) when uncontrolled. | [min] |
| onValueChange | (value: number[]) => voidCalled as the value changes. | — |
| onValueCommit | (value: number[]) => voidCalled when the value settles (pointer up / key release). | — |
| min | numberMinimum value. | 0 |
| max | numberMaximum value. | 100 |
| step | numberStepping interval. | 1 |
| minStepsBetweenThumbs | numberMinimum steps between adjacent thumbs. | 0 |
| orientation | 'horizontal' | 'vertical'Slider axis. | 'horizontal' |
| disabled | booleanDisable the slider. | false |
| dir | 'ltr' | 'rtl'Reading direction. | — |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |
Keyboard interactions
Adheres to the WAI-ARIA design pattern .
| Key | Description |
|---|---|
| ArrowRight / ArrowUp | Increases the value by the step amount. |
| ArrowLeft / ArrowDown | Decreases the value by the step amount. |
| Home / End | Sets the value to its minimum / maximum. |
| PageUp / PageDown | Increases / decreases by a larger step. |