Skip to content
Haze UI

Elastic slider

A native slider with a yielding track, live value and keyboard reachable preset stops.

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

When to use

  • Volume, intensity or a similar continuous setting benefits from subtle resistance at the limits.
  • A few common values should be reachable directly as named presets.

When not to use

  • Use slider for a plain compact range without preset buttons.
  • Use range-slider when users choose both bounds of an interval.

Installation

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

pnpm dlx shadcn@latest add @haze/elastic-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.
namestringidName submitted by the native form control.
labelstringPlayback volumeVisible label for the range input.
minnumber0Lower bound of the domain.
maxnumber100Upper bound of the domain.
stepnumber1Native range increment.
valuenumber60Initial setting, clamped to the supplied domain.
unitstring%Suffix used in the readout and accessible value.
marks{ value: number; label: string }[]Mute / Half / FullNamed native datalist stops with enhanced shortcut buttons.
disabledbooleanfalsePrevents user changes through the native disabled state.
classstring–Additional classes on this component's outer wrapper.
[key: string]unknown–Other native range attributes are passed through to Slider.

Keyboard interactions

ArrowsHomeEnd
Adjust the native range or reach either end.
Tab, EnterSpace
Focus and apply one of the named stops.

Accessibility

  • The real range input remains the only slider and provides native keyboard behavior and forced color support.
  • The datalist works without enhancement; preset buttons are enabled only after their handlers are ready.
  • The visible readout is hidden from assistive technology because aria-valuetext supplies the same value with its unit.
  • Track displacement is capped at eight pixels and is skipped for reduced motion; cancellation releases the transient displacement.

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 "Elastic slider" with `npx shadcn@latest add @haze/elastic-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 ElasticSlider from "@/components/haze/ui/elastic-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/elastic-slider.md

  • Customize with real content

    Adapt the Haze elastic-slider ui for our product. Replace the demo values of these props with our real content: id, name, label, min, max, step, value, unit, marks, disabled, class, [key: string]. Keep the layout, the heading level rules and these accessibility details: The real range input remains the only slider and provides native keyboard behavior and forced color support. The datalist works without enhancement; preset buttons are enabled only after their handlers are ready. The visible readout is hidden from assistive technology because aria-valuetext supplies the same value with its unit. Track displacement is capped at eight pixels and is skipped for reduced motion; cancellation releases the transient displacement. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using elastic-slider, check it fits: use it when volume, intensity or a similar continuous setting benefits from subtle resistance at the limits.; a few common values should be reachable directly as named presets.. Avoid it when use slider for a plain compact range without preset buttons.; use range-slider when users choose both bounds of an interval.. Alternatives: @haze/slider, @haze/range-slider, @haze/ruler-slider.

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