Flatpickr action and component for Svelte 3. demo
Install with npm or yarn:
npm install --save svelte-flatpickr
Any options of Flatpickr can be passed to action as options or Flatpickr component via options
prop.
Import Flatpickr
component to your Svelte app. options
prop will be passed to flatpickr
action. Any other props will be assigned to input element itself.
<label>
<Flatpickr name="modified" {options} on:open={open} />
</label>
<script>
import { Flatpickr } from 'svelte-flatpickr';
let options = {
altInput: true,
dateFormat: 'Z'
};
function open() {
console.log('opened');
}
</script>
OR import flatpickr
action to get full control.
<label>
<input use:flatpickr={options} name="modified" on:open={open}>
</label>
<script>
import { flatpickr } from 'svelte-flatpickr';
let options = {
altInput: true,
dateFormat: 'Z'
};
function open() {
console.log('opened');
}
</script>
change
- event fired when the user selects a date, or changes the time on a selected dateupdate
- event fired when the input value is updated with a new date stringready
- event fired once the calendar is in a ready stateopen
- event fired when the calendar is openedclose
- event fired when the calendar is closedmonth
- event fired when the month is changed, either by the user or programmaticallyyear
- event fired when the year is changed, either by the user or programmaticallyday
- event to take full control of every date cellMIT © PaulMaly