Components

Slider

A custom range control with squircle corners, animated numeric readout, rubber-band overscroll, and optional in-fill label.

pnpx shadcn@latest add https://blog.skxv.dev/r/slider.json
Volume
Volume

Installation

Add the Slider and its package dependencies with one command:

pnpx shadcn@latest add https://blog.skxv.dev/r/slider.json

Usage

import { Slider } from "@/components/registry/slider";

<Slider
  value={volume}
  onChange={(event) => setVolume(Number(event.target.value))}
  min={0}
  max={100}
  step={1}
/>;

Forward a ref to receive the hidden native input[type=range] for forms and imperative access.

API Reference

Extends InputHTMLAttributes<HTMLInputElement> except type, value, and defaultValue (numeric).

PropTypeDefaultDescription
valuenumber-Controlled value. Pair with onChange.
defaultValuenumber-Initial value when uncontrolled.
minnumber0Minimum value.
maxnumber100Maximum value.
stepnumber1Step interval for keyboard and snapping.
labelstring-Optional label inside the fill. Truncates when narrow.
prefixstring''Text shown before the value, such as $.
suffixstring''Text shown after the value, such as % or px.
tickSpacingnumber15Minimum px between visible stepper ticks.
showTicksbooleantrueShow stepper tick marks along the bottom edge.
showValuebooleantrueShow the animated numeric readout on the right.
size'default' | 'small'defaultSmall hides ticks, label, and value. Use aria-label for accessibility.
snapToStepsbooleanfalseTween the fill and readout to each step when crossing detents.
cornersSmoothCornerOptions-Lisse squircle settings.
disabledbooleanfalseDisables interaction.
readOnlybooleanfalsePrevents value changes while keeping focus styles.
onChange / onInputChangeEventHandler-Standard range input handlers. event.target.value is the numeric string.
className / stylestring / CSSProperties-Applied to the interactive track shell. Use w-full to grow; min width is 12rem.

Examples

Default

Uncontrolled slider with default min, max, and step.

Controlled

Use value and onChange for controlled state.

Disabled

Use disabled to disable the slider.

Brightness
Brightness

Prefix & Suffix

Optional prefix and suffix text before and after the animated value.

Monthly budget
Monthly budget
Volume
Volume

Tick controlling

Use showTicks to control the visibility of the ticks. The amount of ticks are automatically calculated based on the min, max, step, and tickSpacing props.

Slider width
Slider width
Tick spacing
Tick spacing
Result
Result

Snap to Steps

Use snapToSteps when the fill and readout should animate between discrete detents.

Detented
Detented

Minimal

Use showTicks={false} and showValue={false} for a quieter control while keeping the native range input accessible.

Custom Corners

Pass corners to tune the Lisse squircle radius, smoothing, and curve.

Soft corner
Soft corner

Label

Use label to add a label to the slider. The label automatically truncates when the slider is too small.

Slider width
Slider width
This is an example of a label that is too long and will be truncated
This is an example of a label that is too long and will be truncated

Small

Use size="small" to hide the ticks, label, and value readout, and make the slider smaller.

Read Only

Use readOnly to prevent value changes without removing focus styles.

Locked
Locked