Components

Slider

The shadcn/ui Slider with a thumb that grows slightly while you drag it and range-slider labels for screen readers — plus two animated React slider blocks built with Motion and Radix: a slider with a floating value tooltip that leans slightly as you drag, and a stepped slider with tick marks that light up.

  • Drop-in shadcn API
  • Range & vertical
  • Keyboard accessible
  • Motion blocks

Installation

$ npx shadcn@latest add https://duskui.com/r/slider.json

Replaces components/ui/slider.tsx with the same API. The drag feedback is CSS, so the base needs no Motion; the root gets data-dragging while a pointer is down if you want to style around it.

Usage

volume.tsx
import { Slider } from "@/components/ui/slider"

export function Volume() {
  return <Slider defaultValue={[60]} max={100} step={1} aria-label="Volume" />
}

Examples

Default

Press and drag a thumb and it grows a little to show it's held. Arrow keys, Page Up/Down and Home/End work once it's focused.

Volume60%

Range & vertical

Pass two values for a range; minStepsBetweenThumbs keeps the thumbs apart and they're announced as “Price, minimum” and “Price, maximum”. Set orientation="vertical" and give it a height for a vertical slider.

Price$25 – $75

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Value Slider

A value bubble rides on each thumb. It springs up on hover, keyboard focus or drag, leans into the direction you're dragging (driven by the value's velocity, so nothing re-renders per frame) and settles upright when you stop. Format it with formatValue; the same text is announced via aria-valuetext.

$ npx shadcn@latest add https://duskui.com/r/value-slider.json
PropTypeDefaultDescription
value / defaultValuenumber[]—One value for a single thumb, two for a range.
onValueChange(value: number[]) => void—Called on every change.
formatValue(value: number) => string—Text in the bubble and for screen readers.
showBubble"interacting" | "always""interacting"Show the bubble only on hover, focus and drag, or all the time.
aria-labelstring—Accessible name; range thumbs get minimum / maximum appended.
...propsRadix Slider props—min, max, step, minStepsBetweenThumbs, disabled, onValueCommit…

Stepped Slider

A slider that snaps between named steps — plans, sizes, levels. Tick marks light up as the range passes them, the selected tick stretches, and clicking a label jumps to it. Values are strings, and name submits the selected step with a form.

Monthly requests

Billed monthly, cancel any time.

$49/mo

$ npx shadcn@latest add https://duskui.com/r/stepped-slider.json
PropTypeDefaultDescription
steps(string | { value: string; label: ReactNode; valueText?: string })[]—The choices, in order. Required.
value / defaultValuestring—The selected step's value.
onValueChange / onValueCommit(value: string) => void—Called on change, and when the user finishes changing it.
namestring—Submits the selected value with a form.
hideLabelsbooleanfalseShow only the tick marks.
aria-labelstring—Accessible name for the slider.

API Reference

Same as shadcn/ui: a single Slider that renders one thumb per value and forwards the Radix Slider props.

PropTypeDefaultDescription
value / defaultValuenumber[]—One value per thumb.
onValueChange / onValueCommit(value: number[]) => void—Called while dragging / when the drag or key press ends.
min / max / stepnumber0 / 100 / 1Range and increment.
minStepsBetweenThumbsnumber0Minimum gap between range thumbs, in steps.
orientation"horizontal" | "vertical""horizontal"Give vertical sliders a height.
aria-label / aria-labelledbystring—Forwarded to the thumbs (role="slider").

Accessibility

  • Built on Radix Slider: each thumb is a role="slider" with aria-valuemin, -max and -now, operable with arrows, Page Up/Down and Home/End.
  • Label sliders with aria-label or aria-labelledby; the base and blocks move the label onto the thumbs, where screen readers look for it.
  • Value Slider and Stepped Slider set aria-valuetext to the formatted value or step label, so “$240” or “50,000 requests” is read instead of a raw number.
  • Under prefers-reduced-motion thumbs resize instantly, the value bubble fades without leaning and ticks change without animating.