Slider
Data inputA value picked by dragging a thumb along a track, or with the arrow keys (Page Up and Down for big steps, Home and End for the ends): type="single" binds a number, type="multiple" a number[] with one thumb each (a range). min, max, step, orientation. Inside a Field the thumbs are named by Field.Label and described by its description and error; outside one, give each thumb a name with aria-label.
import { Slider } from '@limerdev/zest'; Input type="number". Few options: use RadioGroup or ToggleGroup.Examples
Basic
In a Field, the label names the thumb. Arrow keys move by step.
80% of logged time is billed.
<script lang="ts">
import { Field, Slider } from '@limerdev/zest';
let share = $state(80);
</script>
<Field.Root class="w-full max-w-sm">
<Field.Label>Billable share</Field.Label>
<Slider type="single" bind:value={share} max={100} step={5} />
<Field.Description>{share}% of logged time is billed.</Field.Description>
</Field.Root> A range
type="multiple" picks a range with two thumbs; name each thumb outside a Field.
Projects with 20–60 hours logged
<script lang="ts">
import { Slider } from '@limerdev/zest';
let hours: number[] = $state([20, 60]);
</script>
<div class="grid w-full max-w-sm gap-3">
<p class="text-sm font-medium">Projects with {hours[0]}–{hours[1]} hours logged</p>
<Slider type="multiple" bind:value={hours} max={100} aria-label="Hours logged" />
</div> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Slider
| Prop | Type | Default | Description |
|---|---|---|---|
| autoSort | boolean | true | Whether to automatically sort the values in the array when moving thumbs past one another. |
| dir | "ltr" | "rtl" | 'ltr' | The direction of the slider. For vertical sliders, setting dir to 'rtl' will caus the slider to start from the top and move downwards. For horizontal sliders, setting dir to 'rtl' will cause the slider to start from the left and move rightwards. |
| disabled | boolean | false | Whether the slider is disabled or not. |
| max | number | 100 (for number step) or the max value of the step array (for array step) | The maximum value of the slider. |
| min | number | 0 (for number step) or the min value of the step array (for array step) | The minimum value of the slider. |
| onValueChange | OnChangeFn<number> | OnChangeFn<number[]> | – | A callback function called when the value changes. |
| onValueCommit | OnChangeFn<number> | OnChangeFn<number[]> | – | A callback function called when the user stops dragging the thumb and the value is committed. |
| orientation | "horizontal" | "vertical" | 'horizontal' | The orientation of the slider. |
| step | number | number[] | 1 | The amount to increment the value by when the user presses the arrow keys, or an array of specific values that the slider can snap to. When an array is provided, the slider will only allow values that exist in the array, creating discrete tick points. The array values should be within the min/max range and will be automatically sorted. |
| thumbPositioning | "exact" | "contain" | "contain" | The positioning of the slider thumb. |
| trackPadding | number | – | Padding percentage for the track. Creates space before the first and after the last tick positions. This can also be used as an SSR-friendly alternative to thumbPositioning="contain", which requires client-side measurement. |
| type required | "multiple" | "single" | – | The type of slider. If set to 'multiple', the slider will allow multiple ticks and the value will be an array of numbers. |
| value bindable | number | number[] | min | The value of the slider. |