Contents
- Adding mandatory asterisk to placeholder and float label
- See Also
Having trouble getting help?
Contact Support
Contact Support
Customization in Angular Datepicker component
27 Apr 20245 minutes to read
You can customize the entire appearance of the input element and Calendar by using custom cssClass
property.
Also you can use the calendar’s renderDayCell
event to customize the appearance of the each day cell.
Below is the list of classes that provides flexible way to customize the DatePicker component.
Class Name | Description |
---|---|
e-date-wrapper | Applied to DatePicker wrapper |
e-datepicker | Applied to the DatePicker element. |
e-float-text | Applied to the floating label. |
e-date-icon | Applied to the DatePicker icon. |
e-popup-wrapper | Applied to DatePicker popup wrapper. |
e-calendar | Applied to Calendar element. |
e-header | Applied to Calendar header. |
e-title | Applied to Calendar title. |
e-icon-container | Applied to Calendar previous and next icon container. |
e-prev | Applied to Calendar previous icon. |
e-next | Applied to Calendar next icon. |
e-weekend | Applied to Calendar weekend dates. |
e-other-month | Applied to Calendar other month dates. |
e-day | Applied to each day cell of the Calendar. |
e-selected | Applied to Calendar selected dates. |
e-disabled | Applied to Calendar disabled dates. |
The following example disables the weekends of every month using renderDayCell
event.
Here we have used the e-disabled
class to highlight the disabled date.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars'
import { Component } from '@angular/core';
import { RenderDayCellEventArgs } from '@syncfusion/ej2-angular-calendars';
@Component({
imports: [
DatePickerModule
],
standalone: true,
selector: 'app-root',
styleUrls: ['./index.css'],
template: `<ejs-datepicker [value]='dateValue' placeholder='Enter date' (renderDayCell)='onRenderCell($event)'></ejs-datepicker>`
})
export class AppComponent {
public dateValue:Date = new Date();
constructor() {
}
public onRenderCell(args: RenderDayCellEventArgs): void {
if (args.date?.getDay() == 0 || args.date?.getDay() == 6) {
//sets isDisabled to true to disable the date.
args.isDisabled = true;
//To know about the disabled date customization, you can refer in "styles.css".
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Adding mandatory asterisk to placeholder and float label
You can add a mandatory asterisk(*)
to placeholder and float label using .e-input-group.e-control-wrapper.e-float-input .e-float-text::after class.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars'
import { Component } from '@angular/core';
@Component({
imports: [
DatePickerModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-datepicker floatLabelType="Auto" placeholder="Enter date"></ejs-datepicker>`
})
export class AppComponent {
constructor() {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));