Skip to content

DatePicker API Reference ​

Props ​

Core Props ​

PropTypeDefaultDescription
modelValueDate | String | Array | Object | NumbernullThe selected date/time value
typeString'date'Picker type: 'date', 'time', or 'datetime'
placeholderStringnullPlaceholder text (auto-set based on type if not provided)
labelString''Input label
disabledBooleanfalseDisable the date picker
readonlyBooleanfalseMake the input readonly
clearableBooleantrueShow clear button when value is set
loadingBooleanfalseShow loading state

Formatting Props ​

PropTypeDefaultDescription
formatStringnullDate format (auto-set based on type if not provided)
displayFormatStringnullDisplay format using moment.js patterns
outputFormatStringnullOutput format - emits formatted strings instead of Date objects
previewFormatStringnullPreview format for the picker

Selection Mode Props ​

PropTypeDefaultDescription
rangeBooleanfalseEnable date range selection
multiDatesBooleanfalseEnable multiple date selection
multiDatesLimitNumbernullMaximum number of dates that can be selected

Constraint Props ​

PropTypeDefaultDescription
minDateDate | StringnullMinimum selectable date
maxDateDate | StringnullMaximum selectable date
disabledDatesArray[]Array of dates to disable
disabledWeekDaysArray[]Array of week day numbers to disable (0-6)
yearRangeArray[currentYear-50, currentYear+50]Available year range

Time Picker Props ​

PropTypeDefaultDescription
enableTimePickerBooleanfalseEnable time picker functionality
timePickerOptionsObject{}Options for time picker configuration
is24HourBooleantrueUse 24-hour format
enableSecondsBooleanfalseEnable seconds selection

Display Props ​

PropTypeDefaultDescription
hideCalendarIconBooleanfalseHide the calendar/clock icon
hideDetailsBooleanfalseHide input details/validation messages
darkBooleanfalseEnable dark theme
localeString'en-US'Locale for internationalization
timezoneStringnullTimezone for date handling

Calendar Display Props ​

PropTypeDefaultDescription
weekStartNumber | String0First day of week (0 = Sunday)
sixWeeksBooleantrueShow six weeks in calendar
weekNumbersString | Function | ObjectnullShow week numbers
hideOffsetDatesBooleanfalseHide dates from adjacent months
noTodayBooleanfalseHide today indicator

Picker Type Props ​

PropTypeDefaultDescription
monthPickerBooleanfalseShow month picker only
yearPickerBooleanfalseShow year picker only
quarterPickerBooleanfalseShow quarter picker only

Behavior Props ​

PropTypeDefaultDescription
autoApplyBooleantrueAutomatically apply selection
closeOnAutoApplyBooleantrueClose picker on auto-apply
textInputBooleanfalseAllow manual text input
monthChangeOnScrollBooleantrueChange month on scroll

Overlay Props ​

PropTypeDefaultDescription
noHoursOverlayBooleanfalseHide hours overlay in time picker
noMinutesOverlayBooleanfalseHide minutes overlay in time picker
noSecondsOverlayBooleanfalseHide seconds overlay in time picker

Customization Props ​

PropTypeDefaultDescription
markersArray[]Array of date markers
highlightArray | Function() => []Highlight specific dates
selectTextString'Select'Text for select button
cancelTextString'Cancel'Text for cancel button
nowButtonLabelString'Now'Text for now button

Validation Props ​

PropTypeDefaultDescription
rulesArray[]Validation rules array
hintString''Hint text for the input

Events ​

EventPayloadDescription
update:modelValueDate | String | Array | Object | nullEmitted when the value changes
changeDate | String | Array | Object | nullEmitted when a date is selected/changed
open-Emitted when the picker opens
close-Emitted when the picker closes
cleared-Emitted when the value is cleared

Slots ​

SlotPropsDescription
date-picker-header-Custom content for the picker header
date-picker-footer-Custom content for the picker footer (action buttons area)

Methods ​

