CalendarView
A local-date calendar for single, multiple and range selection. The first range endpoint updates the draft only.
Import
With uni-app easycom, use hui-calendar-view。 Standalone Vue imports @nscode/handy-uni/web HuiCalendarView or installs the preview plugin.
Examples
Interaction and event results
Interact with the control. The latest event and its full payload are shown below. Popup selectors commit only after confirmation; cancellation keeps the previous value.
vue
<script setup lang="ts">
import { ref } from 'vue'
const result = ref('')
const value = ref([])
function event0(arg0: unknown) {
result.value = 'update:modelValue' + ': ' + JSON.stringify([arg0])
}
function event1(arg0: unknown, arg1: unknown) {
result.value = 'change' + ': ' + JSON.stringify([arg0, arg1])
}
function event2(arg0: unknown, arg1: unknown) {
result.value = 'select' + ': ' + JSON.stringify([arg0, arg1])
}
function event3(arg0: unknown) {
result.value = 'update:month' + ': ' + JSON.stringify([arg0])
}
function event4(arg0: unknown) {
result.value = 'over-range' + ': ' + JSON.stringify([arg0])
}
</script>
<template>
<view>
<hui-calendar-view
v-model="value"
select-mode="range"
default-month="2026-11"
min="2026-11-01"
max="2027-12-31"
:max-range="7"
@update:model-value="event0"
@change="event1"
@select="event2"
@update:month="event3"
@over-range="event4"
></hui-calendar-view>
<text aria-live="polite">{{ result }}</text>
</view>
</template>
Props
| Property | Type | Default | Description |
|---|---|---|---|
model-value | CalendarModelValue | undefined | undefined | Controlled committed value; display remains unchanged until the parent writes back. |
default-value | CalendarModelValue | undefined | null | Initial uncontrolled value. |
select-mode | CalendarSelectMode | undefined | 'single' | single, multiple or range selection. |
value-format | string | undefined | 'YYYY-MM-DD' | Model format string, timestamp or date. |
min | CalendarValue | undefined | — | Lower value bound, or minimum count for multiple selection. |
max | CalendarValue | undefined | — | Upper bound, star count for Rate, or maximum multiple-selection count. |
disabled-date | ((date: Date) => boolean) | undefined | — | Return true to disable a date. |
month | string | undefined | — | Controlled displayed month, YYYY-MM. |
default-month | string | undefined | — | Initial displayed month, YYYY-MM. |
first-day-of-week | number | undefined | 7 | First weekday: 1 for Monday through 7 for Sunday. |
max-range | number | undefined | — | Maximum inclusive range span, measured in calendar days, months or years. |
allow-same-day | boolean | undefined | true | Allow the same start and end day. |
max-count | number | undefined | — | Maximum selected date count. |
formatter | ((day: CalendarDay) => Partial<Pick<CalendarDay, "disabled" | "topText" | "bottomText" | "className">>) | undefined | — | Format calendar cells using the latest callback when dates recalculate or reset is called. |
readonly | boolean | undefined | false | Readonly; inherit form context when omitted. |
custom-class | string | undefined | '' | Additional root classes. |
custom-style | string | CSSProperties | undefined | — | Additional root styles. |
Events
| Event | Parameters | Description |
|---|---|---|
update:modelValue | (value: CalendarModelValue) | Requests a controlled value update. |
change | (value: CalendarModelValue, context: { dates: Date[]; }) | Reports change with the arguments shown in the example. |
select | (value: CalendarModelValue, context: { dates: Date[]; }) | Reports select with the arguments shown in the example. |
update:month | (month: string) | Requests a controlled value update. |
over-range | (info: { reason: "max-range" | "max-count"; }) | Reports over-range with the arguments shown in the example. |
Slots
| Slot | Description |
|---|---|
header | Month header scope: {month,prev,next,canPrev,canNext}. |
day | Calendar cell scope: {day}. |
Methods
| Method | Signature |
|---|---|
scrollToMonth | (month: string) => void |
reset | () => void |
Types
CalendarViewProps、CalendarViewEmits、CalendarViewExpose。 Public types are exported from the package entry.
Platform notes
| Scope | Behavior and validation limits |
|---|---|
| Shared implementation | Renders the date grid with ordinary component nodes. Date calculations and single, multiple and range selection are shared. |
| Device checks pending | Check scrolling across long month ranges, date taps and range messages; verify touch targets and screen readers on devices. |
See examples/uni-demo/smoke/CalendarView.md for the checklist. Unit tests do not replace device acceptance.