Calendar

A date field component that allows users to enter and edit date.

Installation

ng g @spartan-ng/cli:ui calendar

Usage

import { HlmCalendarImports } from '@spartan-ng/helm/calendar';
<hlm-calendar [(date)]="selectedDate" [min]="minDate" [max]="maxDate" />

Internationalization

The calendar supports internationalization (i18n) via the BrnCalendarI18nService . By default, weekday names and month headers are rendered in English. You can provide a custom configuration globally or swap it at runtime to support multiple locales.

Global Configuration

Use provideBrnCalendarI18n in your app bootstrap to configure labels and formats globally:

import { bootstrapApplication } from '@angular/platform-browser';
import { provideBrnCalendarI18n } from '@spartan-ng/brain/calendar';
bootstrapApplication(App, {
	providers: [
		provideBrnCalendarI18n({
			formatWeekdayName: (i) => ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'][i],
			formatHeader: (m, y) =>
				new Date(y, m).toLocaleDateString('de-DE', {
					month: 'long',
					year: 'numeric',
				}),
			labelPrevious: () => 'Vorheriger Monat',
			labelNext: () => 'Nächster Monat',
			labelWeekday: (i) => ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'][i],
			firstDayOfWeek: () => 1,
		}),
	],
});

Runtime Configuration

You can dynamically switch calendar language at runtime by injecting BrnCalendarI18nService and calling use() :

import { injectBrnCalendarI18n } from '@spartan-ng/brain/calendar';

@Component({...})
export class CalendarPage {
  private readonly _i18n = injectBrnCalendarI18n();

  switchToFrench() {
    this._i18n.use({
      ...,
      labelNext: () => 'Mois suivant',
      labelPrevious: () => 'Mois précédent',
      ...
    });
  }
}

Examples

Multiple Selection

Use hlm-calendar-multi for multiple date selection. Limit the selectable dates using minSelection and maxSelection inputs.

Range Selection

Use hlm-calendar-range for range date selection. Set the range by using startDate and endDate inputs.

Month and Year Selector

Caption layouts with a year dropdown use the years function from the calendar's i18n configuration. By default, the dropdown includes an inclusive range from 100 years in the past through 10 years in the future. Override years with provideBrnCalendarI18n if you need a different range.

See the Internationalization section for configuration examples.

Month and Year

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

For another RTL example please look at the Jalali (Persian) calendar.

Brain API

BrnCalendarCellButton

Selector: button[brnCalendarCellButton]

ExportAs: brnCalendarCellButton

Inputs

PropTypeDefaultDescription
date* (required) T - The date this cell represents

BrnCalendarCell

Selector: [brnCalendarCell]

ExportAs: brnCalendarCell

BrnCalendarGrid

Selector: [brnCalendarGrid]

ExportAs: brnCalendarGrid

BrnCalendarHeader

Selector: [brnCalendarHeader]

ExportAs: brnCalendarHeader

Inputs

PropTypeDefaultDescription
id string `brn-calendar-header-${++uniqueId}` The unique id for the header

BrnCalendarMonthSelect

Selector: brnSelect[brnCalendarMonthSelect],hlm-select[brnCalendarMonthSelect]

ExportAs: brnCalendarMonthSelect

BrnCalendarNextButton

Selector: button[brnCalendarNextButton]

ExportAs: brnCalendarNextButton

BrnCalendarPreviousButton

Selector: button[brnCalendarPreviousButton]

ExportAs: brnCalendarPreviousButton

BrnCalendarWeek

Selector: [brnCalendarWeek]

ExportAs: brnCalendarWeek

BrnCalendarWeekday

Selector: [brnCalendarWeekday]

ExportAs: brnCalendarWeekday

BrnCalendarYearSelect

Selector: brnSelect[brnCalendarYearSelect],hlm-select[brnCalendarYearSelect]

ExportAs: brnCalendarYearSelect

BrnCalendar

Selector: [brnCalendar]

ExportAs: brnCalendar

Inputs

PropTypeDefaultDescription
highlightDays T[] [] The days to highlight.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
defaultFocusedDate T - The default focused date.
date T - The selected value.

Outputs

PropTypeDefaultDescription
focusedDateChange T - Emits whenever the focused date changes.
dateChange T - The selected value.

BrnCalendarMulti

Selector: [brnCalendarMulti]

ExportAs: brnCalendarMulti

Inputs

PropTypeDefaultDescription
highlightDays T[] [] The days to highlight.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
minSelection number undefined The minimum selectable dates.
maxSelection number undefined The maximum selectable dates.
disabled boolean false Determine if the date picker is disabled.
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
defaultFocusedDate T - The default focused date.
date T[] - The selected value.

