Skip to content

injectStyles

Whether the calendar adds its own stylesheet to the page (or its shadow root).

Typeboolean
Defaulttrue
Live update (update())No — at creation only
Declared inpackages/dom/src/calendar.ts

The calendar’s structural CSS — grids, positions, sizes — is put in the page once, in a <style>, so a calendar works with nothing else to include. A page under a Content Security Policy without inline styles cannot take it: set false and include DZ_CSS (exported by @dzcalendar/dom) yourself, in a stylesheet your policy allows, with the theme’s CSS, any family made with defineTheme (themeCss(name)), the sheets of the entries you use (LIST_CSS, MULTIMONTH_CSS, the Pro’s timeline and editor) and, under look: 'none', lookGuardedCss(…).

It is read when the calendar is made.

import { createCalendar, DZ_CSS } from '@dzcalendar/dom';
// Written once into a stylesheet the page's policy allows (a build step), not injected at run time.
console.log(DZ_CSS.length);
createCalendar(element, { timeZone: 'Europe/Paris', injectStyles: false });

It is read when the calendar is made: in Angular through the defaults (DZ_CALENDAR_DEFAULTS, provideDzCalendar), in React and Vue through initial.