Date picker
A button that opens a calendar in a popover, or a bottom sheet on phones, for single dates and ranges.
- Form components
- 2 parts
- 10 examples
@tabler/icons-reactreact-day-picker
See it in a real product: API keys and Discount Builder
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/date-picker.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react @tabler/icons-react class-variance-authority cn react-day-pickerCopy and paste the following code into your project.
components/ui/date-picker.tsx components/ui/calendar.tsx components/ui/popover.tsx components/ui/sheet.tsx components/ui/button.tsx lib/motion.ts Update the import paths to match your project setup.
On screens narrower than 640px the calendar opens in a bottom sheet instead of a popover, so days stay large enough to tap.
Pass value and onValueChange. Cleared values are null. The calendar always opens on the month of the selected date, and picking a day closes it and returns focus to the button.
<DateRangePicker /> shows two months on larger screens. The first click always starts a new range, even when one is set, and the second click finishes it in either order and closes the picker.
Pass any react-day-picker matcher as calendarProps.disabled. Here only future weekdays can be picked.
For far-away dates like a birthday, set captionLayout: "dropdown" with a startMonth and endMonth. Label the trigger with a <label /> pointing at its id.
With name, a single date is submitted as 2026-10-14 and a range as 2026-10-20/2026-10-24. Empty pickers submit an empty string.
A disabled trigger can still show a value.
The trigger never grows past its container. Long labels truncate instead of wrapping.
The picker layers above the sheet, and Escape closes only the picker.
Pass locale for the trigger label and a react-day-picker locale with dir: "rtl" in calendarProps for the calendar. Arrow keys follow the direction.
| Key | Action |
|---|---|
| EnterSpace | On the trigger, opens the picker and focuses the selected day, or today. On a day, selects it. |
| ←→ | Moves to the previous or next day. |
| ↑↓ | Moves to the same day in the previous or next week. |
| Page UpPage Down | Moves to the previous or next month. |
| ShiftPage Up | Moves to the previous year. Shift Page Down moves to the next. |
| HomeEnd | Moves to the start or end of the week. |
| Esc | Closes the picker and returns focus to the trigger. |
- The popover is labelled with
title, and the bottom sheet shows it as a heading. Translate it along withplaceholder. - The trigger has no visible label of its own. Pair it with a
<label />or passaria-label. - Disabled days are skipped by the keyboard and announced as unavailable.
Both pickers share the props below and render a <Button /> trigger with a <Calendar /> in a popover or bottom sheet.
| Prop | Type | Default |
|---|---|---|
value | Date | null | – |
defaultValue | Date | null | null |
onValueChange | (value: Date | null) => void | – |
placeholder | string | "Pick a date" |
titleAccessible name of the popover, heading of the sheet. | string | "Select a date" |
open | boolean | – |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | – |
localeFormats the trigger label with Intl.DateTimeFormat. Pass a react-day-picker locale in calendarProps to translate the calendar too. | string | "en-US" |
clearableAdds a Clear button below the calendar once there is a value. | boolean | false |
clearLabel | string | "Clear" |
nameRenders a hidden input so the value is submitted with its form. | string | – |
calendarPropsPassed to the calendar, except mode, selected, onSelect, required, numberOfMonths and autoFocus. Use it for disabled days, captionLayout, startMonth, endMonth, locale and dir. | CalendarProps | – |
variantThe trigger is a Button, and accepts its other props too. | Button variant | "outline" |
disabled | boolean | false |
classNameApplied to the trigger, which is w-60 by default. | string | – |
| Prop | Type | Default |
|---|---|---|
value | { from: Date; to?: Date } | null | – |
defaultValue | { from: Date; to?: Date } | null | null |
onValueChangeCalled once the second day is picked. | (value: DateRange | null) => void | – |
placeholder | string | "Pick a date range" |
title | string | "Select dates" |
open | boolean | – |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | – |
localeFormats the trigger label with Intl.DateTimeFormat. Pass a react-day-picker locale in calendarProps to translate the calendar too. | string | "en-US" |
clearableAdds a Clear button below the calendar once there is a value. | boolean | false |
clearLabel | string | "Clear" |
nameRenders a hidden input so the value is submitted with its form. | string | – |
calendarPropsPassed to the calendar, except mode, selected, onSelect, required, numberOfMonths and autoFocus. Use it for disabled days, captionLayout, startMonth, endMonth, locale and dir. | CalendarProps | – |
variantThe trigger is a Button, and accepts its other props too. | Button variant | "outline" |
disabled | boolean | false |
classNameApplied to the trigger, which is w-60 by default. | string | – |
| Attribute | Description |
|---|---|
data-slot="date-picker-trigger" | The trigger button. |
data-empty | Present on the trigger while there is no value. Shows the placeholder in muted text. |
data-popup-open | Present on the trigger while the picker is open. |
data-slot="date-picker-content" | Wraps the calendar in the popover or sheet. |
data-slot="date-picker-clear" | The Clear button. |
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- CalendarA date grid for single, range and multiple selection, with sliding months, range previews and touch-sized days.
- PopoverA floating panel anchored to a trigger that resizes smoothly with its content and follows the trigger’s direction.
- SheetA panel that slides in from any edge, with swipe-to-dismiss, scroll lock and stacked nesting.
- CheckboxA checkbox whose check draws in, with indeterminate parents, groups and labels that share its hover.
- ComboboxA filterable select with chips, groups and async results, in a popup that resizes as you type.
Used in Pro blocks
Blocks that build on Date picker.
Every block comes with HextaUI Pro, and Prompt Input is free.