React DateTimePicker
The React DateTimePicker component provides a unified input to select both date and time. It supports keyboard navigation, min/max constraints, custom formatting, popup/dialog rendering, and more.
Getting started
To create a new Vite project, refer to the Vite documentation. Once your project runs with default settings, add the React DateTimePicker component.
Installing Syncfusion React packages
Install the @syncfusion/react-calendars package:
Adding CSS reference
In this article, the Material theme is applied using CSS styles, which are available in installed packages. The necessary Material CSS styles for the DateTimePicker component and its dependents were imported into the src/App.css file.
Adding DateTimePicker component
Import and use the DateTimePicker in your app:
Run the project
The DateTimePicker brings together date and time selection in one UI, enabling users to enter or pick precise date and time values.
Controlled vs Uncontrolled
The DateTimePicker supports both controlled and uncontrolled modes. In controlled mode, the parent component owns the value and supplies it via the value prop, updating it through onChange, ensuring the picker’s state is fully driven by external logic. In uncontrolled mode, the component manages its own internal value, with defaultValue providing the initial state, making it independent of external state management.
Formats
The DateTimePicker component supports customizing how its value is formatted through the format prop. This property accepts standard date‑time format strings and defines the pattern used when displaying the selected value.
Dialog Mode
The DateTimePicker supports dialog-style rendering through the pickerVariant property. Setting pickerVariant to Popup opens the DateTimePicker in a modal-like popup, providing a dialog-style interaction.
Appearance
Variants
The DateTimePicker supports Standard, Outlined, and Filled variants, giving you flexibility in how it looks within your layout.
Float Label
The DateTimePicker component supports different label display modes through the labelMode property. This property controls how the label or placeholder text appears in relation to the input field.
Available label mode options:
- "Never": The label will never float in the input when the placeholder is available.
- "Always": The floating label will always float above the input.
- "Auto": The floating label will float above the input after focusing or entering a value in the input.
Disabled
The DateTimePicker can be disabled to prevent user interaction. This is useful when you want to block date‑and‑time selection temporarily, such as during form validation or when certain conditions are not met. You can disable the DateTimePicker by setting the disabled property to true.
ReadOnly
The DateTimePicker also supports a read‑only mode, allowing users to view the selected date and time without being able to modify it. This is helpful when the value is controlled by another process or when edits should be prevented in specific scenarios. You can enable read‑only mode by setting the readOnly property to true.
Forms Support
A practical appointment booking example that demonstrates DateTimePicker validation props in a real-world scenario. The DateTimePicker shows validation feedback using its props: required, valid, and validationMessage.
Customization
- Customize time items via
itemTemplateto render each entry as a structured row that displays the formatted 12-hour time, the AM/PM indicator, and an additional computed annotation based on the time's total minute value (e.g., generating 1.5 hrs or 30 mins from hours * 60 + minutes). - The DateTimePicker also supports customizing the date cells in the calendar popup through the
cellTemplateto highlight special dates or events.
Accessibility
The DateTimePicker component follows accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.
The accessibility compliance for the DateTimePicker component is outlined below.
| Accessibility Criteria | Compatibility |
|---|---|
| WCAG 2.2 Support | |
| Section 508 Support | |
| Screen Reader Support | |
| Right-To-Left Support | |
| Color Contrast | |
| Mobile Device Support | |
| Keyboard Navigation Support | |
| Accessibility Validation |
- All features of the component meet the requirement.
- Some features of the component do not meet the requirement.
- The component does not meet the requirement.
WAI-ARIA attributes
The DateTimePicker applies ARIA attributes to communicate state and structure:
| Attributes | Purpose |
|---|---|
| aria-expanded | Indicates whether a popup (calendar/time) is open. |
| aria-controls | References the id of the currently opened popup content. |
| aria-haspopup | Identifies the popup type (dialog). |
| aria-disabled | Indicates the disabled state. |
| aria-readonly | Indicates the read-only state. |
| aria-required | Indicates the input is required. |
| aria-invalid | Indicates the input value is invalid. |
| aria-label | Provides an accessible name if no visible label is present. |
| role="combobox" | Identifies the text input that controls popup content. |
| role="dialog", aria-modal | Identifies and describes dialog-style popups (when used). |
Keyboard interaction
Before opening the popup, use the below list of keys to DateTimePicker control the popup element.
| Press | To do this |
|---|---|
| Alt + Down Arrow | Open the select popup |
| Alt + Down Arrow + Alt + Down Arrow | Toggle between two popups |
Use the below list of keys to interact with the Calendar after the DatePicker popup has opened.
| Press | To do this |
|---|---|
| Upper Arrow | Focus the previous week date. |
| Down Arrow | Focus the next week date. |
| Left Arrow | Focus the previous date. |
| Right Arrow | Focus the next date. |
| Home | Focus the first date in the month. |
| End | Focus the last date in the month. |
| Page Up | Focus the same date in the previous month. |
| Page Down | Focus the same date in the next month. |
| Enter | Select the currently focused date. |
| Shift + Page Up | Focus the same date in the previous year. |
| Shift + Page Down | Focus the same date in the previous year. |
| Control + Upper Arrow | Moves into the inner level of view like month-year, year-decade |
| Control + Down Arrow | Moves out from the depth level view like decade-year, year-month |
| Control + Home | Focus the starting date in the current year. |
| Control + End | Focus the ending date in the current year. |
Use the below list of keys to interact with the TimePicker after the popup has opened.
| Press | To do this |
|---|---|
| Upper Arrow | Navigate and select the previous item. |
| Down Arrow | Navigate and select the next item. |
| Left Arrow | Move the cursor towards arrow key pressed direction. |
| Right Arrow | Move the cursor towards arrow key pressed direction. |
| Home | Navigate and select the first item. |
| End | Navigate and select the last item. |
| Enter | Select the currently focused item and close the popup. |
| Alt + Upper Arrow | Close the popup. |
| Alt + Down Arrow | Open the popup. |
| Esc | Close the popup. |