Repository navigation
Conversation
Add the igxCalendarDay directive and the dayTemplate input to customize the content of the calendar day cells. The template receives the date and the day states through IgxCalendarDayTemplateContext, while the cells keep their selection, keyboard navigation, ARIA and styling. The date picker and date range picker pass the template to their calendar. Closes #17822 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Template context values need correction, and both picker import collections must expose the new directive.
3 open issues
What changed in this PR
Adds customizable calendar day content for #17822, with typed date and state context and integration into both date pickers.
Changes:
- Introduces
igxCalendarDayanddayTemplatewhile retaining existing cell interaction and styling. - Adds calendar behavior tests and picker integration tests.
- Documents the API and adds event-indicator and pricing samples.
| File | Description |
|---|---|
| src/app/calendar/calendar.sample.ts | Adds template directive imports and sample data helpers. |
| src/app/calendar/calendar.sample.scss | Styles event indicators and prices. |
| src/app/calendar/calendar.sample.html | Demonstrates calendar and range-picker templates. |
| skills/igniteui-angular-components/references/form-controls.md | Documents template usage and constraints. |
| projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.ts | Forwards projected day templates to the calendar. |
| projects/igniteui-angular/date-picker/src/date-range-picker/date-range-picker.component.spec.ts | Tests range-picker template rendering. |
| projects/igniteui-angular/date-picker/src/date-picker/date-picker.component.ts | Forwards projected day templates to the calendar. |
| projects/igniteui-angular/date-picker/src/date-picker/date-picker.component.spec.ts | Tests date-picker template rendering. |
| projects/igniteui-angular/calendar/src/calendar/public_api.ts | Adds the directive to the calendar import collection. |
| projects/igniteui-angular/calendar/src/calendar/days-view/days-view.component.ts | Accepts a typed day template. |
| projects/igniteui-angular/calendar/src/calendar/days-view/days-view.component.html | Renders custom content for visible days. |
| projects/igniteui-angular/calendar/src/calendar/days-view/day-item.component.ts | Builds the date and state context. |
| projects/igniteui-angular/calendar/src/calendar/calendar.directives.ts | Defines the directive and typed context. |
| projects/igniteui-angular/calendar/src/calendar/calendar.component.ts | Resolves input and projected templates. |
| projects/igniteui-angular/calendar/src/calendar/calendar.component.spec.ts | Tests context, interaction, precedence, and multiple views. |
| projects/igniteui-angular/calendar/src/calendar/calendar.component.html | Passes the template to each days view. |
| projects/igniteui-angular/calendar/README.md | Documents the API, context, and accessibility constraints. |
| CHANGELOG.md | Announces day-template support. |
Review effort: Balanced
Announce the day template text as the day cell description through aria-describedby, and pass projected igxCalendarDay template changes to the calendar of an open date picker or date range picker. Reuse the day template context without extra allocations. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mddragnev
left a comment
There was a problem hiding this comment.
Could you also update the Specification of the calendar,date/date-range pickers?
| private subheaderTemplateDirective!: IgxCalendarSubheaderTemplateDirective; | ||
|
|
||
| /** | ||
| * @hidden |
There was a problem hiding this comment.
@hidden @internal not needed for private members
| @ContentChild(IgxCalendarSubheaderTemplateDirective) | ||
| private subheaderTemplate!: IgxCalendarSubheaderTemplateDirective; | ||
|
|
||
| /** @hidden @internal */ |
| @ContentChild(IgxCalendarSubheaderTemplateDirective) | ||
| private subheaderTemplate!: IgxCalendarSubheaderTemplateDirective; | ||
|
|
||
| /** @hidden @internal */ |
| */ | ||
| @Directive({ | ||
| selector: '[igxCalendarDay]', | ||
| standalone: true |
There was a problem hiding this comment.
Not needed. Now standalone defaults to true
| * @hidden | ||
| * @internal | ||
| */ | ||
| @ContentChild(forwardRef(() => IgxCalendarDayTemplateDirective), { read: TemplateRef }) |
There was a problem hiding this comment.
Any specific reason for the forwardRef?
| * @internal | ||
| */ | ||
| @ContentChild(forwardRef(() => IgxCalendarDayTemplateDirective), { read: TemplateRef }) | ||
| private dayTemplateDirective?: TemplateRef<IgxCalendarDayTemplateContext>; |
There was a problem hiding this comment.
The naming is ambiguous since the type of the dayTemplateDirective is a TemplateRef not the directive itself.
|
|
||
| public set dayTemplate(value: TemplateRef<IgxCalendarDayTemplateContext> | null) { | ||
| this._dayTemplate = value; | ||
| this.cdr?.markForCheck(); |
There was a problem hiding this comment.
Do you really need scheduling a CD in the setter?
| const context = this._templateContext; | ||
| const disabled = this.isDisabled; | ||
|
|
||
| context.$implicit = context.date = this.date.native; |
There was a problem hiding this comment.
this.date.native returns new Date on every access, and getTemplateContext runs on every pass of the days view. So each cell's template gets a new date object, even if the date hasnt changed. If there is something in the user template that compares by reference will re-run on every pass.
You could consider changing it only when the date actually changes.

Closes #17822
Description
Add the igxCalendarDay directive and the dayTemplate input to customize the content of the calendar day cells. The template receives the date and the day states through IgxCalendarDayTemplateContext, while the cells keep their selection, keyboard navigation, ARIA and styling. The date picker and date range picker pass the template to their calendar.
Motivation / Context
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
How Has This Been Tested?
Test Configuration:
Screenshots / Recordings
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)