Skip to content

Calendar ​

Provides single selection, multiple selection, range, week/month, and datetime calendar selection capabilities.

Performance Tip

It is not recommended to set too large a difference between min-date and max-date, as it may affect performance due to heavy date calculations. If you need a large time span, it is recommended to use switch-mode (e.g., month / year-month) to reduce rendering pressure.

Component Type ​

Single Date Selection ​

html
<wd-cell-group border>
  <wd-cell title="Single Date Selection" :value="formatValue(value1, 'date')" is-link @click="show1 = true" />
</wd-cell-group>
<wd-calendar v-model="value1" v-model:visible="show1" @confirm="handleConfirm" />

Multiple Date Selection ​

html
<wd-cell-group border>
  <wd-cell title="Multiple Date Selection" :value="formatValue(value2, 'dates')" is-link @click="show2 = true" />
</wd-cell-group>
<wd-calendar type="dates" v-model="value2" v-model:visible="show2" />

Range Selection ​

html
<wd-cell-group border>
  <wd-cell title="Date Range Selection" :value="formatValue(value3, 'daterange')" is-link @click="show3 = true" />
</wd-cell-group>
<wd-calendar type="daterange" v-model="value3" v-model:visible="show3" />

Date Time Type ​

html
<wd-cell-group border>
  <wd-cell title="Date Time Selection" :value="formatValue(value4, 'datetime')" is-link @click="show4 = true" />
</wd-cell-group>
<wd-calendar type="datetime" v-model="value4" v-model:visible="show4" />
html
<wd-cell-group border>
  <wd-cell title="Date Time Range Selection" :value="formatValue(value5, 'datetimerange')" is-link @click="show5 = true" />
</wd-cell-group>
<wd-calendar type="datetimerange" v-model="value5" v-model:visible="show5" />

Week and Month Type ​

html
<wd-cell-group border>
  <wd-cell title="Week Selection" :value="formatValue(value6, 'week')" is-link @click="show6 = true" />
</wd-cell-group>
<wd-calendar type="week" v-model="value6" v-model:visible="show6" />
html
<wd-cell-group border>
  <wd-cell title="Month Selection" :value="formatValue(value7, 'month')" is-link @click="show7 = true" />
</wd-cell-group>
<wd-calendar type="month" :min-date="minDate" v-model="value7" v-model:visible="show7" />

Week Range and Month Range Selection ​

html
<wd-cell-group border>
  <wd-cell title="Week Range Selection" :value="formatValue(value8, 'weekrange')" is-link @click="show8 = true" />
</wd-cell-group>
<wd-calendar :first-day-of-week="1" type="weekrange" v-model="value8" v-model:visible="show8" />
html
<wd-cell-group border>
  <wd-cell title="Month Range Selection" :value="formatValue(value9, 'monthrange')" is-link @click="show9 = true" />
</wd-cell-group>
<wd-calendar type="monthrange" v-model="value9" v-model:visible="show9" />

Component State ​

Quick Operation ​

After setting show-confirm="false", confirmation occurs on selection.

html
<wd-cell-group border>
  <wd-cell title="Quick Operation" :value="formatValue(value16, 'date')" is-link @click="show16 = true" />
</wd-cell-group>
<wd-calendar v-model="value16" v-model:visible="show16" :show-confirm="false" />

before-confirm ​

Set before-confirm to intercept before confirmation, returning false or Promise<false> can prevent confirmation.

html
<wd-cell-group border>
  <wd-cell title="before-confirm" :value="formatValue(value14, 'date')" is-link @click="show14 = true" />
</wd-cell-group>
<wd-calendar v-model="value14" v-model:visible="show14" :before-confirm="beforeConfirm" />

Component Variant ​

Switch Mode ​

Set switch-mode to control panel switch behavior:

  • none: Display flatly without switch buttons
  • month: Switch by month
  • year-month: Support switching by year and month
html
<wd-radio-group v-model="switchMode" type="button">
  <wd-radio value="none">none</wd-radio>
  <wd-radio value="month">month</wd-radio>
  <wd-radio value="year-month">year-month</wd-radio>
</wd-radio-group>

Day/Week/Month Switch ​

Set show-type-switch to enable day/week/month switching.

html
<wd-cell-group border>
  <wd-cell title="Day/Week/Month Switch" :value="formatValue(value10, 'date')" is-link @click="show10 = true" />
</wd-cell-group>
<wd-calendar :first-day-of-week="1" show-type-switch v-model="value10" v-model:visible="show10" :switch-mode="switchMode" />

Component Style ​

Date Formatting ​

Set formatter to customize date cell text and status display.

html
<wd-cell-group border>
  <wd-cell title="Date Formatting" :value="formatValue(value11, 'daterange')" is-link @click="show11 = true" />
</wd-cell-group>
<wd-calendar type="daterange" v-model="value11" v-model:visible="show11" :formatter="formatter" />

Custom Display ​

Set inner-display-format to customize the start/end text in range selection panel.

html
<wd-cell-group border>
  <wd-cell title="Custom Display" :value="displayFormat(value13)" is-link @click="show13 = true" />
</wd-cell-group>
<wd-calendar
  type="daterange"
  v-model="value13"
  v-model:visible="show13"
  :inner-display-format="innerDisplayFormat"
/>

Special Style ​

Shortcut Options ​

Set shortcuts and on-shortcuts-click to implement shortcut date ranges.

html
<wd-cell-group border>
  <wd-cell title="Shortcut Options" :value="formatValue(value12, 'daterange')" is-link @click="show12 = true" />
</wd-cell-group>
<wd-calendar
  :shortcuts="shortcuts"
  :on-shortcuts-click="onShortcutsClick"
  type="daterange"
  v-model="value12"
  v-model:visible="show12"
