Skip to content
Haze UI

Movable window range

Choose and pan an indexed data window with bounded edges, a chart overview and native range controls.

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

When to use

  • A report needs a contiguous window within an ordered set of observations.
  • People should move a complete interval while preserving its current length.

When not to use

  • Use date-range-picker for calendar dates without an indexed series.
  • Use range-histogram-slider for a numeric distribution whose observations are unordered.

Installation

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

pnpm dlx shadcn@latest add @haze/window-range
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.
labelstringReporting windowLegend for the reporting interval.
datanumber[]Demo activity seriesOrdered nonnegative chart values; invalid observations become zero.
labelsstring[]Day 1, Day 2, …Optional accessible names for each data index.
startnumber5Initial zero based start index.
endnumber14Initial zero based end index.
minSpannumber1Smallest permitted distance between the two indices.
maxSpannumberdata.length - 1Largest permitted distance between the two indices.
startNamestringid-startSubmitted start index field name.
endNamestringid-endSubmitted end index field name.
disabledbooleanfalsePrevents user changes through the native disabled state.
classstring–Additional classes on this component's outer wrapper.

Keyboard interactions

Tab
Reach start, end and move window controls in order.
ArrowsHomeEnd
Resize the focused edge or pan the current interval.

Accessibility

  • The start, end and enhanced whole window control are real range inputs; each edge announces its supplied point label.
  • Dynamic native bounds express the minimum and maximum interval length without allowing the edges to cross.
  • A whole window control mirrors chart dragging, so selecting or panning never requires a pointer.
  • Pointer cancellation restores both original indices, vertical gestures remain page scrolls, and commits announce the complete selected interval.
  • Empty data becomes a single zero point; a one point series disables panning rather than dividing by zero.

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 "Movable window range" with `npx shadcn@latest add @haze/window-range`. 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 WindowRange from "@/components/haze/ui/window-range.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/window-range.md

  • Customize with real content

    Adapt the Haze window-range ui for our product. Replace the demo values of these props with our real content: id, label, data, labels, start, end, minSpan, maxSpan, startName, endName, disabled, class. Keep the layout, the heading level rules and these accessibility details: The start, end and enhanced whole window control are real range inputs; each edge announces its supplied point label. Dynamic native bounds express the minimum and maximum interval length without allowing the edges to cross. A whole window control mirrors chart dragging, so selecting or panning never requires a pointer. Pointer cancellation restores both original indices, vertical gestures remain page scrolls, and commits announce the complete selected interval. Empty data becomes a single zero point; a one point series disables panning rather than dividing by zero. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using window-range, check it fits: use it when a report needs a contiguous window within an ordered set of observations.; people should move a complete interval while preserving its current length.. Avoid it when use date-range-picker for calendar dates without an indexed series.; use range-histogram-slider for a numeric distribution whose observations are unordered.. Alternatives: @haze/range-slider, @haze/range-histogram-slider, @haze/date-range-picker.

Dependencies

  • @haze/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