General configuration
General behavior props configuration
model-value v-model
v-model binding
DANGER
Different modes require different types for model-value
- Exception to this rule is if you use
model-type
Date Picker
- Single -
Date - Range -
[Date, Date]or[Date, null]in case of partial range
Time Picker
- Single -
{ hours: number; minutes: number; seconds?: number } - Range -
{ hours: number; minutes: number; seconds?: number }[]
Week Picker
- Single -
[Date, Date] - Range -
[[Date, Date], [Date, Date]]
Month Picker
- Single -
{ month: number; year: number } - Range -
{ month: number; year: number }[]
Year Picker
- Single -
number - Range -
[number, number]
Quarter Picker
- Single -
Date - Range -
[Date, Date]
TIP
Datevalues can also bestringornumber, as long asnew Date(value)returns a valid datenumbervalues can also bestringvalues, as long asNumber(value)returns a valid number
- Default:
undefined
Code Example
<template>
<VueDatePicker :model-value="date" @update:model-value="(value) => date = value" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>model-type
Specify a custom format for v-model
- Type:
'timestamp' | 'format' | string - Default:
undefined
INFO
timestamp- uses timestamp for bindingformat- uses provided format or fallbacks to the default one. Must be a stringiso- date that will be returned will be in iso string formatstring- use custom format by providing a custom pattern with unicode tokens
This is only compatible with date pickers, time-picker and month-picker, other modes are not supported
Code Example
<template>
<VueDatePicker v-model="date" model-type="dd.MM.yyyy" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>auto-apply
If set to true, clicking on a date value will automatically select the value
- Type:
boolean - Default:
false
TIP
When auto-apply is used in combination with flow, to select date if flow is broken, you need to set flow.partial to true
Code Example
<template>
<VueDatePicker v-model="date" auto-apply />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>no-today
Hide today mark from the calendar
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" no-today />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>markers
Add markers to the specified dates with (optional) tooltips. For color options, you can use any css valid color.
- Type:
Markers[]
interface Marker {
date: Date | string | number;
type?: 'dot' | 'line';
tooltip?: { text: string; color?: string; slot?: string }[];
color?: string;
// el is an HTML element of a calendar cell
customPosition?: (el: HTMLElement) => Record<string, string | number>;
}- Default:
[]
TIP
- You can provide a
slotname in the tooltip object to use a custom slot for the tooltip
Code Example
<template>
<VueDatePicker v-model="date" :markers="markers" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
import { addDays } from 'date-fns';
const date = ref();
const markers = [
{
date: addDays(new Date(), 1),
type: 'dot',
tooltip: [{ text: 'Dot with tooltip', color: 'green' }],
},
{
date: addDays(new Date(), 2),
type: 'line',
tooltip: [
{ text: 'First tooltip', color: 'blue' },
{ text: 'Second tooltip', color: 'yellow' },
],
},
{
date: addDays(new Date(), 3),
type: 'dot',
color: 'yellow',
},
];
</script>highlight
Specify highlighted dates
- Type:
HighlightFn | Partial<Highlight>;
interface Highlight {
dates: Date[];
years: number[];
months: { month: number; year: number }[];
quarters: { quarter: number; year: number }[];
weekdays: number[];
options: { highlightDisabled: boolean };
}
type HighlightFn = ((date: Date) => boolean)
| ((month: { month: number; year: number }) => boolean)
| ((yearOrWeekDay: number) => boolean)
| ((quarter: { quarter: number; year: number }) => boolean);- Default:
undefined
Code Example
<template>
<VueDatePicker v-model="date" :highlight="{ dates: highlighted }" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
import { addDays } from 'date-fns';
const date = ref();
const highlighted = [
addDays(new Date(), 1),
addDays(new Date(), 2),
addDays(new Date(), 3),
];
</script>disabled
Disables the input
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" disabled />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>readonly
Sets the input in readonly state
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" readonly />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>hide-navigation
Hide navigation buttons from the overlays
- Type:
('month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds')[] - Default:
[]
Code Example
<template>
<VueDatePicker v-model="date" :hide-navigation="['month', 'year']" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>action-row
Control which buttons are shown in the action row
- Type:
import type { RoundingMethod, NearestMinutes } from 'date-fns';
interface ActionRow {
selectBtnLabel?: string;
cancelBtnLabel?: string;
nowBtnLabel?: string;
showSelect?: boolean;
showCancel?: boolean;
showNow?: boolean;
showPreview?: boolean;
nowBtnRound?: { rounding?: RoundingMethod; roundTo?: NearestMinutes }
}- Default:
{
selectBtnLabel: 'Select',
cancelBtnLabel: 'Cancel',
nowBtnLabel: 'Now',
showSelect: true,
showCancel: true,
showNow: false,
showPreview: true,
nowBtnRound: undefined,
}INFO
showNow- Places another button in the action row, where click on it results in selecting the current date and timenowBtnRound- WhenshowNowis enabled, you can configurenowbutton to round the selected time to the nearest minute. It supports two properties:rounding- A round method:"ceil" | "floor" | "round" | "trunc"roundTo- Value of minutes to round to: values from1to30
Code Example
<template>
<VueDatePicker v-model="date" :action-row="{ showPreview: false, showNow: true }" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>loading
Adds a loading overlay in the menu
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" loading />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>year-first
Reverse button order in the calendar header
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" year-first />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>disable-year-select
Removes the year button from the menu and cycles trough the current or provided year
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" disable-year-select />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>input-attrs
Configure input attributes
- Type:
interface InputAttrs {
name?: string;
required?: boolean;
autocomplete?: string;
state?: boolean;
clearable?: boolean;
alwaysClearable?: boolean;
hideInputIcon?: boolean;
id?: string;
inputmode?: 'search' | 'text' | 'none' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | undefined;
}- Default:
{
name: undefined,
required: false,
autocomplete: 'off',
state: undefined,
clearable: true,
alwaysClearable: false,
hideInputIcon: false,
id: undefined,
inputmode: 'none',
}INFO
name-HTMLInputElementname attributerequired-HTMLInputElementrequired attributestate- Validation state of the calendar value. Sets the green/red border depending on the valueclearable- Add a clear icon to the input field where you can set the value to nullalwaysClearable- Keeps the clear icon even if there is no value in the calendarhideInputIcon- Hide calendar icon in the input fieldid- Sets theidattribute on the input fieldinputmode-HTMLInputElementinputmode attribute
Code Example
<template>
<VueDatePicker v-model="date" :input-attrs="{ hideInputIcon: true }" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>six-weeks
Always display six weeks on the calendar. This will prevent dynamic calendar height change depending on the month
- Type:
boolean | 'append' | 'prepend' | 'center' | 'fair' - Default:
false
INFO
boolean- Legacy enable, same as append'append'- Always add new row(s) at the bottom of the calendar'prepend'- Always add new row(s) at the beginning of the calendar'center'- If the month that needs padding starts with the beginning of a week, add a week at the start. If a second week needs to be added, add it in the end. This way, every month will have offset days on each end, and months like Feb. 2021 will not have that huge tail. This mode does not add a week before if the month already starts with a partial week'fair'- The first extra week is added to either start or end of the month, depending on which partial week has fewer offset days. This solves the same problems as center, but aims to distribute the padding more evenly. Since it leads to more months having a leading offset week, which is not necessarily desirable. The difference is visible e.g. in June 2021
Code Example
<template>
<VueDatePicker v-model="date" six-weeks="center" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>calendar
Customize the calendar view, filter out weeks, add or remove custom classes
DANGER
Do not modify date values
- Type:
(weeks: CalendarWeek[]) => CalendarWeek[]; - Default:
undefined
interface CalendarWeek {
days: {
text: number | string; // Value displayed in the calendar day box
value: Date; // Date that is going to be selected, do not modify
current: boolean; // If the date belongs to the currenct month
classData: Record<string, boolean>; // All classes for a specific date
}[]
}Code Example
<template>
<VueDatePicker v-model="date" :calendar="calendarFn" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
const calendarFn = (weeks) => {
return weeks
.filter((week) => week.days.some((day) => day.text === 15))
.map((week) => ({
...week,
days: week.days.map((day) => {
day.classData['custom-class'] = true;
return day;
}),
}));
}
</script>hide-offset-dates
Hide dates from the previous/next month in the calendar
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" hide-offset-dates />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>week-start
Day from which the week starts. 0-6, 0 is Sunday, 6 is Saturday
- Type:
number | string - Default:
1
Code Example
<template>
<VueDatePicker v-model="date" :week-start="0" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>year-range
Specify start and end year for years to generate
- Type:
[number, number] - Default:
[1900, 2100]
Code Example
<template>
<VueDatePicker v-model="date" :year-range="[2020, 2040]" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>reverse-years
Reverse the order of the years in years overlay
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" :year-range="[2020, 2040]" reverse-years />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>floating
Configure floating menu
- Type:
import { type ShallowRef } from 'vue';
import type { Placement, Strategy } from '@floating-ui/vue';
interface FloatingConfig {
offset?: number;
arrow?: Readonly<ShallowRef<HTMLDivElement | null>> | boolean;
strategy?: Strategy;
placement?: Placement;
}- Default:
{ offset: 10, arrow: true, strategy: undeifned, placement: undefined }
INFO
offset- Offset from the input fieldarrow- Show/hide floating menu arrow. If you usearrowslot, you should pass thetemplate reffor proper arrow positioningstrategy- Useabsoluteorfixedpositioning strategyplacement- Position of the floating menu
Code Example
<template>
<VueDatePicker v-model="date" :floating="{ arrow: false, offset: 0 }" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>aria-labels
Customize the language of the HTML aria-labels for localized accessibility
- Type
interface AriaLabelsConfig {
toggleOverlay?: string;
menu?: string;
input?: string;
openTimePicker?: string;
closeTimePicker?: string;
incrementValue?: (type: 'hours' | 'minutes' | 'seconds') => string;
decrementValue?: (type: 'hours' | 'minutes' | 'seconds') => string;
openTpOverlay?: (type: 'hours' | 'minutes' | 'seconds') => string;
amPmButton?: string;
openYearsOverlay?: string;
openMonthsOverlay?: string;
nextMonth?: string;
prevMonth?: string;
nextYear: string;
prevYear: string;
day?: ({value}: {value: Date}) => string;
weekDay?: (day: number) => string;
clearInput?: string;
calendarIcon?: string;
timePicker?: string;
monthPicker: (overlay: boolean) => string;
yearPicker: (overlay: boolean) => string;
timeOverlay: (type: 'hours' | 'minutes' | 'seconds') => string;
}- Default:
{}
Code Example
<template>
<VueDatePicker v-model="date" :aria-labels="ariaLabels" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
const ariaLabels = { menu: 'Some custom menu label' }
</script>week-numbers
Display week numbers in the calendar. You can switch between local index, ISO numbering and custom function
- Type:
boolean | WeekNumbersConfig
interface WeekNumbersConfig {
type?: 'iso' | 'local' | ((date: Date) => string | number);
hideOnOffsetDates?: boolean;
label?: string
}- Default:
false
Code Example
<template>
<VueDatePicker v-model="date" :week-numbers="{ type: 'local' }" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>day-names
Provide custom labels for day names in the calendar header
WARNING
- The array order will be rendered as is, make sure to sync it with
week-startprop - Make sure that a provided array has a length of 7
- Type:
(() => string[]) | string[] - Default:
null;
Code Example
<template>
<VueDatePicker v-model="date" :day-names="['1', '2', '3', '4', '5', '6', '7']" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>config
General configuration for customizing specific date picker behaviour
- Type:
interface Config {
allowStopPropagation: boolean;
closeOnScroll: boolean;
modeHeight: number;
allowPreventDefault: boolean;
closeOnClearValue: boolean;
closeOnAutoApply: boolean;
noSwipe: boolean;
keepActionRow: boolean;
onClickOutside?: (validate: () => boolean, evt: PointerEvent) => void;
tabOutClosesMenu: boolean;
arrowLeft?: string;
keepViewOnOffsetClick?: boolean;
timeArrowHoldThreshold: number;
shadowDom?: boolean;
mobileBreakpoint: number;
setDateOnMenuClose?: boolean;
escClose?: boolean;
spaceConfirm?: boolean;
monthChangeOnArrows?: boolean;
monthChangeOnScroll?: boolean | string;
}- Default:
{
allowStopPropagation: true,
closeOnScroll: false,
modeHeight: 255,
allowPreventDefault: false,
closeOnClearValue: true,
closeOnAutoApply: true,
noSwipe: false,
keepActionRow: false,
onClickOutside: undefined,
tabOutClosesMenu: true,
arrowLeft: undefined,
keepViewOnOffsetClick: false,
timeArrowHoldThreshold: 0,
shadowDom: false,
mobileBreakpoint: 600,
setDateOnMenuClose: false,
escClose: true,
spaceConfirm: true;
monthChangeOnArrows: true
monthChangeOnScroll: true;
}INFO
allowStopPropagation- Enableevent.sportPropagationon click eventscloseOnScroll- Close datepicker menu on page scrollmodeHeight- If you usemonth-picker,time-pickeroryear-picker, set custom height of the picker inpxallowPreventDefault- Due to the different implementations of how click outside listeners are implemented, you might encounter issues where the menu closes if the picker is used in dialogs whenteleportprop is enabled. To prevent this issue, you need to set this option totruecloseOnClearValue- Prevent closing the menu on value clear from the input fieldcloseOnAutoApply- If set tofalse, clicking on a date value will automatically select the value but will not close the datepicker menu. Closing will be available on a click-away or clicking on the input againnoSwipe- Disable touch events on the calendarkeepActionRow- When enabled, it will keep the action row even if theauto-applyprop is enabledonClickOutside- Provide custom click outside handler. Exposed validation function that will returntrueorfalsedepending on the selected value and pointer eventtabOutClosesMenu- When tabbing out of the picker menu it will close the picker menu (not compatible when usingteleport)arrowLeft- Overrides default arrow position from left side of the menu. To keep it always in the center, set it to50%. Accepts validCSSvaluekeepViewOnOffsetClick- When enabled, clicking on the offset date will not change the month that is currently in the viewtimeArrowHoldThreshold- When provided with a value> 0, clicking and holding the arrow button in thetime-pickerwill increment/decrement the value. This value represents thesetTimeoutvalue, meaning the larger the number, the change will be slower.0disables the hold eventshadowDom- Set totrueif you are using the component with web componentsmobileBreakpoint- Mobile breakpoint in pixelssetDateOnMenuClose- When enabled, clicking away from the menu will set the selected date if some date is selected. Behaves similar toauto-apply, but it only applies the date on click-awayescClose-Esckey closes the menuspaceConfirm-spacekey selects the date (like you pressed the select button)monthChangeOnArrows- Change months via arrow keysmonthChangeOnScroll- Scrolling the mouse wheel over the calendar will change the month. Scroll down for next month and vice versa. You can set the value toinverseto reverse scrolling up and down.
start-date
Open the datepicker to some preselected month and year
- Type:
Date | string | number - Default:
undefined
Code Example
<template>
<VueDatePicker v-model="date" :start-date="new Date(2020, 1)" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>focus-start-date
Open the datepicker to provided start-date ignoring the v-model value
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" :start-date="new Date(2020, 1)" focus-start-date />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>teleport
Use teleport to position the datepicker menu. This is useful if you have hidden overflow on the parent HTML element where the menu is not showing in full.
TIP
- Setting the prop to
true, the menu will be placed on thebodytag - If you use
stringvalue, provideidof the element
- Type:
string | boolean | HTMLElement - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" :teleport="true" />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>centered
Sets the menu position on the page center, useful for smaller screens where there is no space available above or below the input field
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" centered />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>arrow-navigation
Navigate the menu via arrow keys
Code Example
<template>
<VueDatePicker v-model="date" arrow-navigation />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>preset-dates
When configured, it will provide a sidebar with a configured range / date that the user can select
- Type:
PresetDate[]
import type { MaybeRefOrGetter } from "vue";
interface PresetDate {
label: string;
value: MaybeRefOrGetter<Date[] | string[] | Date | string>;
style?: Record<string, string>;
slot?: string;
testId?: string;
}- Default:
[]
TIP
- You can provide a custom
slotname for a specific preset date and use it as standard slot
Code Example
<template>
<VueDatePicker v-model="date">
<template #preset-date-range-button="{ label, value, presetDate }">
<span
role="button"
:tabindex="0"
@click="presetDate(value)">
{{ label }}
</span>
</template>
</VueDatePicker>
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
import { endOfMonth, endOfYear, startOfMonth, startOfYear, subMonths } from 'date-fns';
const date = ref();
const presetDates = ref([
{
label: 'Today (Slot)',
value: [new Date(), new Date()],
slot: 'preset-date-range-button'
},
{ label: 'Today', value: [new Date(), new Date()] },
{ label: 'This month', value: [startOfMonth(new Date()), endOfMonth(new Date())] },
{
label: 'Last month',
value: [startOfMonth(subMonths(new Date(), 1)), endOfMonth(subMonths(new Date(), 1))],
},
{ label: 'This year', value: [startOfYear(new Date()), endOfYear(new Date())] },
]);
</script>hide-month-year-select
Removes the month and year picker
- Type:
boolean - Default:
false
Code Example
<template>
<VueDatePicker v-model="date" hide-month-year-select />
</template>
<script setup>
import { VueDatePicker } from "@vuepic/vue-datepicker";
import { ref } from 'vue';
const date = ref();
</script>