/>

Extend Confirm Area ​

Extend confirm area buttons through confirm-left / confirm-right slots.

html
<wd-cell-group border>
  <wd-cell title="Extend Confirm Area" :value="formatValue(value19, 'date')" is-link @click="show19 = true" />
</wd-cell-group>
<wd-calendar v-model="value19" v-model:visible="show19">
  <template #confirm-right>
    <wd-button block plain custom-style="margin-left: 10px;" @click="selectToday">Select Today</wd-button>
  </template>
</wd-calendar>

Attributes ​

ParameterDescriptionTypeDefault Value
v-modelSelected value, 13-digit timestamp or timestamp arraynumber | number[] | null-
v-model:visibleWhether to show popupbooleanfalse
typeDate type, supports date / dates / datetime / week / month / daterange / datetimerange / weekrange / monthrangestringdate
min-dateMinimum date timestampnumber6 months before current date
max-dateMaximum date timestampnumber6 months after current date
first-day-of-weekWeek start day (0 means Sunday)number0
formatterDate formatting functionCalendarFormatter-
max-rangeMaximum selectable range for range typesnumber-
range-promptPrompt text when exceeding maximum rangestring-
allow-same-dayWhether to allow same day/week/month for range typesbooleanfalse
default-timeDefault time for datestring | string[]-
time-filterTime option filter function (datetime / datetimerange)CalendarTimeFilter-
hide-secondWhether to hide second selection (datetime / datetimerange)booleanfalse
titlePopup titlestringSelect Date (built-in text)
close-on-click-modalWhether to close when clicking maskbooleantrue
z-indexPopup z-indexnumber15
show-confirmWhether to show confirm buttonbooleantrue
confirm-textConfirm button textstringConfirm (built-in text)
inner-display-formatCustom range panel internal displayCalendarInnerDisplayFormat-
ellipsisWhether to omit range text displaybooleanfalse
show-type-switchWhether to show day/week/month switchbooleanfalse
shortcutsShortcut option list (items need to contain text)Record<string, any>[][]
on-shortcuts-clickShortcut option click callbackCalendarOnShortcutsClick-
safe-area-inset-bottomWhether to enable bottom safe areabooleantrue
before-confirmValidation function before confirmCalendarBeforeConfirm-
custom-view-classPanel internal view class namestring''
immediate-changeWhether to trigger time selection change event when finger is releasedbooleanfalse
root-portalWhether to render outside pagebooleanfalse
panel-heightScrollable panel heightnumber316
show-panel-titleWhether to show scroll panel titlebooleantrue
switch-modeSwitch mode, optional values are none, month, year-month. none displays all months/years flatly without switch buttons; month supports month switching with previous/next month buttons; year-month supports year and month switching with previous/next year, previous/next month buttons. For large date spans, it is recommended to use month or year-month to reduce rendering pressurestringnone
durationPopup animation durationnumber200
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

Events ​

Event NameDescriptionParameters
confirmTriggered after clicking confirm{ value, type }
changeTriggered when panel date changes{ value }
cancelTriggered when closed without confirmation-
openTriggered when calendar opens-

Methods ​

Method NameDescriptionParameters
openOpen calendar popup-
closeClose calendar popup-

Slots ​

nameDescription
confirm-leftConfirm area left slot
confirm-rightConfirm area right slot

CalendarDayItem Data Structure ​

PropertyDescriptionType
typeDate status typeCalendarDayType
date13-digit timestampnumber
textDate text contentstring
topInfoTop tip infostring
bottomInfoBottom tip infostring
disabledWhether disabledboolean

CalendarDayType ​

TypeDescription
selectedSingle date selected
startRange start date
endRange end date
middleDates between range start and end
sameRange start and end dates are the same
currentCurrent date
multiple-middleMultiple date range selection, dates between start and end
multiple-selectedMultiple date range selection, selected dates

主题定制 ​

CSS 变量 ​

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置。

名称默认值描述
--wot-calendar-bg$filled-oppo-
--wot-calendar-tabs-width100%日历弹层背景色
--wot-calendar-tabs-padding$padding-zero $padding-extra-looseTabs 宽度
--wot-calendar-shortcuts-padding$padding-extra-tight $padding-zeroTabs 内边距
--wot-calendar-tag-spacing-right$spacing-extra-loose快捷选项内边距
--wot-calendar-range-padding$padding-zero $padding-loose $padding-extra-loose标签右间距
--wot-calendar-range-font-size$typography-body-size-main范围标签内边距
--wot-calendar-range-item-font-size$typography-body-size-extra-large范围标签字号
--wot-calendar-range-item-font-weight$font-weight-medium范围标签项字号
--wot-calendar-range-item-line-height$typography-body-line-height-size-extra-large范围标签项字重
--wot-calendar-range-item-padding$spacing-loose $spacing-zero范围标签项行高
--wot-calendar-range-item-color$primary-6范围标签项内边距
--wot-calendar-range-item-color-placeholder$text-placeholder范围标签项颜色
--wot-calendar-range-item-line-color$primary-6占位符颜色
--wot-calendar-range-item-line-color-placeholder$border-main范围标签项下划线颜色
--wot-calendar-range-separator-margin$spacing-zero $spacing-tight范围标签项下划线占位符颜色
--wot-calendar-range-separator-color$text-auxiliary分隔符水平间距
--wot-calendar-range-separator-width$n-8分隔符颜色
--wot-calendar-range-separator-height$stroke-main分隔符宽度
--wot-calendar-confirm-padding$padding-tight $padding-loose分隔符高度
--wot-calendar-confirm-border-color$border-light确认区域内边距

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.