Skip to content

Date Time Picker

React date and time picker in one popover: a calendar and a scrollable time list, 5 to 30 minute steps, past times disabled and a 12 or 24 hour clock.

src/registry/ui/date-time-picker.tsx/r/date-time-picker.json

Installation

bash
npx shadcn@latest add @minidev/date-time-picker

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/date-time-picker.json

Usage

tsx
import { DateTimePicker } from "@/components/ui/date-time-picker"

export function Example() {
  return (
    <DateTimePicker />
  )
}

API reference

DateTimePicker props
PropTypeDefault
valueControlled value, or `null` for empty.Date | null-
defaultValueStarting value when uncontrolled.Date | nullnull
onValueChangeFires with the new Date, or `null` after Clear.(value: Date | null) => void-
minuteStepMinutes between time slots.5153015
hour12Force a 12 or 24 hour clock. Defaults to the locale's clock.boolean-
minEarliest moment. Days before it and earlier slots on its day are disabled.Date-
maxLatest moment. Days after it and later slots on its day are disabled.Date-
disabledDisable the trigger.booleanfalse
placeholderTrigger text while empty.string"Pick a date and time"
timeZoneLabelTime zone note in the popover footer, such as "Times in Europe/Berlin".string-
localeBCP 47 locale for the trigger, the calendar and the time labels.string"en-US"
weekStartsOnFirst column of the calendar week: 0 is Sunday, 1 is Monday.010
nameForm field name. Submits the value as an ISO 8601 string in UTC, or "" when empty.string-
idId for a `<label htmlFor>` or FormField.string-
classNamestring-
aria-labelWhat the moment is for, such as "Send at". The value is appended to it.string-

When to use

Use it for meetings, scheduled sends, deploy windows and deadlines, anywhere a single moment matters. The value is a Date (or null when empty). Pass min={new Date()} to block past days and the past slots of today; slots are minuteStep minutes apart. The trigger shows the value through Intl.DateTimeFormat (medium date, short time), and the time list follows the locale's 12 or 24 hour clock unless hour12 is set. Pass name to submit it with a form as an ISO string. For a date alone use Calendar or DatePicker; for a time alone use TimePicker.

Keyboard interactions

Keyboard interactions
KeyAction
EnterorSpaceOn the trigger, opens the popover and focuses the selected day, or today.
ArrowLeftorArrowRightorArrowUporArrowDownIn the calendar, moves by day or week. PageUp and PageDown move by month, as in Calendar.
EnterorSpaceIn the calendar, picks the focused day and keeps the popover open.
TabMoves from the calendar to the time list, then to Clear and Now.
ArrowDownorArrowUpIn the time list, moves to the next or previous free slot, skipping disabled ones.
HomeorEndIn the time list, moves to the first or last free slot.
0-9In the time list, jumps to the first free slot that starts with the typed digits: 9 then 3 finds 9:30. Keys typed within 600ms add up.
EnterorSpaceIn the time list, picks the highlighted slot, closes the popover and returns focus to the trigger.
EscapeCloses the popover and returns focus to the trigger.

Accessibility

  • The trigger is a Base UI Popover.Trigger with aria-haspopup="dialog" and aria-expanded. With aria-label="Send at", its name becomes "Send at" plus the formatted value, or the placeholder when empty.
  • The time list is a role="listbox" labelled by the visible "Time" heading. It is one tab stop and points at the highlighted slot with aria-activedescendant. Slots are role="option" with aria-selected; past or out-of-range slots have aria-disabled.
  • On open, focus moves to the calendar's selected day or today, and the selected slot is scrolled to the middle of the list. On close, Base UI returns focus to the trigger.
  • The trigger text and the hidden input are only filled in the browser: the server's time zone may differ from the visitor's, so rendering the time on the server could show the wrong hour.

Frequently asked questions

How do I disable past dates and times?

Pass min={new Date()}. Days before today are disabled in the calendar, and so are today's slots before that moment: with 15 minute steps at 14:07, the first free slot is 14:15. max works the same way at the other end, for example a deploy window that closes on Friday.

Which time zone does DateTimePicker use?

The browser's. The value is a plain Date, the calendar, slots and trigger all show local time, and timeZoneLabel only prints a note in the footer. With name, the form submits toISOString(), which is UTC, so the server gets an unambiguous moment.

How do I use it with React Hook Form or FormData?

For a plain <form>, pass name and a hidden input submits the ISO string, or "" when empty. With React Hook Form, use a Controller and pass value={field.value} and onValueChange={field.onChange}. Clear sends null, so type the field Date | null.

What happens if I pick a day before a time?

The first day you pick gets 09:00, or keeps the time already chosen; if that time is outside min or max on the new day, it moves to the first free slot. Picking a day keeps the popover open, while picking a time or pressing Now closes it. Now picks the first slot at or after the moment the popover opened.

Dependencies

npm

lucide-react

Examples

Schedule a send

With min set to now, earlier days and the past slots of today cannot be picked.

24 hour clock in a form

Half-hour slots, a 24 hour clock and a note naming the browser time zone, which is the zone the picker uses. With name set, FormData gets an ISO string in UTC.

All form components