Range sliderPro
Two-thumb range with value bubbles and an optional live histogram.
Price per night
219 stays
$120$360
When to use
- Filtering by a range: price, dates as numbers, sizes, scores.
When not to use
- One value: use a slider.
- Exact numbers: add inputs beside it.
Installation
Usage
Import it from @/components/ui/range-slider after installing.
example.tsx
import * as React from "react";
import { RangeSlider } from "@/components/ui/range-slider";
export function PriceFilter() {
const [range, setRange] = React.useState<[number, number]>([100, 400]);
return <RangeSlider aria-label="Price" min={0} max={600} step={10} value={range} onValueChange={setRange} format={(n) => `$${n}`} histogram={counts} />;
}API reference
RangeSlider
Two thumbs on one track, with bubbles while active and an optional histogram.
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue / onValueChange | [number, number] | – | Controlled or uncontrolled. |
| onValueCommit | ([number, number]) => void | – | Once per drag end or key press. |
| min / max / step / minGap | number | 0 / 100 / 1 / 0 | Range, snapping and minimum distance between thumbs. |
| format | (n) => string | String | Labels and aria-valuetext. |
| histogram | number[] | – | Bars spread evenly across the range; bars inside the selection highlight. |
Keyboard interactions
| Keys | Action |
|---|---|
| ←or↓ | Decrease the focused thumb |
| →or↑ | Increase |
| Page UporPage Down | 10% steps |
| HomeorEnd | Min or max |
Accessibility
- Each thumb is a labelled slider ("Price minimum", "Price maximum") whose limits respect the other thumb.
- Clicking the track moves the nearest thumb and focuses it.
Motion
- Histogram bars grow in a wave and change color as the range moves; thumbs grow while active; bubbles pop above them.
Responsive behavior
- Fills its container; touch drags work anywhere on the track.
Performance
- Drags use window listeners and only update the two values.
Notes for AI
- Fetch results in onValueCommit, not onValueChange.
This page as Markdown, for assistants and coding agents:
/components/range-slider/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt