Skip to content
Haze UI

Date picker

A compact native date field with a keyboard-navigable month grid in a popover.

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

When to use

  • A form needs a single date in less space than an inline calendar.
  • People may want to browse adjacent days before choosing a date.

When not to use

  • The user needs to set both ends of a date range.

Installation

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

pnpm dlx shadcn@latest add @haze/date-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 field and popover ID prefix.
namestringidSubmitted field name.
labelstringDateVisible native field label.
valuestring–Initial date as YYYY-MM-DD.
minstring–Earliest selectable date as YYYY-MM-DD.
maxstring–Latest selectable date as YYYY-MM-DD.
requiredboolean–Requires a date for form submission.
disabledboolean–Disables the field and its custom picker.
formstring–ID of an external form.
localestringenLocale used for the month grid.
weekStart0 | 11Shows Sunday or Monday first.
openLabelstringOpen calendarAccessible name for the calendar trigger and panel.
classstring–Classes on the outer wrapper.

Keyboard interactions

Arrow keys
Move by a day or a week inside the open grid.
EnterSpace
Choose the focused day.
Escape
Close the calendar without changing the field.
Space, F4 or AltDown in the field
Open the calendar.

Accessibility

  • The native date field remains usable with scripting disabled.
  • Opening from the button or the keyboard moves focus into the month grid; clicking the field opens it and keeps focus in the field for typing. Focus returns after choosing a date or pressing Escape.
  • The browser's own date popup never opens on top of the calendar.

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

  • Customize with real content

    Adapt the Haze date-picker ui for our product. Replace the demo values of these props with our real content: id, name, label, value, min, max, required, disabled, form, locale, weekStart, openLabel, class. Keep the layout, the heading level rules and these accessibility details: The native date field remains usable with scripting disabled. Opening from the button or the keyboard moves focus into the month grid; clicking the field opens it and keeps focus in the field for typing. Focus returns after choosing a date or pressing Escape. The browser's own date popup never opens on top of the calendar. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using date-picker, check it fits: use it when a form needs a single date in less space than an inline calendar.; people may want to browse adjacent days before choosing a date.. Avoid it when the user needs to set both ends of a date range.. Alternatives: @haze/calendar, @haze/date-range-picker, @haze/time-picker.

Dependencies

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