Histogram Range
Dual-thumb range slider combined with a distribution histogram bar chart.
$80 – $30026 of 44 results
26 of 44 results in selected range
Keyboard
- ←→
- Adjust the focused thumb by step
- ↑↓
- Adjust the focused thumb by step
- PageUpPageDown
- Adjust the focused thumb by larger step
- HomeEnd
- Set the focused thumb to min or max
Installation
The CLI also installs the npm packages and registry items it builds on, and reads the style in your components.json to pick the Base UI or Radix build.
Usage
"use client"
import { useState } from "react"
import { HistogramRange } from "@/components/ui/histogram-range"
const prices = [25, 45, 60, 75, 80, 110, 120, 150, 180, 220, 260, 310, 450]
export function PriceFilter() {
const [range, setRange] = useState<[number, number]>([50, 200])
return (
<HistogramRange
data={prices}
min={0}
max={500}
value={range}
onValueChange={setRange}
formatValue={(n) => `$${n}`}
minThumbLabel="Minimum price"
maxThumbLabel="Maximum price"
showValues
showCount
/>
)
}Examples
Basic price range
A dual-thumb range filter with dollar formatting and active result count.
$50 – $2508 of 13 results
8 of 13 results in selected range
Custom units and styling
File size filtering with megabytes formatting and chart color tokens.
10 MB – 100 MB8 / 14 files
8 / 14 files
API reference
HistogramRange
A dual-thumb range slider sitting below a distribution histogram bar chart. Highlights values in the selected range and mutes values outside.
| Prop | Type | Default |
|---|---|---|
datanumber[]Raw numeric dataset to distribute across histogram bins. | number[] | |
minnumberLower bound of the range. Defaults to min value in data, or 0. | number | |
maxnumberUpper bound of the range. Defaults to max value in data, or 100. | number | |
stepnumberDefault1Step increment of the slider thumbs. | number | 1 |
minStepsBetweenThumbsnumberDefault0Minimum number of steps required between the two thumbs. | number | 0 |
value[number, number]Controlled selected range. | [number, number] | |
defaultValue[number, number]Default[min, max]Initial value when uncontrolled. | [number, number] | [min, max] |
onValueChange(value: [number, number]) => voidCalled when the range changes during dragging or keyboard input. | (value: [number, number]) => void | |
onValueCommit(value: [number, number]) => voidCalled when pointer drag or keyboard interaction finishes. | (value: [number, number]) => void | |
binsnumberDefault24Number of discrete histogram buckets. | number | 24 |
formatValue(value: number) => stringFormats values for display and thumb aria-valuetext. | (value: number) => string | |
minThumbLabelstringDefault"Minimum"Accessible aria-label for the lower thumb. | string | "Minimum" |
maxThumbLabelstringDefault"Maximum"Accessible aria-label for the upper thumb. | string | "Maximum" |
showValuesbooleanDefaultfalseWhether to render current range values above the chart. | boolean | false |
showCountbooleanDefaultfalseWhether to render active item count above the chart. | boolean | false |
renderCount(selectedCount: number, totalCount: number) => React.ReactNodeCustom renderer for result count summary and live region. | (selectedCount: number, totalCount: number) => React.ReactNode | |
barHeightnumber | stringDefault64Height of the histogram chart area. | number | string | 64 |
barColorstringTailwind class for active bars inside the range (defaults to bg-primary). | string | |
mutedBarColorstringTailwind class for inactive bars outside the range (defaults to bg-muted-foreground/20). | string | |
disabledbooleanDefaultfalseWhether the slider thumbs are disabled. | boolean | false |
Other props go to the <div>.
buildHistogramBuckets
buildHistogramBuckets(options: BuildHistogramBucketsOptions): BuildHistogramBucketsResultPure logic helper in @/lib/histogram-range that buckets numeric data, normalizes bar heights, and calculates inRange statuses.