Outputs

PropTypeDefaultDescription
focusedDateChange T - Emits whenever the focused date changes.
dateChange T[] - The selected value.

BrnCalendarRange

Selector: [brnCalendarRange]

ExportAs: brnCalendarRange

Inputs

PropTypeDefaultDescription
highlightDays T[] [] The days to highlight.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
defaultFocusedDate T - The default focused date.
startDate T - The selected start date
endDate T - The selected end date

Outputs

PropTypeDefaultDescription
focusedDateChange T - Emits whenever the focused date changes.
startDateChange T - The selected start date
endDateChange T - The selected end date

BrnMonthYearCalendarGrid

Selector: [brnMonthYearCalendarGrid]

ExportAs: brnMonthYearCalendarGrid

BrnMonthYearCalendarHeader

Selector: button[brnMonthYearCalendarHeader]

ExportAs: brnMonthYearCalendarHeader

Inputs

PropTypeDefaultDescription
id string `brn-month-year-header-${++uniqueId}` The unique id for the header

BrnMonthYearCalendarMonthButton

Selector: button[brnMonthYearCalendarMonthButton]

ExportAs: brnMonthYearCalendarMonthButton

Inputs

PropTypeDefaultDescription
date* (required) T - The month this cell represents.

BrnMonthYearCalendarNextButton

Selector: button[brnMonthYearCalendarNextButton]

ExportAs: brnMonthYearCalendarNextButton

BrnMonthYearCalendarPreviousButton

Selector: button[brnMonthYearCalendarPreviousButton]

ExportAs: brnMonthYearCalendarPreviousButton

BrnMonthYearCalendarYearButton

Selector: button[brnMonthYearCalendarYearButton]

ExportAs: brnMonthYearCalendarYearButton

Inputs

PropTypeDefaultDescription
date* (required) T - The year this cell represents.

BrnMonthYearCalendar

Selector: [brnMonthYearCalendar]

ExportAs: brnMonthYearCalendar

Inputs

PropTypeDefaultDescription
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Whether the month/year selector is disabled.
defaultFocusedDate T - The default focused date.
view BrnMonthYearCalendarView 'year' The current view. The year view is shown first.
date T - The selected month. Represented by the first day of the month.

Outputs

PropTypeDefaultDescription
focusedDateChange T - Emits whenever the focused date changes.
dateChange T - The selected month. Represented by the first day of the month.

Helm API

HlmCalendarMulti

Selector: hlm-calendar-multi

ExportAs: hlmCalendarMulti

Inputs

PropTypeDefaultDescription
captionLayout 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' 'label' Show dropdowns to navigate between months or years.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
minSelection number undefined The minimum selectable dates.
maxSelection number undefined The maximum selectable dates.
disabled boolean false Determine if the date picker is disabled.
date T[] - The selected value.
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
highlightDays T[] [] The days to highlight.
defaultFocusedDate T - The default focused date.

Outputs

PropTypeDefaultDescription
dateChange T[] - The selected value.

HlmCalendarRange

Selector: hlm-calendar-range

ExportAs: hlmCalendarRange

Inputs

PropTypeDefaultDescription
captionLayout 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' 'label' Show dropdowns to navigate between months or years.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
startDate T - The selected start date
endDate T - The selected end date
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
highlightDays T[] [] The days to highlight.
defaultFocusedDate T - The default focused date.

Outputs

PropTypeDefaultDescription
endDateChange T - The selected end date
startDateChange T - The selected start date

HlmCalendar

Selector: hlm-calendar

ExportAs: hlmCalendar

Inputs

PropTypeDefaultDescription
captionLayout 'dropdown' | 'label' | 'dropdown-months' | 'dropdown-years' 'label' Show dropdowns to navigate between months or years.
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Determine if the date picker is disabled.
date T - The selected value.
dateDisabled (date: T) => boolean () => false Whether a specific date is disabled.
weekStartsOn Weekday undefined The day the week starts on
highlightDays T[] [] The days to highlight.
defaultFocusedDate T - The default focused date.

Outputs

PropTypeDefaultDescription
dateChange T - The selected value.

HlmMonthYearCalendar

Selector: hlm-month-year-calendar

ExportAs: hlmMonthYearCalendar

Inputs

PropTypeDefaultDescription
min T - The minimum date that can be selected.
max T - The maximum date that can be selected.
disabled boolean false Whether the month/year selector is disabled.
date T - The selected month. Represented by the first day of the month.
defaultFocusedDate T - The default focused date.
view BrnMonthYearCalendarView 'year' The current view. The year view is shown first.

Outputs

PropTypeDefaultDescription
dateChange T - The selected month. Represented by the first day of the month.
Card Button Group