Skip to content

DatePicker

YhDatePicker is a unified date input component for day, week, month, quarter, year, and range selection. It also supports inline panel rendering, custom cell content, presets, and token-based theming.

Showcase

Set panel-only to render the calendar panel inline. This is useful for dashboards, side panels, or custom layouts that do not need the input shell.

Mode:
Cell Shape:
<div class="demo-viewport">
  <yh-date-picker :key="demoType + demoShape" v-model="demoValue" :type="demoType" :cell-shape="demoShape" panel-only />
</div>

<div class="demo-result">
  <span class="dot"></span>
  <span class="label">Selected:</span>
  <span class="val">Not selected</span>
</div>
Showcase

Basic Usage

Switch the picker mode with the type prop.

Basic Usage

Advanced Configuration

Use slots and auxiliary props to customize icons, default panel anchoring, and date-time formatting.

Advanced Configuration

Cell Shape

Use cell-shape to switch between round and square cells.

Cell Shape

Custom Cell Content

Use cell-render for lightweight label decoration, or the date-cell slot when you need full custom cell markup.

Custom Cell Content

Disabled and Readonly

disabled prevents interaction, while readonly keeps the current value visible but does not allow opening the panel.

Disabled and Readonly

Sizes

The component follows the shared size system: large, default, and small.

Sizes

Presets

Use presets to provide quick-pick actions in the panel footer area.

Presets

Disabled Dates

Control selectable dates with disabled-date.

Disabled Dates

Range Selection

Range-related types such as daterange and monthrange use a two-value model.

-
-
Range Selection

Use in Nuxt

After installing @yh-ui/nuxt, YhDatePicker can be used directly in Nuxt 3/4 pages and components. The panel still relies on client interaction, but the input shell renders correctly in SSR.

Use in Nuxt

API

Props

PropDescriptionTypeDefault
model-value / v-modelBound valueYhDatePickerValue | YhDatePickerRangeValuenull
typePicker mode'date' | 'datetime' | 'year' | 'month' | 'week' | 'quarter' | 'daterange' | 'datetimerange' | 'monthrange' | 'yearrange' | 'quarterrange''date'
disabledDisable the componentbooleanfalse
readonlyKeep the input read-only and prevent opening the panelbooleanfalse
clearableShow the clear icon when a value existsbooleantrue
sizeComponent size'large' | 'default' | 'small''default'
placeholderPlaceholder in non-range mode. When omitted, locale text is usedstringundefined
start-placeholderStart placeholder in range mode. When omitted, locale text is usedstringundefined
end-placeholderEnd placeholder in range mode. When omitted, locale text is usedstringundefined
formatDisplay format used in the inputstring''
value-formatOutput format used for the bound valuestring''
date-formatPanel date formatstring'YYYY-MM-DD'
time-formatPanel and footer time formatstring'HH:mm:ss'
range-separatorSeparator between range inputsstring'-'
first-day-of-weekFirst day of the week, 1 to 7number7
disabled-dateDisable specific dates(date: Date) => booleanundefined
presetsPreset actions shown in the panelYhDatePickerPreset[][]
preset-positionReserved preset position option. The current implementation still renders presets below the panel'left' | 'right' | 'top' | 'bottom''bottom'
show-footerControl footer visibilitybooleantrue
statusVisual status style'success' | 'warning' | 'error'undefined
order-on-confirmAuto-order range values when the end date is earlier than the start datebooleanfalse
prefix-iconCustom prefix icon component or stringstring | Component''
clear-iconCustom clear icon component or stringstring | Component''
default-valueDefault panel anchor date when openingDate | Date[]undefined
panel-onlyRender the panel inline without the input shellbooleanfalse
default-timeDefault time value for datetime workflowsDate | Date[]undefined
popper-classExtra class name for the floating panelstring''
teleportedTeleport the panel to bodybooleantrue
validate-eventTrigger form validation after value changesbooleantrue
nameNative form field namestring''
idNative form field idstring''
cell-shapeDate cell shape'round' | 'square''round'
cell-renderCustom date cell text renderer(date: Date) => string | { text: string; className?: string }undefined
theme-overridesComponent theme override variablesComponentThemeVarsundefined

Events

The current implementation emits the following events at runtime:

EventDescriptionParameters
update:modelValueTriggered when the bound value changes(value: YhDatePickerValue | YhDatePickerRangeValue) => void
changeTriggered after the value changes(value: YhDatePickerValue | YhDatePickerRangeValue) => void
clearTriggered after the clear icon resets the value() => void
confirmTriggered when the confirm button is clicked(value: YhDatePickerValue | YhDatePickerRangeValue) => void

Slots

SlotDescriptionParameters
prefix-iconCustom prefix icon content-
clear-iconCustom clear icon content-
extraExtra content rendered above presets and footer-
date-cellCustom date cell content{ cell: CalendarCell }
footerCustom footer content-

Expose

The current implementation does not expose public instance methods or properties.

Type Exports

TypeDescription
YhDatePickerPropsComponent props type
YhDatePickerEmitsComponent emits type declaration
YhDatePickerSlotsComponent slot type declaration
YhDatePickerPresetPreset item type
YhDatePickerValueSingle value type
YhDatePickerRangeValueRange value type
YhDatePickerPanelViewPanel view type
YhDatePickerInstanceComponent instance type

Theme Variables

YhDatePicker consumes the following component-level CSS variables and also supports themeOverrides.

VariableDescriptionDefault
--yh-date-picker-widthDefault width220px
--yh-date-picker-range-widthRange width400px
--yh-date-picker-primaryPrimary colorvar(--yh-color-primary)
--yh-date-picker-primary-rgbPrimary RGB tokenvar(--yh-color-primary-rgb)
--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-shadowPanel shadowvar(--yh-shadow-lg)
--yh-date-picker-item-hoverHover backgroundvar(--yh-fill-color-light)
--yh-date-picker-range-bgRange backgroundvar(--yh-color-primary-light-9)
--yh-date-picker-panel-widthPanel width380px
--yh-date-picker-panel-bgPanel backgroundvar(--yh-bg-color-overlay)
--yh-date-picker-hover-bgHover state backgroundvar(--yh-date-picker-item-hover)
--yh-date-picker-active-bgActive cell backgroundvar(--yh-date-picker-primary)
--yh-date-picker-active-colorActive cell text colorvar(--yh-color-white)

Released under the MIT License.