---
title: "Histogram Slider"
description: "A range slider with bars above it that show how the values spread. Use it for a price, size, or duration filter, with raw values or bin counts."
url: https://gelatinui.com/components/histogram-slider
markdown_url: https://gelatinui.com/components/histogram-slider.md
access: free
install: "npx shadcn@latest add @gelatin-ui/histogram-slider"
registry_item: https://gelatinui.com/r/histogram-slider.json
version: "2026-11-10"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Histogram Slider

> A range slider with bars above it that show how the values spread. Use it for a price, size, or duration filter, with raw values or bin counts.

Page: https://gelatinui.com/components/histogram-slider

## When to use it

Best for: A range filter where the spread of the values helps people pick the range.

- Use it for price, size, or duration filters.
- Use `counts` when a server sends ready bins, and `data` for raw values.

## When not to use it

- For a value with no data spread, use a [Slider](https://gelatinui.com/components/slider.md).

## Notes for agents

- It is the Slider with a bar strip in its control: every Slider prop works.
- Give the root an `aria-label`.
- Put `HistogramSliderControl` in the root; the ends, summary, and fields are optional parts.
- A press on a bar moves the nearest thumb to that point.
- Values past `max` count in the last bar: pass `end` to `HistogramSliderEnds` for an open end, such as "$1,000+".

## Anatomy

```text
HistogramSlider
├─ HistogramSliderControl (0..n)
├─ HistogramSliderBars (0..n)
├─ HistogramSliderEnds (0..n)
├─ HistogramSliderSummary (0..n)
└─ HistogramSliderInputs (0..n)
```

## API reference

### HistogramSlider

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `thumbProps` | `Omit<SliderThumbProps, "index">` |  | Props for every default thumb: `getAriaLabel`, `getAriaValueText`, `aria-label`, `disabled`. |
| `tone` | `TrackTone` |  | `default`: the `primary` fill. A status colors the fill and the thumb edge: `success` a good value, `warning` a value that needs care, `info` a neutral mark, `destructive` a value over a limit. Color is never the only signal: say it in words too. |
| `glow` | `boolean` |  | A soft halo in the fill color (`glow`, `@gelatin-ui/glow`). Default: `false`. |
| `data` | `readonly number[]` |  | Raw values (prices, sizes), counted into `bins` bins from `min` to `max`. |
| `counts` | `readonly number[]` |  | Ready bin counts from `min` to `max`, when the server counts them. Wins over `data`. |
| `bins` | `number` | 32 | The number of bins for `data`. Default 32. |
| `size` | `"default" \| "lg" \| "sm"` | "default" | The bar area height: `sm` 32, `default` 48, `lg` 64px. |
| `readOnly` | `boolean` | false | No change from the pointer, the keys, or the fields. The bars still show. |
| `onValueChange` | `function` |  |  |
| `onValueCommitted` | `function` |  |  |
| `labels` | `Partial<HistogramSliderLabels>` |  | The words (`HISTOGRAM_SLIDER_LABELS`), to translate them. Keep the object stable. |

Also takes every prop of Base UI `Slider.Root`: https://base-ui.com/react/components/slider

### HistogramSliderControl

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### HistogramSliderBars

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### HistogramSliderEnds

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `start` | `ReactNode` |  | The start label. Default: `min` in the root `format`. |
| `end` | `ReactNode` |  | The end label. Default: `max` in the root `format` (pass "$1,000+" for an open end). |

### HistogramSliderSummary

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `function` |  | The text. Default: "84 of 212", and "120 – 140 · 6" while the pointer is on a bar. Pass a function to name the things ("84 of 212 stays"). |

### HistogramSliderInputs

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| HistogramSlider | `histogram-slider` |  |  |  |
| HistogramSliderControl | `histogram-slider-control` |  |  |  |
| HistogramSliderBars | `histogram-slider-bars` |  | `--bar-strip-cut`, `--bar-strip-scale` |  |
| HistogramSliderEnds | `histogram-slider-ends` | `data-disabled` |  |  |
| HistogramSliderSummary | `histogram-slider-summary` |  |  |  |
| HistogramSliderInputs | `histogram-slider-inputs` |  |  |  |

## Usage

Import Histogram Slider and compose its parts.

```tsx title="histogram-slider.tsx"
import { HistogramSlider, HistogramSliderControl, HistogramSliderSummary } from "@/components/ui/histogram-slider";

/** Nightly prices of 412 stays in Lisbon, in €50 buckets from €0 to €500. */
const PRICES = [6, 18, 41, 72, 88, 69, 51, 33, 22, 12];

export function PriceFilter() {
  return (
    <HistogramSlider data={PRICES} min={0} max={500} defaultValue={[100, 300]} aria-label="Price per night">
      <HistogramSliderControl />
      <HistogramSliderSummary>
        {({ inRange, total }) => {
          return `${inRange} of ${total} stays`;
        }}
      </HistogramSliderSummary>
    </HistogramSlider>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/histogram-slider
```

It adds 39 registry items: 35 files, 5949 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `clsx`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Field](https://gelatinui.com/components/field.md)
- [Number Field](https://gelatinui.com/components/number-field.md)
- [Slider](https://gelatinui.com/components/slider.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Field](https://gelatinui.com/components/field.md)
- [Number Field](https://gelatinui.com/components/number-field.md)
- [Slider](https://gelatinui.com/components/slider.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Move the focused thumb by one step. |
| Page Up, Page Down | Move the focused thumb by `largeStep`. |
| Home, End | Move the focused thumb to the minimum or the maximum. |

## Accessibility

Each thumb is a native range input. In a range they are named Minimum and Maximum; translate the names with `labels`.

The value text of a thumb adds the count in range, such as "$120, 84 of 212 in range".

The bars are a picture and are hidden from screen readers; the summary says the same count.

The Min and Max fields commit on Enter or blur, so the thumb does not jump while you type.

## Motion

| Part | Motion |
| --- | --- |
| New data | panel · each bar grows or shrinks from its old height |
| Drag | none · the bright bars follow the thumbs with no transition |
