# Vue FlatPickr Component
[](https://npm-stat.com/charts.html?package=vue-flatpickr-component&from=2018-01-01)
[](https://www.jsdelivr.com/package/npm/vue-flatpickr-component)
[](https://www.npmjs.com/package/vue-flatpickr-component)
[](https://github.com/ankurk91/vue-flatpickr-component/tags)
[](https://github.com/ankurk91/vue-flatpickr-component/actions)
[](https://codecov.io/gh/ankurk91/vue-flatpickr-component)
[](LICENSE.txt)

Vue.js component for [Flatpickr](https://flatpickr.js.org/) date-time picker.
## [Demo](https://ankurk91.github.io/vue-flatpickr-component/) or [JSFiddle](https://jsfiddle.net/ankurk91/63kzdwLx/)
### Version matrix
|Vue.js version| Package version | Branch |
|:-------------|:---------------:|--------------------------------------------------------------------:|
| 2.x | 8.x | [8.x](https://github.com/ankurk91/vue-flatpickr-component/tree/8.x) |
| 3.x | 11.x | `main` |
## Features
* Reactive `v-model` value
- You can change flatpickr value programmatically
* Reactive [config](https://flatpickr.js.org/options/) options
- You can change config options dynamically
- Component will watch for any changes and redraw itself
* Can emit all possible [events](https://flatpickr.js.org/events/)
* Compatible with [Bootstrap](http://getbootstrap.com/) or any other CSS framework
* Supports [wrapped](https://flatpickr.js.org/examples/#flatpickr--external-elements) mode
* Works with validation libraries
## Installation
```bash
npm install vue-flatpickr-component@^11
```
## Usage
#### Minimal example
```html
```
#### Detailed example
Using Bootstrap [input group](https://getbootstrap.com/docs/4.6/components/input-group/) and Font Awesome icons
```html
Selected date is - {{date}}
```
## Events
* The component can emit all possible events, you can listen to them in your component
```html
```
* Event names has been converted to kebab-case.
* You can still pass your callback methods in `:config` like original flatpickr do.
## Available props
The component accepts these props:
| Attribute | Type | Default | Description |
|:----------|:-----------------------------------------------:|:----------------------------------------------:|:-----------------------------------------------------------------------|
| v-model | String / Date Object / Array / Timestamp / null | `null` | Set or Get date-picker value (required) |
| config | Object | `{ wrap: false }` | Flatpickr configuration [options](https://flatpickr.js.org/options/) |
| events | Array | Array of sensible [events](./src/events.ts#L2) | Customise the [events](https://flatpickr.js.org/events/) to be emitted |
## Use in browser with CDN
```html
```
## Run examples on your localhost
* Clone this repo
* Make sure you have node-js `>=20.11` and [pnpm](https://pnpm.io/) `>=8.x` pre-installed
* Install dependencies `pnpm install`
* Run webpack dev server `npm start`
* This should open the demo page in your default web browser
## Testing
* This package is using [Jest](https://github.com/facebook/jest)
and [vue-test-utils](https://github.com/vuejs/test-utils) for testing.
* Tests can be found in `__test__` folder.
* Execute tests with this command `npm test`
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## License
[MIT](LICENSE.txt) License