Add presets to Date Range Picker in React

In this article, we’ll show you how to add presets to Date Range Picker in React. This example will help you to provide quick buttons in the picker to select a date range such as the next 7 days’ range or the next month’s range.

Demo Application

Output - Add presets to Date Range Picker in React - Clue Mediator
Output – Add presets to Date Range Picker in React – Clue Mediator

Steps to add presets to Date Range Picker in React

  1. Project structure
  2. Package dependencies
  3. Implementation
  4. Output

1. Project structure

  • presets-react-date-range-picker
    • node_modules
    • public
      • index.html
    • src
      • App.js
      • index.css
      • index.js
      • Presets.js
    • package-lock.json
    • package.json
    • README.md

2. Package dependencies

Run the following command to install bootstrap, moment, and react-dates npm packages.

You will find the version of the following packages in React application.

react
^18.2.0
bootstrap
^5.2.3
moment
^2.29.4
react-dates
^21.8.0

3. Implementation

Refer to the following files for implementation.

Presets.js
App.js
index.js

4. Output

Run your application and check the output in the browser.
Live Demo

That’s it for today.
Thank you for reading. Happy Coding..!!

Demo & Source Code

GitHub Repository StackBlitz Project
If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *