About the shadcn/ui Slider Component

The Slider component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add slider` and copy it directly into your project.

Slider Component — Frequently Asked Questions

How do I create a price range slider with two handles?

Use `defaultValue={[20, 80]}` (an array) on `<Slider>`. The component supports multiple thumbs when the value array has more than one element.

How do I use shadcn Slider with React Hook Form?

Wrap in `<Controller>`: `<Controller name="volume" render={({ field }) => <Slider value={[field.value]} onValueChange={([v]) => field.onChange(v)} />}`.

How do I display the current slider value next to the handle?

Read the value from state and render it beside the slider. Add `onValueChange={(v) => setValue(v[0])}` to track the current value and display it.

Slider Component - shadcn/ui Examples | Shadcn Store