Skip to content
Haze UI

Histogram range slider

Filter a numeric dataset with two native range inputs and a histogram that highlights the selected interval.

pnpm dlx shadcn@latest add @haze/range-histogram-slider
Open preview in a new tab
Livesmall script

When to use

  • People need to see how results are distributed before choosing a price or size band.
  • A filter should report how many supplied values fall inside the current interval.

When not to use

  • Use range-slider when there is no underlying distribution to show.
  • Use window-range when the selection moves across an ordered time series.

Installation

Add the Haze registry to components.json once, then install Histogram range slider with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/range-histogram-slider
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller supplied prefix for the control and its associated content.
labelstringNightly budgetLegend describing this numeric filter.
datanumber[]Demo nightly budgetsFinite numeric observations to bin; values outside the domain are excluded.
binsnumber16Histogram resolution, limited to 4–40 bins.
minnumber0Smallest filterable observation.
maxnumber200Largest filterable observation.
stepnumber5Increment of both native range controls.
lowernumber–Initial lower edge; clamped into the domain.
uppernumber–Initial upper edge; never starts below the lower edge.
lowerNamestringid-lowerForm name for the minimum input.
upperNamestringid-upperForm name for the maximum input.
unitstringcreditsUnit spoken by each bound and shown in its value.
disabledbooleanfalsePrevents user changes through the native disabled state.
classstring–Additional classes on this component's outer wrapper.

Keyboard interactions

Tab
Move between the minimum and maximum inputs.
Arrow keysHomeEnd
Adjust the focused range bound using native behavior.

Accessibility

  • The decorative histogram stays outside the accessibility tree; separate Minimum and Maximum inputs expose the selected values.
  • The result count is announced when a change commits, rather than flooding the live region on every drag frame.
  • RangeSlider prevents the enhanced bounds from crossing; without script both named native inputs remain usable.
  • Bars use the supplied observations and selected interval, so empty datasets render an empty distribution with zero matches.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Histogram range slider" with `npx shadcn@latest add @haze/range-histogram-slider`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import RangeHistogramSlider from "@/components/haze/ui/range-histogram-slider.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/range-histogram-slider.md

  • Customize with real content

    Adapt the Haze range-histogram-slider ui for our product. Replace the demo values of these props with our real content: id, label, data, bins, min, max, step, lower, upper, lowerName, upperName, unit, disabled, class. Keep the layout, the heading level rules and these accessibility details: The decorative histogram stays outside the accessibility tree; separate Minimum and Maximum inputs expose the selected values. The result count is announced when a change commits, rather than flooding the live region on every drag frame. RangeSlider prevents the enhanced bounds from crossing; without script both named native inputs remain usable. Bars use the supplied observations and selected interval, so empty datasets render an empty distribution with zero matches. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using range-histogram-slider, check it fits: use it when people need to see how results are distributed before choosing a price or size band.; a filter should report how many supplied values fall inside the current interval.. Avoid it when use range-slider when there is no underlying distribution to show.; use window-range when the selection moves across an ordered time series.. Alternatives: @haze/range-slider, @haze/window-range, @haze/slider.

Dependencies

  • @haze/range-slider
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog