Skip to content

Calendar Component

Calendar Component

Calendar component is used to display and select dates, supporting multiple view modes, date formatting, and custom styles.

Basic Usage

The simplest usage is to provide a two-way bound date value. The component will display the current month's calendar and allow date selection.

Currently selected date: 2025/11/10 16:31:35

Show CodeArrow
CopyGitHub

Different View Modes

Calendar component supports three view modes: date (date), month (month), year (year), which can be specified through the mode attribute.

Date Mode

Month Mode

Year Mode

Date Mode: 2025/11/10 16:31:35

Month Mode: 2025/11/10 16:31:35

Year Mode: 2025/11/10 16:31:35

Show CodeArrow
CopyGitHub

Format Output

Calendar component supports specifying the output format of dates through the value-format attribute. The component will return a string in the specified format instead of a Date object.

Date Format (YYYY-MM-DD)

DateTime Format (YYYY-MM-DD HH:mm:ss)

Custom Format (DD/MM/YYYY)

Date Format: 2023-07-15 (Type: string)

DateTime Format: 2023-07-15 12:30:00 (Type: string)

Custom Format: 15/07/2023 (Type: string)

Show CodeArrow
CopyGitHub

Custom Date Cells

Customize the content and style of date cells through the date slot, allowing you to add holiday markers, event markers, etc.

Currently selected date: 2025/11/10 16:31:35

Weekend/Holiday
Currently Selected
Show CodeArrow
CopyGitHub

Disabled Dates

Through the disabled-date attribute, you can specify which dates are not selectable. This attribute accepts a function that returns true to disable.

Disable dates before today

Disable weekends

Disabled before today: 2025/11/10 16:31:35

Disabled weekends: 2025/11/10 16:31:35

Disabled rules description:
- First calendar: dates before today are disabled
- Second calendar: weekends (Saturday and Sunday) are disabled
Show CodeArrow
CopyGitHub

Time Picker

By setting the show-time attribute, you can enable time selection functionality to select both date and time simultaneously.

With Time Picker

Disabled Time View (Auto sync current time)

Enabled Time View (Manual time selection)

With Time Picker: 2025-11-10 16:31:35

Disabled Time View: 2025-11-10 16:31:35

Enabled Time View: 2025-11-10 16:31:35

Description:
- Disabled Time View: No time selection panel after clicking date, uses current system time
- Enabled Time View: Shows time selection panel after clicking date, allows manual time selection
Show CodeArrow
CopyGitHub

Through the footer slot, you can customize the calendar footer content, such as adding shortcut buttons.

Currently selected date: 2025/11/10 16:31:35

Current panel mode: date

Event Log:
Show CodeArrow
CopyGitHub

Calendar API

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
v-modelBinding valueDate / string / number
modeCalendar modestringdate / month / yeardate
disabledWhether disabledbooleanfalse
disabled-dateUnselectable datesfunction(date: Date)
show-timeWhether to show time pickerbooleanfalse
disabled-time-viewWhether to disable time selection viewbooleantrue
value-formatValue format, e.g., YYYY-MM-DDstring
is-selectWhether dates can be selectedbooleantrue

Events

Event NameDescriptionCallback Parameters
changeDate change(value: Date / string / number)
panel-changePanel mode change(mode: 'date' / 'month' / 'year')
jump-to-dateJump to specified date(date: Date)
time-changeTime change(date: Date)
time-dialog-openTime dialog open
time-dialog-closeTime dialog close

Slots

Slot NameDescriptionScope Parameters
dateCustom date cell content{ date: Date }
monthCustom month cell content{ month: number, index: number }
yearCustom year cell content{ year: number }
footerCustom calendar footer content
time-pickerCustom time picker

Methods

The component exposes the following methods, which can be called through ref:

Method NameDescriptionParameters
jumpToDateJump to specified date(date: Date)
switchPanelModeSwitch panel mode(mode: 'date' / 'month' / 'year')
currentYearGet current year (computed property)-
currentMonthGet current month (computed property)-
tempModeGet current temporary mode-

Style Variables

Calendar component uses the following style variables, which can be customized through CSS variables:

Variable NameDescriptionDefault Value
--t-calendar-bg-colorCalendar background color#fff
--t-calendar-border-colorCalendar border color#e4e7ed
--t-calendar-text-colorCalendar text color#303133
--t-calendar-date-hover-bgDate hover background color#f2f6fc
--t-calendar-date-active-bgDate active background color#409eff
--t-calendar-date-active-colorDate active text color#fff
--t-calendar-disabled-bgDisabled date background color#f5f7fa
--t-calendar-disabled-colorDisabled date text color#c0c4cc

Released under the MIT License