ngx-daterangepicker-pro
May 29, 2025 ยท View on GitHub
A powerful, customizable Angular date range picker built with Angular 17+ and Day.js.
โจ Features
- ๐ฅ Clean and modern date range selection
- ๐ Supports predefined and custom ranges
- ๐จ Fully customizable styles
- ๐ Two-way binding with
FormControlandngModel - ๐งฉ Lightweight (uses Day.js)
๐ฆ Installation
Install via npm:
npm install ngx-daterangepicker-pro dayjs
๐ Usage
1. Import the Directive
In a Module:
import { NgxDaterangePickerProDirective } from 'ngx-daterangepicker-pro';
@NgModule({
imports: [NgxDaterangePickerProDirective]
})
export class AppModule {}
Or in a Standalone Component:
import { Component } from '@angular/core';
import { NgxDaterangePickerProDirective } from 'ngx-daterangepicker-pro';
@Component({
standalone: true,
selector: 'app-root',
imports: [NgxDaterangePickerProDirective],
templateUrl: './app.component.html'
})
export class AppComponent {}
2. Template Usage with Reactive Forms
<form [formGroup]="form">
<input type="text" ngxDaterangePickerPro formControlName="range" />
</form>
<p>
Selected Range:
{{ form.get('range')?.value?.from | date: 'dd/MM/yyyy' }} -
{{ form.get('range')?.value?.to | date: 'dd/MM/yyyy' }}
</p>
3. Component Code
import { Component } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { DateRangeModel } from 'ngx-daterangepicker-pro';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
form = new FormGroup({
range: new FormControl<DateRangeModel>({ from: null, to: null })
});
}
๐งช Development
To run the demo app locally:
npm install
ng serve
Then open http://localhost:4200 in your browser.
๐ ๏ธ Building the Library
To build the library:
ng build ngx-daterangepicker-pro
The output will be located in the dist/ngx-daterangepicker-pro/ folder.
โ Running Unit Tests
To run unit tests:
ng test
๐ฃ Contributing
Contributions are welcome! Found a bug or want to suggest a feature?
- Fork the repo
- Create your branch:
git checkout -b feature/your-feature-name - Commit your changes:
git commit -m 'feat: add new feature' - Push to the branch:
git push origin feature/your-feature-name - Open a Pull Request
๐ฌ Support
If you encounter any issues or have questions, please open an issue.
๐ License
This project is licensed under the MIT License.