Skip to content

<script setup> import DatePickerExample from './DatePickerExample.vue' </script>

DatePicker

DatePicker.vue

This is the main component that orchestrates the date picking functionality.

Props

PropTypeDefaultDescription
modelValueModelValuenullThe selected date or date range. Can be a Date object, a string, or a range object.
inlinebooleanfalseIf true, the datepicker is rendered directly in the page flow. Otherwise, it's a dropdown.
enableTimebooleanfalseIf true, a time picker is included for single date selections.
rangebooleanfalseIf true, allows for the selection of a date range.
presetsPreset[][]An array of predefined date ranges that the user can select from.
outputFormatstring | ((date: Date) => string) | nullnullThe format of the emitted date string. Can be a dayjs format string or a custom function.
is24hrbooleantrueIf true, the time picker uses a 24-hour format. Otherwise, it uses AM/PM.
calendarsnumber2The number of calendars to display simultaneously.
disabledbooleanfalseIf true, the datepicker input is disabled.
minDatestring | Date | nullnullThe earliest date that can be selected.
maxDatestring | Date | nullnullThe latest date that can be selected.

Events

EventPayloadDescription
update:modelValueModelValueEmitted when the selected date or range changes.
on-openundefinedEmitted when the datepicker popover is opened.
on-closeundefinedEmitted when the datepicker popover is closed.
date-selectedstring | DateEmitted when a single date is selected.
range-selected{ start: string | Date; end: string | Date; }Emitted when a date range is fully selected.

Slots

This component does not provide any slots.


Calendar.vue

This sub-component displays a single month calendar.

Props

PropTypeDefaultDescription
modelValueDate | DateRange | nullnullThe currently selected date or date range.
rangebooleanfalseIf true, the calendar supports range selection.
currentDateDatenew Date()The date that determines which month and year the calendar displays.
hidePrevbooleanfalseIf true, the "previous month" navigation button is hidden.
hideNextbooleanfalseIf true, the "next month" navigation button is hidden.

Events

EventPayloadDescription
update:modelValueDate | DateRangeEmitted when a date is clicked.
prev-monthundefinedEmitted when the "previous month" button is clicked.
next-monthundefinedEmitted when the "next month" button is clicked.

Slots

This component does not provide any slots.


TimePicker.vue

This sub-component allows for the selection of a specific time.

Props

PropTypeDefaultDescription
modelValue{ hours: number; minutes: number; }An object containing the selected hours and minutes.
is24hrbooleantrueIf true, the time is displayed in 24-hour format. Otherwise, it uses AM/PM.

Events

EventPayloadDescription
update:modelValue{ hours: number; minutes: number; }Emitted when the time changes.

Slots

This component does not provide any slots.


Presets.vue

This sub-component displays a list of predefined date ranges.

Props

PropTypeDefaultDescription
presetsPreset[][]An array of Preset objects to be displayed.
  • Preset type: { label: string; range: { start: Date; end: Date; } }

Events

EventPayloadDescription
select{ start: Date; end: Date; }Emitted when a preset range is selected.

Slots

This component does not provide any slots.

Examples

Here is a basic example of the DatePicker component.

Released under the MIT License.