Skip to content
Haze UI

Number Field

Unified numeric input with joined -/+ steppers, unit label, boundary clamping, and horizontal label scrubbing.

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

When to use

  • Numeric settings where both precise typing and quick +/- adjustment help
  • Design parameters or limits that benefit from dragging the label to scrub values
  • Compact joined stepper bars in sm, md, or lg heights beside other form fields

When not to use

  • Simple cart item quantity without label scrubbing; use quantity-stepper
  • Continuous visual comparison between two bounds; use slider or range-slider

Installation

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

pnpm dlx shadcn@latest add @haze/number-field
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 id linking label, hint text, and stepper aria-controls.
namestring–Form submission name; defaults to id.
labelstring"Concurrency limit"Visible label and optional pointer-drag scrub handle.
valuenumber12Initial numeric value.
minnumber0Minimum allowed value.
maxnumber1000Maximum allowed value.
stepnumber1Increment step; holding Shift multiplies steps by 10.
unitstring–Optional unit suffix shown inside the center numeric cell.
scrubbooleantrueEnables horizontal pointer dragging on the label.
size"sm" | "md" | "lg""md"Control height aligned with Haze inputs and buttons.
requiredbooleanfalseMarks the native input as required.
disabledbooleanfalseDisables typing, scrubbing, and stepper buttons.
classstring–Extra classes on the outer field wrapper.

Keyboard interactions

UpDown
Step value inside the focused numeric input
ShiftClick (-) or ShiftDrag
Step by 10x the configured increment

Accessibility

  • Stepper buttons expose aria-controls and aria-disabled at min/max bounds so focus stays stable during rapid clicks.
  • Native <input type="number"> accepts keyboard typing and Up/Down arrows when scripts are off.
  • Every scrub adjustment also accepts keyboard Arrow keys and direct number entry.

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 "Number Field" with `npx shadcn@latest add @haze/number-field`. 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 NumberField from "@/components/haze/ui/number-field.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/number-field.md

  • Customize with real content

    Adapt the Haze number-field ui for our product. Replace the demo values of these props with our real content: id, name, label, value, min, max, step, unit, scrub, size, required, disabled, class. Keep the layout, the heading level rules and these accessibility details: Stepper buttons expose aria-controls and aria-disabled at min/max bounds so focus stays stable during rapid clicks. Native <input type="number"> accepts keyboard typing and Up/Down arrows when scripts are off. Every scrub adjustment also accepts keyboard Arrow keys and direct number entry. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using number-field, check it fits: use it when numeric settings where both precise typing and quick +/- adjustment help; design parameters or limits that benefit from dragging the label to scrub values; compact joined stepper bars in sm, md, or lg heights beside other form fields. Avoid it when simple cart item quantity without label scrubbing; use quantity-stepper; continuous visual comparison between two bounds; use slider or range-slider. Alternatives: @haze/quantity-stepper, @haze/scrub-input, @haze/slider.

Dependencies

  • npm: @lucide/astro
  • @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