React DatePicker

The React DatePicker component provides an intuitive interface for date selection and navigation. It offers a comprehensive set of features including multiple view modes, date range restrictions, custom rendering, and accessibility support for building robust date-picking experiences.

Getting started

To create a new Vite project, refer to the Vite documentation. Once that Vite project is ready to run with default settings, let's add the React DatePicker component to the project.

Installing Syncfusion® React packages

To use the React DatePicker component in this project, the @syncfusion/react-calendars package needs to be installed using the following command:

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 DatePicker component and its dependents were imported into the src/App.css file.

Adding DatePicker component

To include the DatePicker component in your application, import the DatePicker from the @syncfusion/react-calendars package in App.tsx.

Add the DatePicker component in application as shown in below code example.

Run the project

To run the project, use the following command:

The DatePicker component provides a simple and intuitive way to select dates. By default, it displays the current month and allows users to navigate between months and years.

Selected date: Tue Dec 16 2025

Views

The DatePicker component supports multiple view modes including Month, Year, and Decade. You can programmatically track which view is currently active using the onViewChange event handler.

The DatePicker starts with the Month view by default and allows users to drill up to Year and Decade views or back down to more specific selections. The example below demonstrates how to detect and display the current view mode:

Year picker

The DatePicker component allows users to select a year by setting both the start and depth properties to Decade view. This configuration opens the DatePicker in decade view, displaying a range of years and able to pick a specific year directly from this view.

Month picker

The DatePicker component allows users to select a month by setting both the start and depth properties to Year view. This configuration opens the DatePicker in year view, showing all months of the selected year and can choose a specific month directly.

Controlled Vs Uncontrolled

The DatePicker component can be used in both controlled and uncontrolled modes. In controlled mode, the component's value is managed by the parent component, while in uncontrolled mode, the component manages its own state.

Disabled Dates

The DatePicker component allows you to disable specific dates, preventing users from selecting them. This is useful for blocking out holidays, weekends, or any dates that should not be selectable in your application.

You can disable dates in the DatePicker using the cellTemplate prop, which lets you customize how individual date cells are rendered. In the example below, we've disabled the 4th, 15th, and 25th days of each month by applying the sf-disabled CSS class:

Special Dates

The DatePicker is used to customize the appearance of specific dates by highlighting important dates, events, or special occasions with custom styling, icons, or indicators.

Format

The DatePicker component supports various date formats, allowing you to display and receive date values in formats that best suit your application needs. You can specify custom date formats using the format property, which accepts standard date format patterns.

Dialog Mode

The DatePicker component supports dialog-style rendering through the pickerVariant property. Setting pickerVariant to Popup enables the DatePicker to open in a modal-like popup, simulating a dialog experience.

Action Button

The DatePicker component provides the footerTemplate property, which allows customizing the footer section of the popup. Using this, action buttons like Ok and Cancel can be added to handle user interactions such as committing or discarding selected dates.

Non-Editable

The DatePicker component provides the editable property, which controls whether users can manually type a date into the input field. When set to false, the input becomes read-only, and dates can only be selected using the calendar popup. This ensures consistent date formatting in DatePicker component.

Variants

The DatePicker component enhances user interaction through its three distinct visual variants: Standard, Outlined and Filled.

Appearance

Disabled

The DatePicker component can be disabled to prevent user interaction. This is useful when you want to temporarily disable the date selection functionality, such as during form validation or when certain conditions are not met. You can disable the DatePicker by setting the disabled property to true.

ReadOnly

The DatePicker component can be set to read-only mode, which allows users to view the selected date but prevents them from making any changes. This is useful when you want to display a date value that should not be altered by the user, such as in a read-only form or when the date is determined by another process. You can set the DatePicker to read-only mode by setting the readOnly property to true.

Float Label

The DatePicker 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.

Forms support

The DatePicker component can be integrated into forms to allow users to select dates as part of form submissions. This integration ensures that the selected date is included in the form data, making it easy to handle and validate user input. You can use the DatePicker component within a form by placing it inside a <form> element and handling the form submission as needed.

Schedule Medical Appointment
Appointment Guidelines:
  • Appointments available Monday through Friday only
  • Must be scheduled at least 1 day in advance
  • Can be booked up to 30 days in advance

Accessibility

The DatePicker 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 DatePicker component is outlined below.

Accessibility CriteriaCompatibility
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 DatePicker component follows the WAI-ARIA patterns to meet accessibility requirements. The following ARIA attributes are used in the DatePicker component:

AttributesPurpose
aria-expandedIndicates whether the popup list has expanded or not.
aria-disabledIndicates disabled dates that cannot be selected.
aria-activedescendantIndicates the current active child being managed in the DatePicker component.
tabindexMakes the list item focusable via keyboard navigation.
aria-haspopupIndicates that the combobox opens a calendar.
aria-controlsReferences the id of the element.
aria-readonlySpecifies whether the input is read-only.
aria-labelProvides an accessible name for the input element if it doesn't have an associated visible label.

Keyboard interaction

The DatePicker component follows keyboard interaction guidelines, making it accessible for people who use assistive technologies (AT) and those who rely on keyboard navigation. The following keyboard shortcuts are supported:

WindowsmacOSAction
Alt + Down ArrowOption + Down ArrowOpens the popup.
Alt + Up ArrowOption + Up ArrowCloses the popup.
EscEsccloses the popup.
Upper ArrowUpper ArrowFocus the previous week date.
Down ArrowDown ArrowFocus the next week date.
Left ArrowLeft ArrowFocus the previous date.
Right ArrowRight ArrowFocus the next date.
HomeFn + ←Focus the first date in the month.
EndFn + →Focus the last date in the month.
Page UpPage UpFocus the same date in the previous month.
Page DownPage DownFocus the same date in the next month.
EnterEnterSelect the currently focused date.
Shift + Page UpShift + Page UpFocus the same date in the previous year.
Shift + Page DownShift + Page DownFocus the same date in the next year.
Control + Upper ArrowCommand + Upper ArrowMoves into the inner level of view like month-year, year-decade.
Control + Down ArrowCommand + Down ArrowMoves out from the depth level view like decade-year, year-month.
Control + HomeControl + Fn + ←Focus the starting date in the current year.
Control + EndControl + Fn + →Focus the ending date in the current year.