How to create an example of angular daterangepicker component with highly customizable options?
This section explains the way to customize Angular DateRangePicker Component using the CSSClass
Introduction
The Angular DateRangePicker used in this project is created from the Syncfusion ej2-angular-calendars package. You can simply define it as
Dependencies
Before starting this project, the Angular DateRangePicker requires adding the Syncfusion ej2-angular-calendars package from the npmjs, which is distributed to npm as @syncfusion scoped packages. DateRangePicker requires the following dependent packages for rendering the DateRangePicker component.
|-- @syncfusion/ej2-angular-calendars
|-- @syncfusion/ej2-angular-base
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-calendars
|-- @syncfusion/ej2-lists
|-- @syncfusion/ej2-inputs
|-- @syncfusion/ej2-splitbuttons
|-- @syncfusion/ej2-popups
|-- @syncfusion/ej2-buttonsThe following CSS styles require dependencies to render the file Uploader component.
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/material.css';
@import '../node_modules/@syncfusion/ej2-angular-calendars/styles/material.css';Adding DateRangePicker Component:
Render the DateRangePicker component by using the <ejs-daterangepicker> selector.
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `<ejs-daterangepicker></ejs-daterangepicker>`
})
export class AppComponent { }Step1:
Customize the hover element before selecting the element.
.customCSS .e-calendar .e-content .e-selected span.e-day,
.customCSS .e-calendar .e-content .e-selected span.e-day:hover,
.customCSS .e-calendar .e-content .e-today.e-selected:hover,
.customCSS .e-calendar .e-content .e-today.e-selected span.e-day,
.customCSS .e-calendar .e-content .e-selected:hover span.e-day
{
background-color: #35b86b;
}Step2:
Customize the weekend element by overriding the styles below.
.customCSS .e-calendar .e-content .e-weekend span
{
color: #ff3337;
}Customize the action buttons, such as the input element icon and the cancel button.
.customCSS.e-date-range-wrapper .e-input-group-icon.e-icons.e-active,
.customCSS .e-btn.e-flat,
.customCSS .e-btn.e-flat:hover
{
color: #35b86b;
}Screenshot:
Refer to the working sample for additional details and implementation: Sample
For more information about the DateRangePicker Customization, refer to this UG Documentation, API Reference and Samples.
Conclusion
We hope you enjoyed learning about how to create an example of the Angular DateRangePicker component with highly customizable options.
You can refer to our Angular DateRangePicker feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular DateRangePicker example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!