Slider
A glass knob that turns to liquid as you drag it.
Installation#
$ pnpm dlx shadcn@latest add @liquikit/sliderNeeds the @liquikit registry in your components.json. Set it up once.
Usage#
import { Slider } from "@/components/liquikit/slider"<Slider defaultValue={40} width={280} aria-label="Volume" />The slider draws at a fixed width in pixels, because the lens is traced for that size. Measure the container if you need it to fill one.
Examples#
Controlled#
64%
Sizes#
thumbHeight and trackHeight resize the knob and the track.
API Reference#
Slider
| Prop | Type | Default |
|---|---|---|
theme | "light" | "dark"Light or dark glass. Falls back to the nearest | — |
lens | Partial<LensProfile>Overrides for the lens profile, such as | — |
liquid | numberHow far the glass squashes and stretches as it moves. | — |
value | numberThe current value, when you control it. | — |
defaultValue | numberThe value it starts with, when it manages its own state. | — |
onValueChange | (value: number, eventDetails: BaseSlider.Root.ChangeEventDetails) => voidCalled with the new value when the user changes it. | — |
onValueCommitted | (value: number, eventDetails: BaseSlider.Root.CommitEventDetails) => voidCalled once the user lets go of the knob. | — |
width | numberWidth of the track, in pixels. | 240 |
trackHeight | numberHeight of the track, in pixels. | — |
thumbHeight | numberHeight of the glass knob, in pixels. | 22 |
thumbWidth | numberWidth of the knob. Defaults to twice its height. | — |
aria-label | stringAn accessible name, for controls without a visible label. | — |
Also takes every prop of Base UI's slider, plus className and style.