Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calendar is not displaying correctly using flatpickr

I installed flatpickr by npm install flatpickr. Calender is displaying like when click on input control enter image description here

var React = require('React');
var ReactDOM = require('ReactDOM');
var Flatpickr = require('flatpickr');

var Calender = React.createClass({

    componentDidMount: function(){
    this.flatpickr = new Flatpickr(this.refs.date, {dateFormat: "m/d/Y"});
    },

    render: function() {
        return(
                <div>            
                    <input data-enable-time defaultValue='2016-11-11' ref="date_from" />    
                </div>
             );
    }
});
like image 567
user2194838 Avatar asked Dec 06 '16 20:12

user2194838


People also ask

What is Flatpickr?

flatpickr is a lightweight and powerful datetime picker. Lean, UX-driven, and extensible, yet it doesn't depend on any libraries. There's minimal UI but many themes. Rich, exposed APIs and event system make it suitable for any environment.


1 Answers

I know its been a long time but- You need to add the link to the CSS file.

In your SCSS file:

@import '../node_modules/flatpickr/dist/flatpickr.min.css';

It's the first line in the the docs example:
https://github.com/coderhaoxin/react-flatpickr
(When I used it I found that the css file name in the example was different than what I had, so double check that in your node_modules.)

Hope that helped.

like image 187
Bud Anin- Aminof Avatar answered Oct 09 '22 19:10

Bud Anin- Aminof