Skip to content
Haze UI

Date range picker

Two native date controls with a shared label and validation for an end date earlier than the start.

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

When to use

  • A report or export collects a start date and an end date
  • Native date pickers suit the device and locale

When not to use

  • Only one date is needed. Use input with type date.
  • Customers need a visual overview of unavailable dates throughout a calendar.

Installation

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

pnpm dlx shadcn@latest add @haze/date-range-picker
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 prefix for both field IDs and the validation message.
labelstring"Date range"Legend for the pair.
startstring–Initial start date in YYYY-MM-DD format.
endstring–Initial end date in YYYY-MM-DD format.
startNamestringid + -startSubmitted name for the start date.
endNamestringid + -endSubmitted name for the end date.
startLabelstring"Start"Start field label.
endLabelstring"End"End field label.
minstring–Earliest date for either field.
maxstring–Latest date for either field.
requiredboolean–Requires both dates.
disabledboolean–Disables both fields.
orderErrorstring"Choose an end date on or after the start date."Validation text for a reversed range.
startAttributesRecord<string, unknown>–Additional attributes for the start input.
endAttributesRecord<string, unknown>–Additional attributes for the end input.
classstring–Additional classes on the fieldset.

Keyboard interactions

Tab
Move between the date fields and their native controls.

Accessibility

  • The fieldset legend and each input label describe the two levels of the control.
  • The browser controls how each date picker opens and displays dates.
  • Validate the date order on the server as well. Without JavaScript both fields still submit.

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 "Date range picker" with `npx shadcn@latest add @haze/date-range-picker`. 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 DateRangePicker from "@/components/haze/ui/date-range-picker.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/date-range-picker.md

  • Customize with real content

    Adapt the Haze date-range-picker ui for our product. Replace the demo values of these props with our real content: id, label, start, end, startName, endName, startLabel, endLabel, min, max, required, disabled, orderError, startAttributes, endAttributes, class. Keep the layout, the heading level rules and these accessibility details: The fieldset legend and each input label describe the two levels of the control. The browser controls how each date picker opens and displays dates. Validate the date order on the server as well. Without JavaScript both fields still submit. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using date-range-picker, check it fits: use it when a report or export collects a start date and an end date; native date pickers suit the device and locale. Avoid it when only one date is needed. use input with type date.; customers need a visual overview of unavailable dates throughout a calendar.. Alternatives: @haze/input, @haze/field.

Dependencies

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