Skip to content

DatePicker

Properties

PropertyTypeDefaultDescription
type'day'|'month'|'year''day'Defines the date unit to display as one of 'day', 'month', or 'year'.
todayDatenew Date()Defines today's date.
headerPatternsobjectFormat of the date displayed in the header. { day: 'YYYY.MM', month: 'YYYY', year: '{YYYY} ~ {YYYY}' }
patternsRecord<'day'|'month'|'year', string>Format of the displayed date. { day: 'YYYY.MM.DD', month: 'YYYY.MM.DD', year: 'YYYY' }
allowRangebooleanfalseWhether users can select a date range.
allowDates(date: Date) => booleanFunction that defines selectable dates.
selectedRangeArray<Date>Defines the selected date range. Set in the form of [new Date('2020/1/1'), new Date('2020/1/31')].
selectedDateDateDefines the selected date. Set in the form of new Date('2020/1/1').
selectedDateStringstringReturns the selected date as a string. Determined by the formatter and pattern property.
labelstring''Label text for the input field.
clearablebooleanfalseWhether to enable the reset button when the input field has a value.
placeholderstringText displayed when no value is entered in the input field.
titlePatternsobjectFormat of the date displayed in the title. { day: 'YYYY.MM.DD', month: 'YYYY.MM', year: 'YYYY' }
coordinateMode'global'|'relative'|'none''relative'Sets the coordinate system for the popup. 'global': global placement, 'relative': relative placement, 'none': no placement

Methods

MethodParametersDescription
clearvoidDeletes the selected date.
resetvoidMoves to the selected date, or to today's date if no date is selected.
setCurrentDate(date: Date)Moves the displayed date list to the specified date.
getStatevoidReturns the current display state ('day', 'month', 'year').
openvoidOpens the date selection popup.
closevoidCloses the date selection popup.

Events

EventTypeDescription
selection-changing(event: SelectionEvent<T>) => voidOccurs before an item is selected. Selection can be cancelled by calling preventDefault.
selection-change(event: SelectionEvent<T>) => voidOccurs after an item is selected.
state-change(event: CustomEvent<{value: DateType; oldValue: DateType}>) => voidOccurs whenever the calendar's state changes.
item-down(event: ItemEvent<DateItem>) => voidOccurs when mouse down on an item.
item-click(event: ItemEvent<DateItem>) => voidOccurs when mouse click on an item.
date-picker-opening(event: CustomEvent<DateRange>) => voidOccurs before the date selection popup opens.
date-picker-closing(event: CustomEvent<DateRange>) => voidOccurs before the date selection popup closes.
date-picker-open(event: CustomEvent<DateRange>) => voidOccurs when the date selection popup opens.
date-picker-close(event: CustomEvent<DateRange>) => voidOccurs when the date selection popup closes.
date-picker-select(event: CustomEvent<DateRange>) => voidOccurs when a date is selected.