Skip to content

DatePicker

A control for selecting or inputting dates. It supports selection by day, week, month, year, quarter, and range, featuring exceptional aesthetic design and smooth interaction.

Showcase

DatePicker supports multiple units of panel display directly, which is common for custom layouts or dashboards.

Mode:
Cell Shape:
Mar 2026
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
Selected:Not Selected
Full Showcase

Basic Usage

With the type attribute, you can quickly switch between date, month, and year selection modes.

Basic Usage

Advanced Configuration

DatePicker provides rich attributes to meet fine-tuned customization needs, such as custom icons and special display formats.

Advanced Options

Cell Shape

The appearance style supports not only the modern round (default) but also the classic and stable square.

Shape Switch

Custom Cell Content

Through the cell-render attribute or date-cell slot, you can customize the display content of date cells, such as adding lunar calendars, holidays, solar terms, or business markers.

Holidays and Solar Terms

Disabled and Readonly

Use the disabled attribute to disable the component, and use the readonly attribute to set it to read-only.

Status Demo

Sizes

The component provides three sizes: large, default, and small, to adapt to different page spaces.

Sizes Demo

Presets

Through the presets attribute, quick selection options can be configured, greatly improving user selection efficiency.

Presets

Disabled Dates

Through the disabled-date function, you can customize which dates should not be selectable.

Date Filtering

Range Selection

Set type to *range to enable range selection mode.

-
-
Range Mode

Use in Nuxt

DatePicker perfectly supports SSR rendering in Nuxt 3/4. In Nuxt projects, the component and its dependencies (styles, Hooks) are automatically imported, no manual registration required.

Use in Nuxt

SSR Note

DatePicker has been optimized for Hydration internally, ensuring that the DOM structure generated on the server and client is completely consistent in SSR scenarios.

API

Props

PropDescriptionTypeDefault
v-model / model-valueBinding valueDate | string | number | Array
typeDisplay typeDatePickerType'date'
cell-shapeCell shape'round' | 'square''round'
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
clearableWhether to show clear buttonbooleantrue
sizeSize'large' | 'default' | 'small''default'
placeholderPlaceholder when not in range modestring'Please select date'
start-placeholderPlaceholder for start date in range modestring'Start date'
end-placeholderPlaceholder for end date in range modestring'End date'
formatFormat displayed in the input boxstring
value-formatFormat of the binding valuestring
date-formatDate format displayed on the panelstring'YYYY-MM-DD'
time-formatTime format displayed on the panelstring'HH:mm:ss'
range-separatorSeparator when choosing rangestring'-'
first-day-of-weekFirst day of week (1-7)number7
disabled-dateDisabled dates function(date: Date) => boolean
presetsQuick optionsDatePickerPreset[][]
preset-positionPosition of quick options'left' | 'right' | 'top' | 'bottom''bottom'
show-footerWhether to show operation bar at bottombooleantrue
statusInput box status'success' | 'warning' | 'error'
order-on-confirmWhether to auto-sort during range selectionbooleanfalse
prefix-iconCustom prefix iconstring | Component
clear-iconCustom clear iconstring | Component
default-valueDate shown by default when opening the pickerDate | Date[]
default-timeDefault time (in datetime mode)Date | Date[]
panel-onlyWhether to display inline (panel only)booleanfalse
cell-renderCustom cell rendering function(date: Date) => string | { text: string; className?: string }
teleportedWhether to insert the panel into bodybooleantrue
popper-classPopover class namestring
validate-eventWhether to trigger form validationbooleantrue

Events

Event NameDescriptionParameters
update:modelValueTriggered when binding value is updated(value: DateValue | DateRangeValue) => void
changeTriggered when value changes(value: DateValue | DateRangeValue) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered when clear button is clicked() => void
confirmTriggered when confirm button is clicked(value: DateValue | DateRangeValue) => void
panel-changeTriggered when panel view switches(value: Date, mode: PanelView) => void
visible-changeTriggered when panel visibility changes(visible: boolean) => void

Slots

Slot NameDescription
prefix-iconCustom input prefix icon
clear-iconCustom clear icon
extraExtra content in the panel
date-cellCustom date cell (Scope: { cell: CalendarCell })
footerCustom footer area

Theme Variables

All color variables are connected to the global theme system and automatically support dark mode:

VariableDescriptionDefault
--yh-date-picker-widthRegular input box width220px
--yh-date-picker-range-widthRange input box width400px
--yh-date-picker-primaryMain theme colorvar(--yh-color-primary)
--yh-date-picker-text-mainMain text colorvar(--yh-text-color-primary)
--yh-date-picker-text-secondarySecondary text colorvar(--yh-text-color-secondary)
--yh-date-picker-borderBorder colorvar(--yh-border-color)
--yh-date-picker-panel-widthPanel physical width380px
--yh-date-picker-panel-bgPanel background colorvar(--yh-bg-color-overlay)
--yh-date-picker-panel-shadowPanel shadowvar(--yh-shadow-lg)
--yh-date-picker-item-hoverHover background colorvar(--yh-fill-color-light)
--yh-date-picker-range-bgRange background colorvar(--yh-color-primary-light-9)

Released under the MIT License.