calendar

A flexible and accessible calendar component for selecting dates. Built with modern Angular patterns and full keyboard navigation support.

PreviousNext
Su
Mo
Tu
We
Th
Fr
Sa
import { Component } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

@Component({
  selector: 'z-demo-calendar-default',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <z-calendar (dateChange)="onDateChange($event)" />
  `,
})
export class ZardDemoCalendarDefaultComponent {
  onDateChange(date: Date | Date[]) {
    console.log('Selected date:', date);
  }
}

Installation

Copy
npx zard-cli@latest add calendar

Usage

import { ZardCalendarComponent } from '@/shared/components/calendar/calendar.component';
Copy
<z-calendar></z-calendar>
Copy

Examples

default

Su
Mo
Tu
We
Th
Fr
Sa
import { Component } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

@Component({
  selector: 'z-demo-calendar-default',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <z-calendar (dateChange)="onDateChange($event)" />
  `,
})
export class ZardDemoCalendarDefaultComponent {
  onDateChange(date: Date | Date[]) {
    console.log('Selected date:', date);
  }
}

multiple

Su
Mo
Tu
We
Th
Fr
Sa

Selected (0) date(s).

import { Component, signal } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

@Component({
  selector: 'z-demo-calendar-multiple',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <div class="space-y-4">
      <z-calendar zMode="multiple" [(value)]="selectedDates" (dateChange)="onDateChange($event)" />

      <div class="text-muted-foreground mt-2 text-sm">
        <p class="font-medium">Selected ({{ selectedDates()?.length ?? 0 }}) date(s).</p>
      </div>
    </div>
  `,
})
export class ZardDemoCalendarMultipleComponent {
  readonly selectedDates = signal<Date[] | null>(null);

  onDateChange(dates: Date | Date[]) {
    console.log('Selected dates:', dates);
  }

  formatDate(date: Date): string {
    return date.toLocaleDateString('en-US', { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' });
  }
}

range

Su
Mo
Tu
We
Th
Fr
Sa
From:N/A
To:N/A
import { Component, signal } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

@Component({
  selector: 'z-demo-calendar-range',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <div class="space-y-4">
      <z-calendar zMode="range" [(value)]="dateRange" (dateChange)="onDateChange($event)" />

      <div class="bg-muted/50 mt-4 rounded-lg border p-4">
        <div class="space-y-1 text-sm">
          <div class="flex items-center gap-2">
            <span class="text-muted-foreground min-w-12">From:</span>
            <span class="font-medium">{{ formatDate(dateRange(), 'start') }}</span>
          </div>

          <div class="flex items-center gap-2">
            <span class="text-muted-foreground min-w-12">To:</span>
            <span class="font-medium">{{ formatDate(dateRange(), 'end') }}</span>
          </div>
        </div>
      </div>
    </div>
  `,
})
export class ZardDemoCalendarRangeComponent {
  readonly dateRange = signal<Date[] | null>(null);

  onDateChange(dates: Date | Date[]) {
    console.log('Selected range:', dates);
  }

  formatDate(date?: Date[] | null, label: 'start' | 'end' = 'start'): string {
    if (!date || date?.length === 0) {
      return 'N/A';
    }

    const targetDate = label === 'start' ? date[0] : date[1];
    if (!targetDate) {
      return 'N/A';
    }

    return targetDate.toLocaleDateString('en-US', {
      weekday: 'short',
      year: 'numeric',
      month: 'short',
      day: 'numeric',
    });
  }
}

with constraints

With Min/Max Date

Su
Mo
Tu
We
Th
Fr
Sa

Available dates: 7/19/2026 - 8/18/2026

Disabled

Su
Mo
Tu
We
Th
Fr
Sa
import { Component } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

const DAYS_IN_FUTURE = 30;
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;

@Component({
  selector: 'z-demo-calendar-with-constraints',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <div class="space-y-8">
      <div>
        <h3 class="mb-3 text-sm font-medium">With Min/Max Date</h3>
        <z-calendar [minDate]="minDate" [maxDate]="maxDate" (dateChange)="onDateChange($event)" />
        <p class="text-muted-foreground mt-2 text-sm">
          Available dates: {{ minDate.toLocaleDateString() }} - {{ maxDate.toLocaleDateString() }}
        </p>
      </div>

      <div>
        <h3 class="mb-3 text-sm font-medium">Disabled</h3>
        <z-calendar [disabled]="true" />
      </div>
    </div>
  `,
})
export class ZardDemoCalendarWithConstraintsComponent {
  minDate = new Date();
  maxDate = new Date(Date.now() + DAYS_IN_FUTURE * MILLISECONDS_PER_DAY);

  constructor() {
    // Set min date to today
    this.minDate.setHours(0, 0, 0, 0);

    // Set max date to 30 days from now
    this.maxDate.setHours(23, 59, 59, 999);
  }

  onDateChange(date: Date | Date[]) {
    console.log('Selected date:', date);
  }
}

expand year selection range

Date of Birth

Su
Mo
Tu
We
Th
Fr
Sa
import { Component } from '@angular/core';

import { ZardCalendarComponent } from '../calendar.component';

@Component({
  selector: 'z-demo-calendar-expand-year-selection-range',
  imports: [ZardCalendarComponent],
  standalone: true,
  template: `
    <div class="space-y-8">
      <div>
        <h3 class="mb-3 text-sm font-medium">Date of Birth</h3>
        <z-calendar [minDate]="minDate" [maxDate]="maxDate" (dateChange)="onDateChange($event)" />
      </div>
    </div>
  `,
})
export class ZardDemoCalendarExpandYearSelectionRangeComponent {
  minDate = new Date(1950, 1, 1);
  maxDate = new Date();

  onDateChange(date: Date | Date[]) {
    console.log('Selected date:', date);
  }
}

API Reference

z-calendarComponent

A flexible and accessible calendar component for selecting dates with full keyboard navigation support.

PropertyDescriptionTypeDefault
class Additional CSS classes to apply to the calendar ClassValue ''
zMode Selection mode of the calendar 'single' | 'multiple' | 'range' 'single'
value Currently selected date(s) - type depends on mode CalendarValue null
minDate Minimum selectable date. Also used to expand the year picker range Date | null null
maxDate Maximum selectable date. Also used to expand the year picker range Date | null null
disabled Whether the calendar is disabled boolean false
(dateChange) Emitted when date selection changes EventEmitter<Date | Date[]> -
github iconwhatsapp icondiscord iconX icon

Made with in Brazil. Open source and available on GitHub .