Slider

A glass knob that turns to liquid as you drag it.

Installation#

pnpmnpmyarnbun
$ pnpm dlx shadcn@latest add @liquikit/slider

Needs 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

PropTypeDefault
theme"light" | "dark"

Light or dark glass. Falls back to the nearest GlassThemeProvider, then light.

—
lensPartial<LensProfile>

Overrides for the lens profile, such as thickness, bevel, ior and magnification.

—
liquidnumber

How far the glass squashes and stretches as it moves. 0 keeps it rigid.

—
valuenumber

The current value, when you control it.

—
defaultValuenumber

The value it starts with, when it manages its own state.

—
onValueChange(value: number, eventDetails: BaseSlider.Root.ChangeEventDetails) => void

Called with the new value when the user changes it.

—
onValueCommitted(value: number, eventDetails: BaseSlider.Root.CommitEventDetails) => void

Called once the user lets go of the knob.

—
widthnumber

Width of the track, in pixels.

240
trackHeightnumber

Height of the track, in pixels.

—
thumbHeightnumber

Height of the glass knob, in pixels.

22
thumbWidthnumber

Width of the knob. Defaults to twice its height.

—
aria-labelstring

An accessible name, for controls without a visible label.

—

Also takes every prop of Base UI's slider, plus className and style.