react-flatpickr
react-flatpickr copied to clipboard
is there a way to use monthSelectPlugin , this doesnot seems to work ?
<script>
import Flatpickr from 'react-flatpickr'
import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect';
import '@styles/react/libs/flatpickr/flatpickr.scss'
import 'flatpickr/dist/plugins/monthSelect/style.css'
</script>
<Flatpickr
value={selectedDate}
onChange={date => setSelectedDate(date[0])}
options={{
plugin: [
new monthSelectPlugin({
shorthand: true, //defaults to false
dateFormat: "m.y", //defaults to "F Y"
altFormat: "F Y", //defaults to "F Y"
})
]
}}
/>
I was able to make it work, I think you're only missing the plugin CSS import and you have a typo, the option is called plugins, not plugin.
import "flatpickr/dist/flatpickr.min.css";
import "flatpickr/dist/plugins/monthSelect/style.css"; // <-----
import Flatpickr from 'react-flatpickr'
import monthSelectPlugin from "flatpickr/dist/plugins/monthSelect";
<Flatpickr
value={value}
onChange={onChange}
options={{
plugins: [new monthSelectPlugin()],
}}
/>
Zavan, is correct. I was able to make it work by using the plugins instead plugin. I think we should go ahead and close this issue since it is working as designed.