WlCalendar
Selection
Selected: 2026-10-15
Last activation and count: · 0
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlCalendar, WlCheckbox } from "legato-ui";
import { computed, ref } from "vue";
const value = ref("2026-10-15");
const selected = ref(["2026-10-15", "2026-10-17"]);
const month = ref("2026-10");
const availability = ref(false);
const activated = ref("");
const activationCount = ref(0);
const disabledDates = computed(() => availability.value ? ["2026-10-16", "2026-10-18"] : []);
function activate(iso: string): void {
activated.value = iso;
activationCount.value += 1;
}
const multiple = computed(() => props.preview?.multiple === true);
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.multiple;
return attributes;
});
</script>
<template>
<div class="wl-stack" data-space="md">
<WlCheckbox v-model="availability">{{ "Disable October 16 and 18" }}</WlCheckbox>
<WlCalendar
v-if="multiple"
v-model="selected"
v-model:month="month"
multiple
:disabled-dates="disabledDates"
:events="[{ date: '2026-10-15', label: 'Overview', tone: 'blue' }]"
v-bind="forwardedPreview"
@date-select="activate"
>
<template #day="{ day, events, disabled }">
<span>{{ day }}</span><span v-if="events.length && !disabled" aria-hidden="true"> · {{ events.length }}</span>
</template>
</WlCalendar>
<WlCalendar
v-else
v-model="value"
v-model:month="month"
:disabled-dates="disabledDates"
:events="[{ date: '2026-10-15', label: 'Overview', tone: 'blue' }]"
v-bind="forwardedPreview"
@date-select="activate"
/>
<p class="wl-text-small" role="status">{{ "Selected:" }} {{ multiple ? selected.join(', ') : value }}</p>
<p class="wl-text-small" data-testid="calendar-activation">
{{ "Last activation and count:" }} {{ activated }} · {{ activationCount }}
</p>
</div>
</template>Date, month and events
Date and month models, events for the selected day, month navigation and returning to today.
Controlled date, month and events
The selected date and displayed month are separate models. Programmatic navigation sets both in this example.
Events on the selected day
- Planning
- Material review
Arrow keys move focus between days; Home/End within a week, PageUp/PageDown between months. Enter or Space selects a day.
Date: 2026-10-15. Month: 2026-10. Events: 2.
Full example
<script setup lang="ts">
import { WlButton, WlCalendar, type WlCalendarEvent } from "legato-ui";
import { computed, ref } from "vue";
const date = ref("2026-10-15");
const month = ref("2026-10");
const events: WlCalendarEvent[] = [
{ id: "planning", date: "2026-10-15", label: "Planning", tone: "blue" },
{ id: "review", date: "2026-10-15", label: "Material review", tone: "gray" },
{ id: "release", date: "2026-10-22", label: "Release preparation", tone: "blue" },
{ id: "next", date: "2026-11-03", label: "Next review", tone: "gray" }
];
const dayEvents = computed(() => events.filter((event) => event.date === date.value));
function selectRelease() {
date.value = "2026-10-22";
month.value = "2026-10";
}
function selectNextMonth() {
date.value = "2026-11-03";
month.value = "2026-11";
}
function selectToday() {
const today = new Date();
const pad = (value: number) => String(value).padStart(2, "0");
date.value = `${today.getFullYear()}-${pad(today.getMonth() + 1)}-${pad(today.getDate())}`;
month.value = date.value.slice(0, 7);
}
function reset() {
date.value = "2026-10-15";
month.value = "2026-10";
}
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlCalendar">
<section class="wl-stack" data-space="md" aria-label="Team calendar">
<h3 class="wl-text-subheading">{{ "Controlled date, month and events" }}</h3>
<WlCalendar v-model="date" v-model:month="month" :events="events" />
<p class="wl-text-small wl-text-muted">{{ "The selected date and displayed month are separate models. Programmatic navigation sets both in this example." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selectRelease">{{ "Go to release preparation" }}</WlButton>
<WlButton size="sm" @click="selectNextMonth">{{ "Go to November review" }}</WlButton>
<WlButton size="sm" variant="soft" @click="selectToday">{{ "Today" }}</WlButton>
<WlButton size="sm" @click="reset">{{ "Restore October" }}</WlButton>
</div>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Events on the selected day" }}</h3>
<ul v-if="dayEvents.length" class="wl-stack docs-calendar-events" data-space="sm">
<li v-for="event in dayEvents" :key="event.id">{{ event.label }}</li>
</ul>
<p v-else class="wl-text-small">{{ "No events on the selected day." }}</p>
<p class="wl-text-small wl-text-muted">{{ "Arrow keys move focus between days; Home/End within a week, PageUp/PageDown between months. Enter or Space selects a day." }}</p>
<p class="wl-text-small" role="status">{{ "Date:" }} {{ date }}{{
". Month:"
}} {{ month }}{{ ". Events:" }} {{ dayEvents.length }}.</p>
</section>
</div>
</template>
<style scoped>
.docs-calendar-events { margin: 0; padding-inline-start: var(--wl-space-lg); overflow-wrap: anywhere; }
</style>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: WlCalendarModel<Selected ISO date "YYYY-MM-DD" (default "").
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
events | readonly WlCalendarEvent[] | [] | WlCalendarEvent[]: { date (ISO), label, tone?: "blue" | "gray" }. |
disabledDates | WlDisabledDates | Not set | ISO date list or predicate identifying dates that cannot be activated. |
multiple | Multiple & boolean | false | Enable selection of more than one value. |
disabled | boolean | false | Disable user interaction with this component. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
dateSelect | [iso: string] | An enabled date was activated by pointer or keyboard, even when already selected. |
update:modelValue | WlCalendarModel< | Emitted when the component requests a model change; the payload is the next value. |
update:month | string | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
day | day?(props: WlCalendarDaySlotProps): unknown; | Custom calendar day content with its date and selection state. |
Pass-through: pt
Sections WlCalendar are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-cal | Main element of the component. |
header | div.wl-cal__head | Component heading area. |
prevButton | button.wl-cal__nav | Button that moves to the previous calendar month or view. |
title | span.wl-cal__title | Visible component heading. |
nextButton | button.wl-cal__nav | Button that moves to the next calendar month or view. |
body | div.wl-cal__body | Main component content. |
week | div.wl-cal__week | Row of weekday headings. |
weekday | span.wl-cal__wd | One localized weekday heading. |
grid | div.wl-cal__grid | Calendar or color-palette grid. |
row | div.wl-cal__row | One repeated calendar or file-list row. |
day | button.wl-cal__day | Selectable calendar day. |
dayNumber | span.wl-cal__dnum | Day number inside a calendar cell. |
event | span.wl-cal__ev | Event label inside a calendar day. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- disabledDates accepts an ISO array or predicate. Disabled dates stay visible and are skipped by keyboard navigation. dateSelect emits the activated ISO date, including the current selection; v-model remains state. In multiple mode activation can remove a date. The day slot and PT receive disabled. Searches are bounded; use month buttons if no enabled target is found.
- The calendar announces the month and selected day; a date's accessible name includes its event count. Give the surrounding section a clear heading.
- Arrows move focus by day, Home/End within the current week, PageUp/PageDown by month, and Enter/Space selects a day.
- v-model stores YYYY-MM-DD; v-model:month stores the displayed YYYY-MM. Set both models for programmatic navigation if the date needs to be visible.
- Also list events in text for the selected day. Do not add unsupported disabled/minDate/invalid props: these restrictions are outside the calendar contract.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| ← / →, ↑ / ↓ | Move by a day or a week in the open calendar. |
| Home / End | Move to a week edge. |
| PageUp / PageDown | Change the visible month. |
| Enter / Space | Choose an available day. |
| Escape | Close the date picker popup. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.