Component

Calendar

安装 Installation

npx timkit add calendar --yes --framework react

用法 Usage

import { Calendar } from "@/components/ui/calendar"

className 与 variant、size 可以一起用。字段以 timkit agent inspect calendar --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

24 / 24

Calendar Date Picker · Interactive State · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

calendar

Logic

zag / date-picker

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
date-pickerUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
@internationalized/dateOptional peer dependencies used by this registry item.
registryDependencies
array
buttonDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
mode
enum (single | range | multiple)
singleThe selection mode.
disabled
boolean
falseWhen true, date changes are ignored.
readOnly
boolean
falseWhen true, dates can be focused but not changed.
value
array
-The controlled selected dates.

Events

PropTypeDefaultDescription
onValueChange
event
-Event handler called when the selected dates change.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
modelValue
CalendarVueValue
-The controlled value bound via `v-model` (Vue specific).
defaultValue
CalendarVueValue
-The default value of the component when uncontrolled.
month
Date
-The controlled display month.
defaultMonth
Date
-The default display month for uncontrolled usage.
startMonth
Date
-The earliest month that can be navigated to.
endMonth
Date
-The latest month that can be navigated to.
pagedNavigation
boolean
-Enables paged navigation by month groups.
captionLayout
enum (label | dropdown | dropdown-years)
-Controls the caption layout.
hideNavigation
boolean
-Hides previous/next navigation controls.
fixedWeeks
boolean
-Renders a fixed number of weeks.
showWeekNumber
boolean
-Shows week numbers.
showOutsideDays
boolean
-When `true`, displays dates from the previous and next months that fall in the calendar grid.
numberOfMonths
number
-The number of months to display simultaneously.
minDate
Date
-The minimum allowed date.
maxDate
Date
-The maximum allowed date.
excludeDisabled
boolean
-When `true`, range selection excludes spans that include unavailable dates.
onMonthChange
event
-Callback fired when the visible month changes.
isDateUnavailable
event
-Callback to determine whether a given date should be marked as unselectable.

Slots

PropTypeDefaultDescription
default
slot
-Default slot content rendered inside the component root.

Parts

PropTypeDefaultDescription
root*
root
-The calendar container
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowRight moves the focused day.
  • ArrowDown moves to the same weekday in the next week.
  • ArrowUp moves to the same weekday in the previous week.
  • Home moves to the first day of the visible month.
  • End moves to the last.
  • PageUp moves to the previous month.
  • PageDown moves to the next month.
  • Shift with PageUp moves to the previous year.
  • Shift with PageDown moves to the next year.
  • None of these keys selects a day.
  • Enter selects the focused day.
  • Enter or Space on Switch to previous month and Switch to next month changes the month.
  • When read-only, the day can still be focused, but selection does not change.
  • A disabled calendar ignores those keys.
  • The selected day is visible as YYYY-MM-DD.
  • Several selected days are separated by to.
  • An empty value has no day status.
  • The visible month names the grid.
  • Weekday names are column headers.
  • Each week is a row.
  • Month buttons sit outside the grid.
  • Each day is named with its full date.
  • Each day exposes whether it is selected.
  • The focused day is in the tab order.
  • The other days are not.
  • A disabled calendar leaves the days and the month buttons out of the tab order.
  • A disabled day is not in the tab order.
  • In static HTML, only the selected day stays in the tab order.
  • In static HTML, the month grid uses tabindex -1.
  • In static HTML, each day is a button.
  • Today uses aria-current date.
  • On the mini program, the month grid uses tabindex -1.
  • On the mini program, the month grid sets aria-disabled and aria-readonly.
  • On the mini program, the month grid is described as calendar month.
  • A range calendar sets aria-multiselectable.
  • Each row sets aria-disabled when the calendar is disabled.
  • Calendar RAC uses the calendar.
  • The selected day is visible as YYYY-MM-DD.
  • An empty value has no day status.

行为契约

Contract

props、默认值和运行时状态。

  • Single mode keeps one day.
  • Multiple mode keeps every selected day.
  • Range mode keeps a start and an end.
  • A disabled or read-only calendar ignores selection.
  • Month changes stop at startMonth and endMonth.