Skip to main content

Date picker

Ask AIView as Markdown
Copy a prompt to ask an AI assistant about this page.

Date pickers provide a versatile calendar that can be used as a standalone element or within a dropdown for date input, offering a seamless way to select dates.

Date picker - Code

Basic​

Single Selection​

Require confirmation​

By default, date pickers apply every pick immediately. Set requireConfirmation to only apply the selection when users click Confirm. Cancel restores the last confirmed value.

info

Date pickers emit dateChange for every pick and dateSelect only when the selection should be applied: with Done or Confirm, or on pick in single selection without requireConfirmation.

Translation​

The ix-date-picker can be configured using BCP 47 locale strings specifying the language to use generating or interpreting strings. More information can be found here

API for ix-date-picker​

Properties​

Since 5.0.0
Description

ARIA label for the next month icon button

Will be set as aria-label on the nested HTML button element

Attribute
aria-label-month-selection
Type
string | undefined
Default
'Select month'
Description

ARIA label for the next month icon button.

Will be set as aria-label on the nested HTML button element.

Attribute
aria-label-next-month-button
Type
string | undefined
Default
'Change calendar view to next month'
Description

ARIA label for the previous month icon button.

Will be set as aria-label on the nested HTML button element.

Attribute
aria-label-previous-month-button
Type
string | undefined
Default
'Change calendar view to previous month'
Since 5.0.0
Description

ARIA label for the next month icon button

Will be set as aria-label on the nested HTML button element

Attribute
aria-label-year-selection
Type
string | undefined
Default
'Select year'
Description

Corner style.

Attribute
corners
Type
"left" | "right" | "rounded" | "straight"
Default
'rounded'
Description

Enable Popover API rendering for dropdown.

Attribute
enable-top-layer
Type
boolean
Default
false
Description

Date format string.

See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for all available tokens.

Attribute
format
Type
string
Default
'yyyy/LL/dd'
Description

The selected starting date. If the date picker is not in range mode, this is the selected date.

Format has to match the format property.

Attribute
from
Type
string | undefined
Since 6.0.0
Description

Text of the cancel button shown when requireConfirmation is enabled.

Attribute
i18n-cancel
Type
string
Default
'Cancel'
Since 6.0.0
Description

Text of the confirm button shown when requireConfirmation is enabled.

Attribute
i18n-confirm
Type
string
Default
'Confirm'
Description

Text of the date select button.

Attribute
i18n-done
Type
string
Default
'Done'
Description

Locale identifier (e.g. 'en' or 'de').

The locale is used to translate the labels for weekdays and months.

When the locale changes, the weekday labels are rotated according to the weekStartIndex.

The locale is also applied when formatting and parsing date values.

For locale-dependent format tokens (e.g. MMMM, MMM), the output will reflect the locale.

Use the isoFrom and isoTo fields on events for locale-independent values.

Attribute
locale
Type
string | undefined
Description

The latest date that can be selected by the date picker.

If not set there will be no restriction.

Attribute
max-date
Type
string
Default
''
Description

The earliest date that can be selected by the date picker.

If not set there will be no restriction.

Attribute
min-date
Type
string
Default
''
Since 6.0.0
Description

If true, a selection is only applied after the user confirms it with the

confirm button, which emits dateSelect. dateChange still reports

every pick. The cancel button discards the

pending selection.

Attribute
require-confirmation
Type
boolean
Default
false
Description

Shows week numbers displayed on the left side of the date picker.

Attribute
show-week-numbers
Type
boolean
Default
false
Description

If true, disables date range selection (from/to).

Attribute
single-selection
Type
boolean
Default
false
Description

The selected end date. If the date picker is not in range mode, this property has no impact.

Format has to match the format property.

Attribute
to
Type
string | undefined
Description

The index of the day the week starts on, as a 0-based index into Luxon's

Info.weekdays() array. That array is always ordered Monday-first

regardless of locale, so 0 is Monday, 1 is Tuesday and 6 is Sunday.

E.g. weekStartIndex = 6 results in starting the week on Sunday.

Attribute
week-start-index
Type
number
Default
0

Methods​

Events​

Since 6.0.0
Description

Emitted when the pending selection is discarded via the cancel button.

Event
dateCancel
Detail
void
Breaking change in v6.0.0
from and to are localized, use isoFrom and isoTo for ISO 8601 values
Description

Emitted on any date selection change. The DateChangeEvent contains from and to properties

formatted according to the format and locale properties.

Use isoFrom and isoTo for locale-independent ISO 8601 date strings.

Note: Since 2.0.0 dateChange does not dispatch detail property as string

When a pending selection is discarded, it is emitted with the confirmed

selection again. Use dateSelect to receive only the applied selection.

Event
dateChange
Detail
DateRange<string> & { isoFrom?: string | undefined; isoTo?: string | undefined; }
Deprecated since 6.0.0, use `dateChange` instead, which carries the same `from`/`to` range. Will be removed in 7.0.0.
Breaking change in v6.0.0
Deprecated, from and to are localized (use isoFrom and isoTo)
Description

Date range change event. Emitted when the date range selection changes and the component is in range mode.

The DateChangeEvent contains from and to properties formatted according to the format and locale properties.

Use isoFrom and isoTo for locale-independent ISO 8601 date strings.

Emitted together with dateChange.

Event
dateRangeChange
Detail
DateRange<string> & { isoFrom?: string | undefined; isoTo?: string | undefined; }
Breaking change in v6.0.0
from and to are localized, use isoFrom and isoTo for ISO 8601 values
Description

Date selection event. Emitted when the selection is applied via the done

button, or via the confirm button with requireConfirmation. With

singleSelection and without requireConfirmation there is no button,

so it is emitted together with dateChange when a date is picked.

The DateChangeEvent contains from and to properties formatted according to the format and locale properties.

Use isoFrom and isoTo for locale-independent ISO 8601 date strings.

Event
dateSelect
Detail
DateRange<string> & { isoFrom?: string | undefined; isoTo?: string | undefined; }