initialView
The view the calendar shows when it is made.
| Type | string |
|---|---|
| Default | 'timeGridWeek' — or, with @dzcalendar/dom/base, the first view whose renderer is imported |
Live update (update()) | Yes, as view: update({ view: … }) |
| Declared in | packages/core/src/kernel.ts |
What it does
Section titled “What it does”A view is a way of drawing a period: a month of day cells, a week of hours, a
list. initialView names the one shown first; the person then moves between
views with the header’s buttons, and your code with update({ view }).
The views built into @dzcalendar/dom:
| Name | What it shows |
|---|---|
dayGridMonth |
The month, one cell per day |
dayGridWeek, dayGridDay |
A week, a day, as day cells |
timeGridWeek |
The week, hour by hour (the default) |
timeGridDay |
One day, hour by hour |
Two more families are separate entries, imported once:
| Name | Import |
|---|---|
listDay, listWeek, listMonth, listYear |
import '@dzcalendar/dom/list' |
multiMonthYear |
import '@dzcalendar/dom/multimonth' |
The resource views (resourceTimeGridWeek…) and, with @dzcalendar/pro, the
timeline views are described in Resources & timeline.
Your own views — four days, a conference’s dates — are declared with views
and named here like any other.
Example
Section titled “Example”import { createCalendar } from '@dzcalendar/dom';import '@dzcalendar/core/recurrence'; // repeating events (rrule)import '@dzcalendar/dom/list';
const calendar = createCalendar(element, { timeZone: 'Europe/Paris', initialView: 'dayGridMonth', headerToolbar: { start: 'prev,next today', center: 'title', end: 'dayGridMonth,timeGridWeek,listWeek' },});
// Later: another view.calendar.update({ view: 'listWeek' });import { Component, signal } from '@angular/core';import { DZ_CALENDAR } from '@dzcalendar/angular';import '@dzcalendar/dom/list';
@Component({ selector: 'app-agenda', imports: [DZ_CALENDAR], template: ` <dz-calendar timeZone="Europe/Paris" [(view)]="view" [options]="{ headerToolbar: { start: 'prev,next today', center: 'title', end: 'dayGridMonth,timeGridWeek,listWeek' } }" /> <p>Showing {{ view() }}</p>`,})export class Agenda { // The first view; it follows the person's choice (two-way). readonly view = signal<string | undefined>('dayGridMonth');}import { DzCalendar } from '@dzcalendar/react';import '@dzcalendar/dom/list';
export function Agenda() { return ( <DzCalendar timeZone="Europe/Paris" defaultView="dayGridMonth" headerToolbar={{ start: 'prev,next today', center: 'title', end: 'dayGridMonth,timeGridWeek,listWeek' }} /> );}// Controlled instead: view={view} onViewChange={setView}<script setup lang="ts">import { ref } from 'vue';import { DzCalendar } from '@dzcalendar/vue';import '@dzcalendar/dom/list';
const view = ref('dayGridMonth');</script>
<template> <DzCalendar time-zone="Europe/Paris" v-model:view="view" :options="{ headerToolbar: { start: 'prev,next today', center: 'title', end: 'dayGridMonth,timeGridWeek,listWeek' } }" /></template>In the frameworks the option is the component’s view: Angular’s [(view)],
React’s defaultView (or view with onViewChange, controlled), Vue’s
v-model:view.
Live demo
Section titled “Live demo”The calendar opens on the month; the header switches to the week and the list.
See also
Section titled “See also”headerToolbar— where the view buttons go.events— what the views show.- Views — custom views, durations, hidden days.