Slider
Slide to a number: nights, a budget, a distance (Radix Slider).
Preview
Nights
Budget per night
Usage
import { Slider } from "zostel-ui";
const [nights, setNights] = useState([3]);
<Slider value={nights} onValueChange={setNights} min={1} max={14} step={1} aria-label="Nights" />
{/* a range: two values, two thumbs, heard as "Budget per night minimum" and "… maximum" */}
<h3 id="budget">Budget per night</h3>
<Slider value={budget} onValueChange={setBudget} min={0} max={5000} step={100} aria-labelledby="budget" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue | number[] | — | One number per thumb. |
onValueChange | (value: number[]) => void | — | Called while sliding. |
min | number | 0 | Lowest value. |
max | number | 100 | Highest value. |
step | number | 1 | Step size. |
disabled | boolean | false | Greys it out. |
aria-label · aria-labelledby | string | — | Its name, required (a slider can’t take a <Label htmlFor>). It goes on each thumb, where a screen reader lands; a range’s thumbs add which end they are (“Nights minimum”, “Nights maximum”). In development, a thumb with no name warns in the console. |
thumbLabels | [string, string] | — | A range (two values, two thumbs): each thumb’s own name, e.g. ["Fewest nights", "Most nights"], instead of the slider’s name with minimum and maximum. |
className | string | — | More classes, merged with the component’s own (tailwind-merge). |
value / defaultValuenumber[]One number per thumb.
onValueChange(value: number[]) => voidCalled while sliding.
minnumber0Lowest value.
maxnumber100Highest value.
stepnumber1Step size.
disabledbooleanfalseGreys it out.
aria-label · aria-labelledbystringIts name, required (a slider can’t take a <Label htmlFor>). It goes on each thumb, where a screen reader lands; a range’s thumbs add which end they are (“Nights minimum”, “Nights maximum”). In development, a thumb with no name warns in the console.
thumbLabels[string, string]A range (two values, two thumbs): each thumb’s own name, e.g. ["Fewest nights", "Most nights"], instead of the slider’s name with minimum and maximum.
classNamestringMore classes, merged with the component’s own (tailwind-merge).