React Datepicker reference
15 June 2022 (Updated 15 June 2022)
On this page
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
Tagged:
React tooling
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment