Componenta11yUpdated in v15

Calendar

A month calendar for picking a date or a date range.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrCalendar } from 'ngwr/calendar';

@Component({ imports: [WrCalendar] })
export class MyComponent {}

Single date

Bind [(date)]. Click the header label to pick a month or a year.

<wr-calendar [(date)]="picked" />
SunMonTueWedThuFriSat

Date range

Set mode="range" and bind [(range)] to a [start, end] pair.

<wr-calendar mode="range" [(range)]="picked" />
SunMonTueWedThuFriSat

Bounds + filter

min and max limit the range. dateFilter turns single dates off, here weekends.

<wr-calendar
  [(date)]="picked"
  [min]="firstOfYear"
  [max]="lastOfYear"
  [dateFilter]="isWeekday"
/>
SunMonTueWedThuFriSat

Keyboard

The grid is one tab stop. The arrows move the cursor and skip dates that cannot be picked.

Day view
KeyDoes
ArrowLeftArrowRightPrevious / next day. Swapped under dir="rtl".
ArrowUpArrowDownSame weekday, one week back / forward.
HomeEndFirst / last day of the week, for the locale.
PageUpPageDownPrevious / next month.
Shift + PageUpShift + PageDownPrevious / next year.
EnterSpacePicks the day.
Month and year views
KeyDoes
ArrowLeftArrowRightPrevious / next chip. Swapped under dir="rtl".
ArrowUpArrowDownOne row up / down.
HomeEndFirst / last chip on the page.
EnterSpacePicks the chip.

API

NameDescriptionTypeDefault
modeSelection mode.WrCalendarMode'single'
dateTwo-way bindable single value (used when mode === 'single').Date | nullnull
rangeTwo-way bindable [start, end] (used when mode === 'range').WrCalendarRange[null, null]
minMin selectable date (inclusive).Date | nullnull
maxMax selectable date (inclusive).Date | nullnull
dateFilterPredicate — return false to disable specific dates (e.g. weekends only).((date: Date) => boolean) | nullnull
autoFocusMove real focus onto the roving cell as soon as the grid is on screen. Off by default: a standalone <wr-calendar> sitting in a page must not steal focus on load. wr-date-picker turns it on for the popup it opens from its trigger, where the user asked to be taken to the calendar.booleanfalse
disabledDisable interaction entirely.booleanfalse

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/calendar's own element.

VariableDefaultDeclared on
--wr-calendar-accentvar(--wr-color-primary).wr-calendar
--wr-calendar-accent-contrastvar(--wr-color-primary-contrast).wr-calendar
--wr-calendar-accent-inkvar(--wr-color-primary-ink).wr-calendar
--wr-calendar-bgvar(--wr-color-surface).wr-calendar
--wr-calendar-body-gapvar(--wr-space-sm).wr-calendar
--wr-calendar-bordervar(--wr-border-base).wr-calendar
--wr-calendar-cell-size2rem.wr-calendar
--wr-calendar-chip-font-sizevar(--wr-text-sm).wr-calendar
--wr-calendar-chip-font-weightvar(--wr-font-weight-semibold).wr-calendar
--wr-calendar-colorvar(--wr-color-on-surface).wr-calendar
--wr-calendar-day-font-sizevar(--wr-text-sm).wr-calendar
--wr-calendar-day-font-weightvar(--wr-font-weight-semibold).wr-calendar
--wr-calendar-day-radiusvar(--wr-border-radius-sm).wr-calendar
--wr-calendar-font-familyvar(--wr-font-family-base).wr-calendar
--wr-calendar-gapvar(--wr-space-sm).wr-calendar
--wr-calendar-grid-gapvar(--wr-space-xs).wr-calendar
--wr-calendar-header-gapvar(--wr-space-sm).wr-calendar
--wr-calendar-label-font-sizevar(--wr-text-sm).wr-calendar
--wr-calendar-label-font-weightvar(--wr-font-weight-semibold).wr-calendar
--wr-calendar-label-line-heightvar(--wr-text-base-leading).wr-calendar
--wr-calendar-label-padding-xvar(--wr-space-sm).wr-calendar
--wr-calendar-months-gapvar(--wr-space-xs).wr-calendar
--wr-calendar-mutedvar(--wr-color-on-surface-muted).wr-calendar
--wr-calendar-paddingvar(--wr-space-md).wr-calendar
--wr-calendar-radiusvar(--wr-border-radius-base).wr-calendar
--wr-calendar-weekday-font-sizevar(--wr-text-xs).wr-calendar
--wr-calendar-weekday-font-weightvar(--wr-font-weight-semibold).wr-calendar
--wr-calendar-weekday-letter-spacingvar(--wr-tracking-wider).wr-calendar
--wr-calendar-weekday-line-heightvar(--wr-text-base-leading).wr-calendar
--wr-calendar-width17rem.wr-calendar
--wr-calendar-years-gapvar(--wr-space-xs).wr-calendar

Dependencies

Built onngwr/date
Used byDate Picker

See also