Migrating from v11
Breaking changes
- Library now requires
vue >= v3.5 Compatmode is removedumdandiifebundles are removediife: Browser bundle, importing the component inhtml<script>tagumd: Mostly used in older webpack bundles
importstatement is changed to named instead of default- Removed
onScrollanddpWrapMenuRefexposed methods - In
action-rowslot, paraminternalModelValueis renamed tomodelValue noTzproperty frompreset-datesconfig array is removed- Removed props:
positionauto-positionalt-positionutcformat-localemonth-name-formatuidweek-num-name
- Renamed props:
disable-month-year-selectteleport-center
- Moved props (prop behavior is retained, just moved under appropriate prop group):
select-text(and renamed)cancel-text(and renamed)now-button-label(and renamed)format(and renamed)preview-format(and renamed)namerequiredautocompletestateclearablealways-clearablehide-input-icondisabled-week-days(and renamed)enable-time-pickerignore-time-validationenable-secondsenable-minutesis-24no-hours-overlayno-minutes-overlayno-seconds-overlayhours-grid-incrementminutes-grid-ncrementseconds-grid-ncrementtime-picker-inlineday-classesc-closespace-confirmmonth-change-on-arrowsmonth-change-on-scrollpartial-flow(renamed)
- Removed emits:
recalculate-positionupdate:model-timezone-valuetime-picker-opentime-picker-close
- Altered props:
timezoneday-nameslocaleflowweek-numbers
- Timezone behavior is chained, places check the
timezoneprop info - All locale-based formating is now done via Unicode tokens
- Type definition is now auto-generated, there might be some misalignment between types from previous version and the new one
Importing the component
Importing the component is now done via named import:
import VueDatePicker from '@vuepic/vue-datepicker';
import { VueDatePicker } from '@vuepic/vue-datepicker'; Props changes
position, auto-position, alt-position
Since the position logic is now done via @floating-ui/vue library and custom positioning logic is removed, there is no need to keep these props.
position and auto-position props can be replaced with appropriate options in the floating prop
uid
The uid prop is now removed. Previously, it was using the same value and appending 'dp-menu' or 'dp-input' to it. Now, you can pass two separate values via menu-id prop for the menu, or inputAttrs.id for the input id.
utc
This prop is kind of a leftover since the initial versions before timezones. You should use the timezone prop instead.
<template>
<VueDatePicker
utc
timezone="utc"
/>
</template>format-locale
Prop type for locale is changed, making this prop redundant, use locale prop instead
<template>
<VueDatePicker
locale="ja-JP"
:format-locale="ja"
:locale="ja"
/>
</template>
<script setup>
import { ja } from "date-fns/locale"
</script>month-name-format
To change the month name format, you should use formats prop and unicode tokens
<template>
<VueDatePicker
month-name-format="long"
:formats="{ month: 'MMMM' }"
/>
</template>teleport-center
The prop is renamed to centered
<template>
<VueDatePicker
teleport-center
centered
/>
</template>select-text, cancel-text and now-button-label
These props are now grouped under action-row prop and renamed to unify the labels:
select-text->selectBtnLabelcancel-text->cancelBtnLabelnow-button-label->nowBtnLabel
<template>
<VueDatePicker
select-text="Pick"
cancel-text="Close"
now-button-label="Current"
:action-row="{
selectBtnLabel: 'Pick',
cancelBtnLabel: 'Close',
nowBtnLabel: 'Current'
}"
/>
</template>format and preview-format
These props are now grouped under formats prop and renamed:
format->inputpreview-format->preview
<template>
<VueDatePicker
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:formats="{ input: 'dd.MM.yyyy', preview: 'dd.MM.yyyy' }"
/>
</template>name, required, autocomplete, state, clearable, always-clearable and hide-input-icon
These props are now grouped under input-attrs prop. Prop types and names are unchanged.
Use camel case for naming multi-word props. e.g. always-clearable -> alwaysClearable
<template>
<VueDatePicker
:always-cleable="true"
:input-attrs="{ alwaysClearable: true }"
/>
</template>day-names
Prop type is changed, and no longer provides arguments if a function is provided:
- From:
((lang: string, weekStart: number) => string[]) | string[]; - To:
(() => string[]) | string[]
locale
Locale prop type is changed, and will now only accept date-fns Locale object.
disable-month-year-select
This prop is renamed to hide-month-year-select
disabled-week-days
This prop is now moved under filters prop and renamed to weekDays.
<template>
<VueDatePicker
:disabled-week-days="[3, 4]"
:filters="{ weekDays: [3, 4] }"
/>
</template>enable-time-picker, ignore-time-validation, enable-seconds, enable-minutes, is-24, no-hours-overlay, no-minutes-overlay, no-seconds-overlay, hours-grid-increment, minutes-grid-ncrement, seconds-grid-ncrement, time-picker-inline
These props are now grouped under time-config prop. Prop types and names are unchanged.
Use camel case for naming multi-word props. e.g. enable-time-picker -> enableTimePicker
<template>
<VueDatePicker
:enable-time-picker="false"
:time-config="{ enableTimePicker: false }"
/>
</template>day-class
This prop is now moved under ui prop.
<template>
<VueDatePicker
:day-class="(day, internalModel) => 'my-class'"
:ui="{ dayClass: (day, internalModel) => 'my-class' }"
/>
</template>esc-close, space-confirm, month-change-on-arrows, month-change-on-scroll
These props are now grouped under config prop. Prop types and names are unchanged.
Use camel case for naming multi-word props. e.g. esc-close -> escClose
<template>
<VueDatePicker
:esc-close="false"
:config="{ escClose: false }"
/>
</template>flow and partial-flow
These two props are now part of the FlowConfig prop object:
- Instead of an array of steps, the
flowprops accepts anobjectwithstepsproperty partial-flowis moved underflowconfig aspartial
<template>
<VueDatePicker
:flow="['year', 'month', 'calendar']"
:partial-flow="true"
:flow="{ steps: ['year', 'month', 'calendar'], partial: true }"
/>
</template>timezone
Timezone prop type is changed, and will now only accept string value
week-numbers and week-num-name
week-numbersprop now accepts only boolean or config objectweek-num-nameprop is now moved underweek-numbersaslabelproperty
<template>
<VueDatePicker
week-numbers="iso"
week-num-name="ww"
:week-numbers="{ type: 'iso', label: 'ww' }"
/>
</template>