Date picker
npx shadcn add @klarhimmel/date-picker @klarhimmel/inputCopy for AIExamples
Basic
Preselected
Limits
Invalid, with an error message
Disabled
Form
DetailsAbout, usage, props and more
A date field you can type or pick: the text takes ISO or day-first, the button opens the calendar in a dialog.
When to use
Use for
A date in a form: arrival, departure, a birthday, a due date.
Not for
A time of day or a range in one control. Use two Date pickers.
Pairs with
Field, Calendar, Button.
Preview
Type 2026-11-16 or 16/11/2026, or press the calendar button.
No date yet.
Import
Import
- Files
- date-picker.tsx, input.tsx, in components/klarhimmel/ui/. With it: button, calendar, editing, input-group and 3 more. npm: lucide-react.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
- Limit
- Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The chosen day, "YYYY-MM-DD", or "" for none. |
defaultValue | string | '' | The day as 'YYYY-MM-DD'; '' means none. Typed text is read on Enter and when leaving the field. |
onValueChange | (value: string) => void | - | The day as 'YYYY-MM-DD'; '' means none. Typed text is read on Enter and when leaving the field. |
name | string | - | Submits the chosen day, as "YYYY-MM-DD", with a form (a hidden input). |
id | string | - | |
placeholder | string | 'YYYY-MM-DD' | Shown while the field is empty. |
disabled | boolean | - | Error styling; switches it off. Unreadable text is marked invalid on its own. |
invalid | boolean | - | Error styling; switches it off. Unreadable text is marked invalid on its own. |
aria-label | string | - | Needed when no Field or <label htmlFor> names it. |
aria-labelledby | string | - | Needed when no Field or <label htmlFor> names it. |
aria-describedby | string | - | |
labels | { open: string; panel: string; previous: string; next: string; today: string;… | - | Words for the button, the panel, the calendar's buttons and the two messages. Pass them translated. |
className | string | - | Extra classes, merged after the component's own. |
min | string | - | The earliest and latest day that can be chosen. Other days are shown but cannot be picked. |
max | string | - | Days that cannot be chosen. Typing one is marked and explained in words. |
isDisabled | (iso: string) => boolean | - | Days that cannot be chosen. Typing one is marked and explained in words. |
today | string | - | Today, "YYYY-MM-DD". Marked with a ring and the word. Never read from the clock here, so it renders the same on the server. |
firstDay | 'mon' | 'sun' | - | Passed to the calendar. |
locale | string | - | Passed to the calendar. |
Accessibility
| Key | Does |
|---|---|
Type | 2026-11-16 or day first, 16/11/2026 |
Enter / leaving the field | Reads the text; wrong text is marked and explained |
Alt+Down on the field | Opens the calendar |
Enter / Space on the button | Opens the calendar on the chosen day |
Escape | Closes it and returns focus to the button |
Arrow keys, Page Up / Down | Move within the calendar (see Calendar) |
The WAI-ARIA date picker dialog. Choosing a day closes it and puts the ISO text in the field. A form gets the day as YYYY-MM-DD.
Accessibility