Skip to main content

Date dropdown

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

Date dropdowns allow users to select a specific date from a date picker or pre-defined date options.

Date dropdown - Code

Basic​

With presets​

Require confirmation​

By default, date dropdowns apply the range and close as soon as the range is complete. Set requireConfirmation to only apply the range when users click Confirm. Cancel, Escape or clicking outside discards the pending selection. Date dropdowns emit dateRangeChange for every pick and dateSelect only when they apply the range.

Display format​

Set displayFormat to show the selected dates in the dropdown button in a different format than format. from, to, minDate, maxDate and emitted values keep using format.

API for ix-date-dropdown​

Properties​

Description

Used to set the initial select date range as well as the button name,

if not set or no according date range label is found, nothing will be selected

Attribute
date-range-id
Type
string
Default
'custom'
Description

An array of predefined date range options for the date picker.

Each option is an object with a label describing the range and a function

that returns the start and end dates of the range as a DateRangeOption object.

Example format:

{

id: 'some unique id',

label: 'Name of the range',

from: undefined, to: '2023/03/29'

},

// ... other predefined date range options ...

Type
DateDropdownOption[]
Default
[]
Description

Disable the button that opens the dropdown containing the date picker.

Attribute
disabled
Type
boolean
Default
false
Since 6.0.0
Description

Date format used to display the selected dates in the dropdown button.

from, to, minDate, maxDate and emitted values keep using format.

Defaults to format.

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

Attribute
display-format
Type
string | undefined
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

Picker date. If the picker is in range mode this property is the start date.

If set to null no default start date will be pre-selected.

Format is based on format

Attribute
from
Type
string
Default
''
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'
Deprecated The done button was removed. Without `requireConfirmation` the dropdown closes once a complete date or range is selected.
Breaking change in v6.0.0
The done button was removed, the property has no effect
Description

Text for the done button. Will be used for translation.

Attribute
i18n-done
Type
string
Default
'Done'
Description

Text for the done button. Will be used for translation.

Attribute
i18n-no-range
Type
string
Default
'No range set'
Description

Loading button

Attribute
loading
Type
boolean
Default
false
Description

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

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 date range picked in the dropdown is only applied after the

user confirms it with the confirm button, which emits dateSelect. The

trigger label keeps the applied range until then, while dateRangeChange

still reports every pick. The cancel button, pressing Escape or clicking

outside the dropdown 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

Picker date. If the picker is in range mode this property is the end date.

If the picker is not in range mode leave this value null

Format is based on format

Attribute
to
Type
string
Default
''
Description

Button variant

Attribute
variant
Type
"danger-primary" | "danger-secondary" | "danger-tertiary" | "primary" | "secondary" | "subtle-primary" | "subtle-secondary" | "subtle-tertiary" | "tertiary"
Default
'primary'
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​

Breaking change in v6.0.0
Emitted for every pick instead of on close, from and to are localized (use isoFrom and isoTo)
Description

EventEmitter for date range change events.

This event is emitted when the date range changes within the component.

The event payload contains information about the selected date range.

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

range again.

Use dateSelect to only receive applied ranges.

Event
dateRangeChange
Detail
DateRange<string> & { isoFrom?: string | undefined; isoTo?: string | undefined; } & { id: string; }
Since 6.0.0
Description

Emitted when the user applies a changed range: on confirm with

requireConfirmation, otherwise when a complete range or a predefined

range is picked.

It is not emitted for programmatic prop input changes.

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