Pick a number, or a low–high range, by dragging.
Default
A labelled slider; arrow keys, Page Up/Down, Home and End all work.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add sliderIt needs no other component. The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/slider.tsx.
import { Slider, RangeSlider } from "@/design-system/components/slider";Usage
<RangeSlider label="Price range" min={0} max={1000} step={50} value={price} onValueChange={setPrice} formatValue={(n) => `$${n}`} />Examples
Value bubble
showTooltip puts the formatted value in a bubble above the thumb.
Value and range
showValue prints the current value, showMinMax shows the ends, and formatValue formats both for people and screen readers.
Controlled
Hold the value in state with value and onValueChange when other UI depends on it.
Brand refresh for Denzing: about 3 working days.
Range
RangeSlider picks a low and a high value and the thumbs can't cross. Here a price filter in steps of $50.
Showing studios that quote between $200 and $800.
Disabled
Visible but locked, e.g. a budget only the owner can change.
Disabled range
A locked range keeps showing its values, in neutral.
When to use
Use it when
- An approximate value in a known range: opacity, volume, budget share, hours
- A low–high filter such as a price or a delivery window (RangeSlider)
Don’t use it when
- An exact number matters → Field and inputs (Input type=number)
- Two values that don't form a range → two Sliders
Rules
- Show the value (showValue or showTooltip) when it isn't obvious
- Format with formatValue so the bubble, the label row and screen readers agree
- Save on onValueCommit (pointer up, key press), not on every onValueChange
- RangeSlider thumbs can't cross; they can meet
Properties
Slider
| Prop | Type | Default |
|---|---|---|
value | number | – |
defaultValue | number | – |
min | number | 0 |
max | number | 100 |
step | number | – |
onValueChange | (value: number) => void | – |
onValueCommit | (value: number) => void | – |
onChange | ComponentProps<"input">["onChange"] | – |
label | ReactNode | – |
showValue | boolean | – |
showMinMax | boolean | – |
showTooltip | boolean | false |
formatValue | (value: number) => string | String |
RangeSlider
| Prop | Type | Default |
|---|---|---|
value | [number, number] | – |
defaultValue | [number, number] | [min, max] |
min | number | 0 |
max | number | 100 |
step | number | 1 |
onValueChange | (value: [number, number]) => void | – |
onValueCommit | (value: [number, number]) => void | – |
label | ReactNode | – |
aria-label | string | – |
showTooltip | boolean | true |
formatValue | (value: number) => string | String |
disabled | boolean | – |
id | string | – |
name | string | – |
className | string | – |
* required
Accessibility
- One native range input per thumb: arrows, Page Up/Down, Home/End, forms and screen readers work
- Pass label or aria-label; formatValue feeds aria-valuetext
- RangeSlider thumbs are named "<label> Minimum" and "<label> Maximum"