<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Date Picker

Input field and calendar for choosing a date or range of dates.
stylekeys: datePicker

Use Date Picker...

  • To prompt users for a date or range with their choice of input field or calendar grid.

Don't use Date Picker...

  • In scenarios or layouts more suited for a standalone calendar grid. Use DateCalendar instead.

The preview has been updated.

Selection Mode

Indicates whether the user can select a single date or a range of dates.

Single

Use selectionMode="single" to allow only one date to be entered or selected. This is the default mode.

The preview has been updated.

Range

Use selectionMode="range" to allow a date range to be entered or selected.

The preview has been updated.

Disabled

Use disabled to prevent the input field and popover from being focused or selected. If possible, use a message to explain why input/selection is not allowed.

The preview has been updated.

Min and max dates

Use minDate, maxDate , or both to narrow the date/range selection to a specific window. The calendar will disable any dates occurring before the minDate and after the maxDate, preventing them from being focused or selected. It will also prevent forward/backward navigation using the arrow controls when there are no available dates in the adjacent months.

The preview has been updated.

Unavailable dates

Use isDateUnavailable to provide a callback that evaluates whether each visible date is unavailable for selection. A date is “unavailable” when it is not selectable, but may be preceded or followed by other selectable dates (e.g. preventing weekends from being selected while still allowing weekdays).

Non-contiguous ranges

By default, non-contiguous date ranges are allowed. This means that any range can be selected even if an unavailable date would fall in the middle.

The preview has been updated.

Contiguous ranges

Use allowsNonContiguousRanges={false} to prevent non-contiguous ranges from being selected. This means that a range cannot be selected if an unavailable date is in the middle. On selection of a start date, the calendar will disable any end dates that would result in an unavailable date falling in the middle of the range.

The preview has been updated.

Labels, errors, and helper text

Use the Form Field components to incorporate labels, error messages, or helper text. These components automatically apply the necessary ARIA attributes to the Date Picker, eliminating the need for manual handling.

With Form components (preferred)

The preview has been updated.

Without Form components

Labels

Use aria-labelledby (preferred) or a localized aria-label prop to provide an accessible label.

The preview has been updated.

Errors

Use aria-errormessage and aria-describedby to provide an accessible error message, and use skin=”error” on DatePickerInput to apply a red border.

The preview has been updated.

Helper text

Use aria-describedby to provide accessible helper text.

The preview has been updated.

Calendar shortcuts

Today

Use showTodayButton on DatePickerCalendar to reveal a “Today” button that updates the calendar to reflect the current month. This option is best to use in scenarios where the user's selected date is far from the present. Note that today’s date will NOT be selected or focused.

The preview has been updated.

Clear

Use showClearButton on DatePickerCalendar to reveal a “Clear” button that clears the currently selected date or date range.

The preview has been updated.

Managing state

Single

Controlled

Use selectedDate to provide a stored value and onSelectedDateChange to provide a callback for managing that value. The callback will be invoked whenever the date is edited by the user.

The preview has been updated.

Uncontrolled

Omit selectedDate and onSelectedDateChange to allow the browser to manage the state. Use defaultDate to provide an initial value.

The preview has been updated.

Range

Controlled

Use selectedRange to provide a stored value and onSelectedRangeChange to provide a callback for managing that value. The callback will be invoked only when the end date is edited by the user.

The preview has been updated.

Uncontrolled

Omit selectedRange and onSelectedRangeChange to allow the browser to manage the state. Use defaultRange to provide an initial value.

The preview has been updated.

Internationalization

Month names, weekday names, placeholder format, the first day of the week, and other locale-specific features are automatically formatted using the locale provided to the SWAN I18n Provider and according to our Date/Time content guidelines.

Accessibility

A DatePicker must have an accessible label that describes the purpose of the date selection. Refer to Labels, errors, and helper text.