Skip to content

CalendarView

Provides single selection, multiple selection, range, week/month, and datetime calendar selection capabilities. Can be used as a underlying panel component for business calendar selectors.

Performance Tip

It is not recommended to set too large a difference between min-date and max-date. If you need a large time span, it is recommended to use switch-mode (month / year-month) to reduce rendering pressure.

Component Type

Single Date Selection

html
<wd-calendar-view type="date" v-model="value" @change="handleChange" />

Multiple Date Selection

html
<wd-calendar-view type="dates" v-model="value" @change="handleChange" />

Date Range Selection

html
<wd-calendar-view type="daterange" v-model="value" @change="handleChange" />

Date Time Type

html
<wd-calendar-view type="datetime" v-model="value" @change="handleChange" />
<wd-calendar-view type="datetimerange" v-model="valueRange" @change="handleChange" />

Week and Month Type

html
<wd-calendar-view type="week" v-model="value" :first-day-of-week="1" @change="handleChange" />
<wd-calendar-view type="month" v-model="value" @change="handleChange" />
<wd-calendar-view type="weekrange" v-model="valueRange" @change="handleChange" />
<wd-calendar-view type="monthrange" v-model="valueRange" @change="handleChange" />

Component State

Range Selection Allow Same Day

html
<wd-calendar-view type="daterange" v-model="valueRange" allow-same-day @change="handleChange" />

Component Variant

Switch Mode

Set switch-mode to control panel switch behavior:

  • none: Display all months/years flatly without switch buttons
  • month: Support month switching with previous/next month buttons
  • year-month: Support year and month switching with previous/next year, previous/next month buttons
html
<wd-calendar-view type="date" v-model="value" switch-mode="month" @change="handleChange" />

Component Style

Format Date

Set formatter to customize date cell text and status.

html
<wd-calendar-view type="daterange" v-model="valueRange" allow-same-day :formatter="formatter" @change="handleChange" />

Set Week Start Day

html
<wd-calendar-view :first-day-of-week="1" v-model="value" @change="handleChange" />

Show Panel Title

html
<wd-calendar-view type="daterange" :show-panel-title="false" v-model="valueRange" @change="handleChange" />

Special Style

Max Range Limit

html
<wd-calendar-view type="daterange" :max-range="3" v-model="valueRange" @change="handleChange" />

Time Option Filter

Set hide-second and time-filter to filter hour/minute/second options.

html
<wd-calendar-view type="datetime" v-model="value" hide-second :time-filter="timeFilter" @change="handleChange" />

Attributes

ParameterDescriptionTypeDefault Value
v-modelSelected value, 13-digit timestamp or timestamp arraynumber | number[] | null-
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
show-panel-titleWhether to show panel titlebooleantrue
default-timeDefault time for datestring | string[]00:00:00
panel-heightScrollable panel heightnumber316
time-filterTime option filter function (datetime / datetimerange)CalendarTimeFilter-
time-item-heightTime option heightnumber44
time-visible-item-countTime visible item countnumber3
hide-secondWhether to hide second selection (datetime / datetimerange)booleanfalse
immediate-changeWhether to trigger time selection change event when finger is releasedbooleanfalse
switch-modeSwitch mode: 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
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

Events

Event NameDescriptionParameters
changeTriggered when panel value changes{ value }
pickstartTriggered when time selection scroll starts-
pickendTriggered when time selection scroll ends-

Methods

Method NameDescriptionParameters
scrollIntoViewScroll current date or selected date into visible area (recommended to call when panel shows from hidden)-

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-view-panel-title-font-size$typography-body-size-main-
--wot-calendar-view-panel-title-line-height$typography-body-line--height-size-main面板标题字号
--wot-calendar-view-panel-title-color$text-main面板标题行高
--wot-calendar-view-panel-title-padding$padding-extra-tight $padding-loose面板标题文字颜色
--wot-calendar-view-panel-title-font-weight$font-weight-medium面板标题内边距
--wot-calendar-view-panel-title-margin$spacing-super-tight $spacing-zero面板标题字重
--wot-calendar-view-weeks-padding$padding-tight $spacing-loose面板标题外边距
--wot-calendar-view-week-color$text-secondary星期栏内边距
--wot-calendar-view-week-font-size$typography-body-size-main星期文字颜色
--wot-calendar-view-week-line-height$typography-body-line--height-size-main星期文字字号
--wot-calendar-view-day-font-size$typography-body-size-extra-large星期文字行高
--wot-calendar-view-day-color$text-main日期单元字号
--wot-calendar-view-day-font-weight$font-weight-medium日期单元文字颜色
--wot-calendar-view-day-height$n-60日期单元字重
--wot-calendar-view-month-width$n-60日期单元高度
--wot-calendar-view-month-height$n-60月份单元宽度
--wot-calendar-view-month-font-weight$font-weight-medium月份单元高度
--wot-calendar-view-color-active$primary-6月份单元字重
--wot-calendar-view-color-selected$text-white激活态颜色
--wot-calendar-view-color-disabled$text-disabled选中态文字颜色
--wot-calendar-view-range-bg$primary-2禁用态文字颜色
--wot-calendar-view-range-color$text-main区间态背景色
--wot-calendar-view-border-radius-active$radius-main区间态文字颜色
--wot-calendar-view-info-font-size$typography-label-size-extra-small激活态圆角
--wot-calendar-view-info-line-height$typography-label-line--height-size-extra-small顶部/底部辅助信息字号
--wot-calendar-view-info-position$spacing-extra-tight顶部/底部辅助信息行高
--wot-calendar-view-item-margin-bottom$spacing-super-tight顶部/底部辅助信息偏移位置
--wot-calendar-view-item-padding$padding-zero $spacing-loose日期/月份单元底部间距
--wot-calendar-view-time-picker-font-size$typography-body-size-extra-large日期/月份容器内边距
--wot-calendar-view-time-picker-color$text-main时间选择器字号
--wot-calendar-view-time-picker-bg$filled-content时间选择器文字颜色
--wot-calendar-view-time-label-height$n-44时间选择器背景色
--wot-calendar-view-time-label-border$stroke-main solid $border-main时间标签高度
--wot-calendar-view-controls-padding$padding-loose时间标签分隔边框
--wot-calendar-view-control-icon-color$icon-secondary面板控制栏内边距
--wot-calendar-view-control-icon-size$n-20控制栏图标颜色
--wot-calendar-view-control-icon-spacing$spacing-extra-loose控制栏图标尺寸
--wot-calendar-view-control-color-disabled$icon-disabled控制栏图标间距
--wot-calendar-view-time-box-shadow$n-0 (-$n-4) $n-8 $n-0 $opac-1_02控制栏禁用图标颜色

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.