MethodParametersReturn TypeDescription
validate-BooleanValidate the input and return validation result
setInternalValuevalue: anyvoidSet the internal value programmatically
getMomentValue-Moment | Array<Moment> | Object | nullGet the current value as moment.js object(s)

Format Examples ​

Date Formats (Moment.js) ​

javascript
// Common formats
'DD/MM/YYYY'     // 25/12/2023
'MM/DD/YYYY'     // 12/25/2023
'YYYY-MM-DD'     // 2023-12-25
'DD MMM YYYY'    // 25 Dec 2023
'MMMM DD, YYYY'  // December 25, 2023

Time Formats (Moment.js) ​

javascript
// Time formats
'HH:mm'          // 14:30 (24-hour)
'hh:mm A'        // 02:30 PM (12-hour)
'HH:mm:ss'       // 14:30:45 (with seconds)
'hh:mm:ss A'     // 02:30:45 PM (12-hour with seconds)

DateTime Formats (Moment.js) ​

javascript
// DateTime formats
'DD/MM/YYYY HH:mm'     // 25/12/2023 14:30
'MM/DD/YYYY hh:mm A'   // 12/25/2023 02:30 PM
'YYYY-MM-DD HH:mm:ss'  // 2023-12-25 14:30:45

Example Usage ​

Basic Date Picker ​

vue
<template>
  <ODatePicker
    v-model="selectedDate"
    type="date"
    label="Select Date"
    placeholder="Choose a date"
    :minDate="new Date(2023, 0, 1)"
    :maxDate="new Date(2023, 11, 31)"
    @change="handleDateChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const selectedDate = ref(null)

const handleDateChange = (date) => {
  console.log('Selected date:', date)
}
</script>

Time Picker ​

vue
<template>
  <ODatePicker
    v-model="selectedTime"
    type="time"
    label="Select Time"
    :is24Hour="false"
    :enableSeconds="true"
    format="hh:mm:ss A"
    @change="handleTimeChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const selectedTime = ref(null)

const handleTimeChange = (time) => {
  console.log('Selected time:', time)
}
</script>

Date Range Picker ​

vue
<template>
  <ODatePicker
    v-model="dateRange"
    :range="true"
    label="Select Date Range"
    format="DD/MM/YYYY"
    :autoApply="false"
    @change="handleRangeChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const dateRange = ref(null)

const handleRangeChange = (range) => {
  console.log('Date range:', range)
}
</script>

Multi-Date Picker ​

vue
<template>
  <ODatePicker
    v-model="multipleDates"
    :multiDates="true"
    :multiDatesLimit="5"
    label="Select Multiple Dates"
    format="DD/MM/YYYY"
    @change="handleMultiDateChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const multipleDates = ref([])

const handleMultiDateChange = (dates) => {
  console.log('Selected dates:', dates)
}
</script>

DateTime Picker with Custom Formatting ​

vue
<template>
  <ODatePicker
    v-model="dateTime"
    type="datetime"
    label="Select Date & Time"
    displayFormat="DD/MM/YYYY HH:mm"
    outputFormat="YYYY-MM-DDTHH:mm:ss"
    :is24Hour="true"
    :enableSeconds="true"
    @change="handleDateTimeChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const dateTime = ref(null)

const handleDateTimeChange = (dateTime) => {
  console.log('Selected date/time:', dateTime)
}
</script>

Date Picker with Validation ​

vue
<template>
  <ODatePicker
    v-model="date"
    label="Required Date"
    :rules="[v => !!v || 'Date is required']"
    :clearable="false"
    @change="handleDateChange"
  />
</template>

<script setup>
import { ref } from 'vue'

const date = ref(null)

const handleDateChange = (date) => {
  console.log('Date selected:', date)
}
</script>

Dependencies ​

This component requires the following dependencies:

  • @vuepic/vue-datepicker - Core date picker functionality
  • moment - Date formatting and manipulation
  • OInput - Input component for the wrapper