Skip to content
Haze UI

Lens range

Choose a numeric band on two native sliders with a magnified tick scale and named edge presets.

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

When to use

  • A selected band needs context from a fine scale and a few known reference points.
  • Named presets should move whichever range edge the person last focused.

When not to use

  • Use range-slider when the extra tick scale adds no useful context.
  • Use range-histogram-slider when the scale must show the data distribution.

Installation

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

pnpm dlx shadcn@latest add @haze/lens-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.
labelstringExperience bandLegend naming the selected band.
minnumber0Lower limit represented on the tick scale.
maxnumber20Upper limit represented on the tick scale.
stepnumber1Native increment for both edges.
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.
unitstringyearsUnit added to both accessible values.
presets{ value: number; label: string }[]Associate / Senior / PrincipalNamed values applied to the most recently focused edge.
disabledbooleanfalsePrevents user changes through the native disabled state.
classstring–Additional classes on this component's outer wrapper.

Keyboard interactions

Tab
Focus either bound or one of the named preset buttons.
EnterSpace
Apply the focused preset to the last focused edge.
Arrow keys
Adjust a range edge one step at a time.

Accessibility

  • The minimum and maximum are labelled native inputs; the tick magnification is a decorative reading aid.
  • Each preset is a normal button with a label and numeric value, and its result is clamped to the other edge.
  • Focus expands the nearby ticks just as editing does; reduced motion keeps all tick scales at their resting size.
  • Before an edge receives focus, presets apply to the minimum; the helper text makes this rule visible.

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

  • Customize with real content

    Adapt the Haze lens-range ui for our product. Replace the demo values of these props with our real content: id, label, min, max, step, lower, upper, lowerName, upperName, unit, presets, disabled, class. Keep the layout, the heading level rules and these accessibility details: The minimum and maximum are labelled native inputs; the tick magnification is a decorative reading aid. Each preset is a normal button with a label and numeric value, and its result is clamped to the other edge. Focus expands the nearby ticks just as editing does; reduced motion keeps all tick scales at their resting size. Before an edge receives focus, presets apply to the minimum; the helper text makes this rule visible. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using lens-range, check it fits: use it when a selected band needs context from a fine scale and a few known reference points.; named presets should move whichever range edge the person last focused.. Avoid it when use range-slider when the extra tick scale adds no useful context.; use range-histogram-slider when the scale must show the data distribution.. Alternatives: @haze/range-slider, @haze/range-histogram-slider, @haze/ruler-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