WlCalendar

Monthly calendar with events. The displayed month is controlled through v-model:month ("YYYY-MM").
Components / Inputs v0.1.0

Selection

October 2026
MoTuWeThFrSaSu

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

October 2026
MoTuWeThFrSaSu

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>