DatePicker Component

The DatePicker component provides an input with an integrated calendar popup for selecting a single date. It supports date formatting, parsing, min/max date constraints, strict mode validation, custom calendar templates, and can be rendered as an inline picker or a dialog-based picker.

Usage

To import and use the DatePicker component in your application, use the following code snippet:

Demos

Explore the demos of the React DatePicker component. Refer to this page.

Props

The following table outlines the props for the DatePicker component:

NameTypeDefaultDescription
cellTemplate
((props: CalendarCellProps) => node)
-

Specifies a custom template for rendering the content of each calendar cell. Can be a React node or a function that returns a React node.

clearButton
boolean
true

Specifies whether to show the clear button within the input field.

defaultValue
Date
-

Specifies the default selected date of the DatePicker for uncontrolled mode.

depth
CalendarView.Month

Sets the most granular view the user can navigate down to. For example, a depth of Year prevents navigation to the Month view.

disableFutureDays
boolean
false

When true, disables all dates in the future relative to the current day.

disableOtherMonthNavigation
boolean
false

Prevents navigation when clicking on dates from other months in month view

disablePastDays
boolean
false

When true, disables all dates in the past relative to the current day.

disabled
boolean
false

Specifies whether the component is disabled or not.

editable
boolean
true

Specifies whether the input field can be edited directly. When false, only allows selection via calendar.

firstDayOfWeek
number
0

Specifies the first day of the week: 0 for Sunday, 1 for Monday, and so on. If not set, the first day is determined by the locale.

footerTemplate
((props: CalendarFooterProps) => node)
-

Specifies a custom template for the calendar footer. If not provided, a default footer with a 'Today' button is rendered.

format
string
'M/d/yyyy'

Specifies the date format string for displaying and parsing date values. Examples: 'MM/dd/yyyy', 'yyyy-MM-dd', etc.

headerTemplate
((props: CalendarHeaderProps) => node)
-

Specifies a custom template for the calendar header. If not provided, a default header with navigation controls is rendered.

inputFormats
string[]
-

Specifies an array of acceptable date input formats for parsing user input. Can be an array of strings or FormatObject.

labelMode
'Never'

Specifies the float label behavior. Possible values:

  • Never - The label will never float.
  • Auto - The label floats when the input has focus, value, or placeholder.
  • Always - The label always floats.
maxDate
Date
new Date(2099, 11, 31)

Specifies the maximum date that can be selected in the Calendar.

minDate
Date
new Date(1900, 0, 1)

Specifies the minimum date that can be selected in the Calendar.

open
boolean
false

Specifies whether the calendar popup is open or closed.

openOnFocus
boolean
false

When true, should open the calendar popup on input focus.

orientation
Orientation.Vertical

Specifies the layout orientation of the calendar.

pickerIcon
node
undefined

Specifies the calendar/datepicker icon rendered in the input.

pickerVariant
PickerVariant.Auto

Specifies the display variant of the calendar popup.

  • Inline: anchored popup near the input (both desktop and mobile)
  • Dialog: centered dialog overlay (both desktop and mobile)
  • Auto: desktop = Inline, mobile = Dialog
placeholder
string
-

Specifies the placeholder text to display in the input box when no value is set.

readOnly
boolean
false

Specifies whether the component is in read-only mode. When enabled, users cannot change input value or open the picker.

required
boolean
false

Specifies whether the DatePicker is a required field in a form. When set to true, the component will be marked as required.

showDaysOutsideCurrentMonth
boolean
true

When true, shows dates from the previous and next months in the current month's view.

showTodayButton
boolean
true

Specifies whether the calendar shows the Today button in the footer.

showToolBar
boolean
false

Specifies whether the calendar displays an additional toolbar for showing the full selected date.

size
Size
Size.Medium

Specifies the size style of the Timepicker. Options include 'Small', 'Medium' and 'Large'.

start
CalendarView.Month

Specifies the initial view that the calendar renders.

strictMode
boolean
false

Enables strict date validation mode. When enabled, invalid values are prevented or auto-corrected.

valid
boolean
false

Overrides the validity state of the component. If valid is set, the required property will be ignored.

validationMessage
string
-

Controls the form error message of the component.

validityStyles
boolean
true

If set to false, no visual representation of the invalid state of the component will be applied.

value
Date | null
-

Specifies the selected date of the DatePicker for controlled usage.

variant
Variant.Standard

Specifies the visual style variant of the component.

weekDaysFormat
WeekDaysFormats.Short

Specifies the format of the day names to be displayed in the week header.

weekNumber
boolean
false

When true, displays the week number of the year in the month view.

weekRule
WeekRule.FirstDay

Specifies the rule for defining the first week of the year.

zIndex
number
1000

Sets the z-index value for the dropdown popup, controlling its stacking order relative to other elements on the page.

Events

The following table outlines the events for the DatePicker component:

NameTypeDescription
onChange
(event: DatePickerChangeEvent) => void

Triggers when the DatePicker value is changed.

onClose
( ) => void

Triggers when the calendar popup closes.

onOpen
( ) => void

Triggers when the calendar popup opens.

onViewChange
(event: ViewChangeEvent) => void

Triggers when the calendar navigates to a new view or date range.