Loading...
Loading...
Implement Syncfusion React DatePicker component with comprehensive guidance on date selection, formatting, validation, and accessibility. Use this when working with date input fields, date range pickers, custom date formats, locale-specific date handling, or keyboard navigation. This skill covers installation, setup, date formatting, validation, styling, globalization, and accessibility features.
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-datepickerenableMaskmaskPlaceholderstrictModestartdepthrenderDayCellenableRtlfirstDayOfWeekshow()hide()focusIn()focusOut()navigateTo()currentView()| Property | Type | Default | Description |
|---|---|---|---|
| Date | null | Selected date |
| Date | 1900-01-01 | Minimum selectable date |
| Date | 2099-12-31 | Maximum selectable date |
| string | FormatObject | null | Display format (e.g., |
| string[] | FormatObject[] | null | Accepted input formats array |
| string | null | Placeholder text for the input |
| boolean | true | Enable or disable the component |
| boolean | false | Readonly state |
| boolean | true | Allow editing the input textbox |
| boolean | false | Auto-correct out-of-range dates |
| boolean | true | Show/hide the clear button |
| boolean | true | Show/hide today button |
| CalendarView | Month | Initial view: |
| CalendarView | Month | Deepest navigation level |
| boolean | false | Enable masked date input |
| MaskPlaceholderModel | {...} | Segment placeholders for masked input |
| boolean | false | Right-to-left rendering |
| string | '' | Culture/locale code |
| number | 0 | First day of week (0=Sunday) |
| boolean | false | Show week numbers |
| WeekRule | FirstDay | Rule for first week of year |
| CalendarType | Gregorian | Calendar type (Gregorian or Islamic) |
| DayHeaderFormats | Short | Day name format in header |
| FloatLabelType | Never | Floating label behavior |
| boolean | false | Full screen popup on mobile |
| boolean | false | Open popup on input focus |
| number | null | Server timezone offset |
| string | null | Custom CSS class |
| { [key: string]: string } | {} | Additional HTML attributes |
| { [key: string]: string } | null | Custom key action mappings |
| number | string | null | Component width |
| number | 1000 | Popup z-index |
| boolean | false | Persist state between reloads |
| Method | Returns | Description |
|---|---|---|
| void | Opens the calendar popup |
| void | Closes the calendar popup |
| void | Sets focus to the component |
| void | Removes focus from the component |
| void | Navigates to a specific view and date |
| string | Returns the current calendar view name |
| string | Gets persisted state data |
| void | Removes date(s) from the values |
| void | Destroys the component |
| Event | Args Type | Description |
|---|---|---|
| ChangedEventArgs | Fires when the selected date changes |
| FocusEventArgs | Fires when input gains focus |
| BlurEventArgs | Fires when input loses focus |
| PreventableEventArgs | PopupObjectArgs | Fires when the popup opens |
| PreventableEventArgs | PopupObjectArgs | Fires when the popup closes |
| ClearedEventArgs | Fires when value is cleared |
| Object | Fires when component is created |
| Object | Fires when component is destroyed |
| NavigatedEventArgs | Fires when calendar view is navigated |
| RenderDayCellEventArgs | Fires when each day cell is rendered |
enableMaskmaskPlaceholderstrictModeimport React, { useState } from 'react';
import { DatePickerComponent } from '@syncfusion/ej2-react-calendars';
import '@syncfusion/ej2-base/styles/material3.css';
import '@syncfusion/ej2-buttons/styles/material3.css';
import '@syncfusion/ej2-inputs/styles/material3.css';
import '@syncfusion/ej2-popups/styles/material3.css';
import '@syncfusion/ej2-react-calendars/styles/material3.css';
export default function App() {
const [selectedDate, setSelectedDate] = useState(new Date());
return (
<div style={{ padding: '20px' }}>
<h3>Select a Date</h3>
<DatePickerComponent
value={selectedDate}
change={(e) => setSelectedDate(e.value)}
placeholder="Enter date"
/>
<p>Selected: {selectedDate?.toDateString()}</p>
</div>
);
}DatePickerComponent@syncfusion/ej2-react-calendarsvaluechangeonChange<DatePickerComponent
value={new Date()}
min={new Date(2026, 0, 1)}
max={new Date(2026, 11, 31)}
placeholder="Select a date in 2026"
/><DatePickerComponent
value={new Date()}
format="dd/MM/yyyy"
placeholder="DD/MM/YYYY"
/><DatePickerComponent
value={new Date()}
format="yyyy-MM-dd"
inputFormats={['dd/MM/yyyy', 'yyyy-MM-dd', 'yyyyMMdd']}
placeholder="Enter date (dd/MM/yyyy or yyyy-MM-dd)"
/><DatePickerComponent
value={new Date()}
start="Decade"
depth="Year"
placeholder="Select year"
/><DatePickerComponent
value={new Date()}
renderDayCell={(args) => {
if ((args.date.getDay()) === 0 || (args.date.getDay()) === 6) {
args.isDisabled = true;
}
}}
placeholder="Weekdays only"
/>const [date, setDate] = useState(null);
<DatePickerComponent
value={date}
change={(e) => setDate(e.value)}
format="yyyy-MM-dd"
strictMode={true}
placeholder="Enter date"
/><DatePickerComponent
locale="de"
enableRtl={false}
firstDayOfWeek={1}
value={new Date()}
placeholder="Datum eingeben"
/><DatePickerComponent
enableMask={true}
format="MM/dd/yyyy"
maskPlaceholder={{ day: 'DD', month: 'MM', year: 'YYYY' }}
placeholder="Select a date"
/>import { useRef } from 'react';
const datePickerRef = useRef(null);
// Open calendar
datePickerRef.current.show();
// Close calendar
datePickerRef.current.hide();
// Focus
datePickerRef.current.focusIn();
// Get current view
const view = datePickerRef.current.currentView(); // "Month" | "Year" | "Decade"
// Navigate to specific view
datePickerRef.current.navigateTo('Year', new Date(2026, 0, 1));
<DatePickerComponent ref={datePickerRef} value={new Date()} /><DatePickerComponent
value={new Date()}
change={(e) => console.log('Changed:', e.value)}
focus={(e) => console.log('Focused')}
blur={(e) => console.log('Blurred')}
open={(e) => console.log('Opened')}
close={(e) => console.log('Closed')}
cleared={(e) => console.log('Cleared')}
navigated={(e) => console.log('Navigated to view:', e.view)}
renderDayCell={(args) => {
// Disable weekends
if (args.date.getDay() === 0 || args.date.getDay() === 6) {
args.isDisabled = true;
}
}}
/>