React Datepicker
A decent and pretty date picker to be used with React
import 'moment/locale/it.js';import DatePicker DatePickerInput from 'rc-datepicker'; const date = '2015-06-26' // or Date or Moment.js { // ...} React;
You can see a live demo here
or check the full examples here
FOR WEBPACK USERS: webpack by default imports every locale. Please take a look at this question on Stack Overflow for possible solutions.
Install
npm install --save rc-datepicker
The npm package is compiled in JavaScript 5
Changelog
See CHANGELOG.md
DatePickerInput API
See this readme
Locales
DatePicker
and DatePickerInput
use Moment.js, therefore they support any locale inside "moment/locale".
To select a locale you need to require it before requiring the datepicker or moment anywhere in your app: this way it will be automatically selected as current locale.
;
DatePickerInput
will now use French locale by default.
Switch between locales
You can switch between locales by passing the prop "locale" to DatePickerInput
or DatePicker
.
WATCH OUT this method requires the wanted locale to be already available in your bundle which is only true if you had already imported it or if you're using moment-with-locales.min.js
import 'moment/locale/fr.js'import 'moment/locale/es.js' <DatePicker ='es' />
Style
DatePickerInput
and DatePicker
come with their own default style. In order to use it you should import it in your project as follows:
;
Examples
$ npm install$ npm start$ open http://localhost:8080