Articles in this section
Category / Section

How to create an example of angular daterangepicker component with highly customizable options?

5 mins read

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 within the template.


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-buttons

The 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  { }
To customize the UI, make use of the cssClass which will be added to the DateRangePicker component as the root CSS class. With this CSS class, existing styles can be overridden in the DateRangePicker.


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;

}
Step3:

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:


DaterRangePicker

 

Refer to the working sample for additional details and implementation: Sample

For more information about the DateRangePicker Customization, refer to this UG DocumentationAPI 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 forumsBoldDesk Support, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied