sajad torkamani

Install

npm i react-datepicker

Basic usage

Assuming you’re using a build system like Webpack that supports requiring CSS files, you can do:

import React, { useState } from "react";
import DatePicker from "react-datepicker";

import "react-datepicker/dist/react-datepicker.css";

const Example = () => {
  const [startDate, setStartDate] = useState(new Date());

  return (
    <DatePicker 
      selected={startDate} 
      onChange={date => setStartDate(date)} 
      placeholderText="Search date..."
    />
  );
};

Sources

Leave a comment

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