Skip to content

Components

Slider

A range slider with a glass thumb: a small pill at rest that opens into a wide lens while you hold it.

Latest changeImprovedv1.3.8A color prop for the filled part of the track. The examples are now the slider in a few colours, nothing else.
  1. v1.3.8ImprovedA color prop for the filled part of the track. The examples are now the slider in a few colours, nothing else.
  2. v1.3.3ImprovedExamples for the four sizes, a range of its own with min, max and step, icons, and clear glass at rest.
  3. v1.3.0NewThe range slider of the first previews: a glass pill that opens into a wide lens while held.
  4. All changes →
range-slider.tsx
40

Use it for

  • Picking a value on a continuous range: volume, brightness, opacity.

Not for

  • Exact numbers the user must type: use a number input.
  • Confirming one action: that is Slide to Confirm.

Installation

npx shadcn@latest add https://onemorethink.dev/r/slider.json

Slider, Switch and Checkbox are drawn by their own renderer, which needs three, and take their behaviour (keyboard, the label, the input a form reads) from UI SDK: @ui-sdk/core and @ui-sdk/react. The install command adds all three; UI SDK is in beta, so it is added at the exact version this was built on.

Usage

app.tsx
import { RangeSlider } from '@/components/liquid-glass/controls/RangeSlider'

const [volume, setVolume] = useState(60)

<RangeSlider label="Volume" value={volume} onChange={setVolume} />

Drag the glass, or press the track to bring it there. While held, the pill swells into a clear lens that bends the track and the fill beneath it, and squashes and stretches with its speed; released, it springs back to the small pill.

API reference

PropTypeDefault
value

Current value.

number50
onChange

Called with the new value.

(value: number) => void—
min / max / step

The range and its step.

number0 / 100 / 1
label

Label above the track; an empty string hides it.

string'Volume'
name

Submits the value under this name with the form around it.

string—
showValue

Shows the value next to the label.

booleantrue
size

Track height 8, 12, 18 or 26 px; the glass scales with it.

'sm' | 'md' | 'lg' | 'xl''md'
startIcon / endIcon

Icons at either end of the track.

IconName | 'none''none'
color

The filled part of the track: a hex, rgb() or named colour, not a CSS variable.

string'#3291FF'
theme

Overrides the page theme for this slider.

'light' | 'dark'—
restFrost

The thumb at rest: 1 = a white pill, 0 = clear glass. Held, it is always clear glass.

number1
refraction

How far the lens bends what lies beneath.

number37
dispersion / rimIntensity / magnification

Colour fringing, rim light and zoom of the lens.

number0.12 / 0.55 / 0
motionStretch / motionSmoothing

Squash and stretch with speed; how tightly the glass follows.

number3 / 30
pressSpeed / pressBounce

The spring that opens and closes the lens.

number16 / 0.4

Accessibility

  • A native range input does the work: arrow keys, Home, End and Page Up / Down, and screen readers announce the value.
  • The label names the input.
  • With reduced motion the glass follows without springs.