Datetime Picker
Overview
A date and time picker built on shadcn/ui with no extra dependencies.
This form component is intended for interfaces that need a date and time picker built on shadcn/ui with no extra dependencies, authentication flows, and settings forms. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
No additional package dependency is declared for this component.
Installation
Usage
Hour cycle - 12H / 24H
Date picker or Time picker
Date Picker
Time Input
Year Dropdown Range
The year range will be: this year + yearRange and this year - yearRange.
Default is 50.
For example: This year is 2026, The year dropdown will be 1976 to 2076 which is generated by 2026 - 50 = 1976 and 2026 + 50 = 2076.
Locale
Import locale from date-fns
The following example is zhTW from date-fns.
Week start on Monday, Show week number, Disable outside days
Week start on Monday
Show week number
Disable outside days
Display Format
Visit date-fns to customize the format.
Placeholder
Granularity
Minute
Hour
Day
Disabled
Ref
Form
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
value | Date | undefined | - | Date value. |
onChange | (Date) => void | - | When you pick a date, the |
hourCycle | 12 | 24 | 24 | Hour cycle that showing AM/PM or not. |
placeholder | string | Pick a date | The datetime picker placeholder. |
disabled | boolean | false | Disabled Datetime Picker. |
yearRange | number | 50 | The year dropdown range according to this year. By default is 50, which means this year ± 50. For example: This year is 2026. the year dropdown range will be 1976 to 2076. |
displayFormat | { hour24?: string, hour12?: string } | { hour24: 'PPP HH:mm:ss', hour12: 'PP hh:mm:ss b' } | Custom display format by |
granularity | 'day' | 'hour' | 'minute' | 'second' | second | The granularity prop allows you to control the smallest unit that is displayed by DatePicker. By default is |
Use cases
- interfaces that need a date and time picker built on shadcn/ui with no extra dependencies
- authentication flows
- settings forms
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- shadcn/ui dependencies: datetime-picker
- Responsive Tailwind variants present in the source
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- The source includes keyboard event handling; verify it alongside pointer behavior.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
Related components
Topic guides
See how this component fits into broader interface patterns, implementation decisions, and working examples.
Datetime Picker FAQ
Is Datetime Picker free to use in commercial projects?
Yes. The public Datetime Picker source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Datetime Picker?
Run npx shadcn@latest add @spectrumui/datetime-picker-demo or npx shadcn@latest add @spectrumui/datetime-picker-hour-cycle or npx shadcn@latest add @spectrumui/datetime-picker-and-time-input or npx shadcn@latest add @spectrumui/datetime-picker-year-range or npx shadcn@latest add @spectrumui/datetime-picker-locale or npx shadcn@latest add @spectrumui/datetime-picker-calendar-settings or npx shadcn@latest add @spectrumui/datetime-picker-display-format or npx shadcn@latest add @spectrumui/datetime-picker-placeholder or npx shadcn@latest add @spectrumui/datetime-picker-granularity or npx shadcn@latest add @spectrumui/datetime-picker-disabled or npx shadcn@latest add @spectrumui/datetime-picker-ref or npx shadcn@latest add @spectrumui/datetime-picker-form or npx shadcn@latest add calendar select input popover. The page also exposes the source for manual installation.
Does Datetime Picker require Motion?
No Motion dependency was detected in the documented source or registry entry for Datetime Picker.
Does Datetime Picker use shadcn/ui or Radix UI?
Datetime Picker uses the datetime-picker shadcn/ui dependencies.
Can I use Datetime Picker in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Datetime Picker?
The source includes ARIA markup, keyboard handlers. Test the finished interface with keyboard and screen-reader workflows.