React Range Slider
A glass React slider that picks a single value or a range by dragging, clicking the track or pressing the arrow keys. Use Slider as a React slider component for a volume or brightness control where people want to drag and hear or see the change as they go, and exact digits matter less than feel.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/slider.jsonBrightness
SliderdefaultSliderLabels
Using it in a form? See the react-hook-form and zod recipe.
Single value and range
Volume
Price range
import { useState } from "react";
import { Slider } from "@/components/sheenui/slider/slider";
// Package build (after the first npm release, or a packed tarball): import { Slider } from "@sheenui/theme";
export function Example() {
const [volume, setVolume] = useState(40);
return (
<>
<Slider label="Volume" value={volume} onValueChange={(v) => setVolume(Array.isArray(v) ? (v[0] ?? 0) : v)} />
<Slider label="Price range" defaultValue={[200, 800]} min={0} max={1000} step={10} />
</>
);
}Files to copy
5 folders · 4 files · 3 packages
- From
theme/src/ components/slider/components/field/hooks/use-latest.tslib/{cn.ts, form.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/slider.jsonRegistry item: slider. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx tailwind-merge
Step, bounds and states
Temperature
Locked
import { Slider } from "@/components/sheenui/slider/slider";
// Package build (after the first npm release, or a packed tarball): import { Slider } from "@sheenui/theme";
export function Example() {
return (
<div className="flex w-full max-w-sm flex-col gap-6">
<Slider label="Temperature" min={16} max={30} step={0.5} defaultValue={21.5} />
<Slider aria-label="Brightness" defaultValue={70} showValue={false} />
<Slider label="Locked" defaultValue={40} disabled />
</div>
);
}Props
SliderLabels keys and English defaults (2)
Keyboard
Accessibility
- Each thumb is role="slider" with aria-valuenow, aria-valuemin and aria-valuemax; a range slider has one thumb per value.
- The label names the group; the value text is announced as it changes.
- The track is 44 px tall on touch screens and its edge has a 3:1 border; a value bubble shows above the thumb while dragging.
All exports on this page
Slider— A slider for picking a number (volume, price) or a range between two numbers.defaultSliderLabels— The English SliderLabels used when labels is omitted; a partial labels prop is merged over it.
When to use Slider
- Use Slider for a price range filter, a zoom level or an audio volume, where a thumb on a track is quicker than typing; pair it with a visible value when the exact number matters. For a dual range slider in Tailwind, pass two values and the component draws two thumbs on one track.
- Use two values for a price range filter on a product list, with minStepsBetweenValues keeping the thumbs from crossing and the bubble showing the value above the thumb while dragging.
- Use onValueCommitted to save a setting once when the drag or key press ends, rather than firing a request on every step of onValueChange.
- Skip it when people must enter an exact figure, where NumberField fits, or when there are three or four named choices, where SegmentedControl or RadioGroup is clearer.
- Pair it with NumberField for a typed fallback, Field to describe the range, and Button to apply the filter after the range is chosen.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .