Skip to content

Date Picker ​

<pa-date-picker> | PaDatePicker

A feature-rich date picker component built on @vuepic/vue-datepicker with validation, flexible formatting, and customizable display options. Supports both inline and dropdown modes with weekend highlighting and date constraints.

vue
<pa-date-picker v-model="selectedDate" />

Examples ​

Basic Date Picker ​

vue
<template>
  <pa-date-picker v-model="selectedDate" placeholder="Select a date..." />
</template>

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

const selectedDate = ref(null)
</script>

Use the isDropdown prop to enable a dropdown style with calendar and chevron icons.

vue
<template>
  <pa-date-picker 
    v-model="dropdownDate" 
    is-dropdown 
    placeholder="Choose date..." 
  />
</template>

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

const dropdownDate = ref(null)
</script>

With Label ​

Add a floating label that appears when the field is focused or has a value.

vue
<template>
  <pa-date-picker 
    v-model="birthDate" 
    label="Birth Date" 
  />
</template>

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

const birthDate = ref(null)
</script>

Date Constraints ​

Set minimum and maximum dates to restrict date selection.

vue
<template>
  <div style="display: flex; flex-direction: column; gap: 1rem;">
    <pa-date-picker 
      v-model="futureDate" 
      :min-date="new Date()" 
      placeholder="Future dates only" 
    />
    <pa-date-picker 
      v-model="rangeDate" 
      :min-date="new Date('2020-01-01')" 
      :max-date="new Date('2025-12-31')" 
      placeholder="Date range 2020-2025" 
    />
  </div>
</template>

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

const futureDate = ref(null)
const rangeDate = ref(null)
</script>

Required Field ​

Mark the date picker as required for form validation.

vue
<template>
  <pa-date-picker 
    v-model="requiredDate" 
    required 
    placeholder="Required date field" 
  />
</template>

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

const requiredDate = ref(null)
</script>

Date Output Formats ​

Configure different output formats for the v-model value.

vue
<template>
  <div style="display: flex; flex-direction: column; gap: 1rem;">
    <pa-date-picker 
      v-model="dateObject" 
      format="date" 
      placeholder="Date object output" 
    />
    <pa-date-picker 
      v-model="isoString" 
      format="iso_string" 
      placeholder="ISO string output" 
    />
    <pa-date-picker 
      v-model="shortIsoString" 
      format="short_iso_string" 
      placeholder="Short ISO string output (default)" 
    />
  </div>
</template>

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

const dateObject = ref(null)       // Outputs: Date object
const isoString = ref(null)        // Outputs: "2024-12-25T00:00:00.000Z"
const shortIsoString = ref(null)   // Outputs: "2024-12-25"
</script>

Weekend Options ​

Control weekend display and behavior.

vue
<template>
  <div style="display: flex; flex-direction: column; gap: 1rem;">
    <pa-date-picker 
      v-model="weekendDate1" 
      placeholder="With weekends highlighted" 
    />
    <pa-date-picker 
      v-model="weekendDate2" 
      :show-weekends="false" 
      placeholder="No weekend highlighting" 
    />
    <pa-date-picker 
      v-model="weekendDate3" 
      weekend-tooltip="Weekend day" 
      placeholder="Custom weekend tooltip" 
    />
  </div>
</template>

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

const weekendDate1 = ref(null)
const weekendDate2 = ref(null)
const weekendDate3 = ref(null)
</script>

Importing ​

typescript
import { PaDatePicker } from '@payadvantage/ui_components'

Properties ​

NameDescriptionReflectsTypeDefault
modelValueThe selected date value (used with v-model).noDate | string | nullnull
formatOutput format for the v-model value.no'date' | 'iso_string' | 'short_iso_string''short_iso_string'
isDropdownDisplay as a dropdown with calendar and chevron icons.nobooleanfalse
requiredMarks the date picker as required for validation.nobooleanfalse
showWeekendsWhether to highlight weekends in the calendar.nobooleantrue
showTodayWhether to show a "Today" button.nobooleantrue
minDateMinimum selectable date.noDate | string | nullnull
maxDateMaximum selectable date.noDate | string | nullnull
placeholderPlaceholder text for the input field.nostring | nullnull
weekendPopupOverWhether weekend tooltips appear on hover.nobooleantrue
isInlineDisplay the calendar inline instead of as a popup.nobooleanfalse
weekendTooltipCustom tooltip text for weekend days.nostring | nullnull
labelFloating label text that appears above the input.nostring''
sfSelectorCustom selector for testing frameworks.nostring | nullnull

Events ​

NameDescriptionEvent Detail
update:modelValueEmitted when the selected date changes (for v-model).New date value in specified format
focusEmitted when the input receives focus.Focus event
blurEmitted when the input loses focus.Blur event

Slots ​

The date picker component does not support custom slots.

Dependencies ​

  • @vuepic/vue-datepicker: Core date picker functionality and calendar display
  • PaIcon: Used for calendar and chevron icons in dropdown mode
  • Validation Mixin: Provides built-in validation capabilities with visual feedback
  • Date Utils: Internal utility functions for date formatting and manipulation
  • Bootstrap CSS: Uses Bootstrap's form control styling for consistent appearance

Design Notes ​

The date picker component provides:

  • Flexible formatting: Three output formats (Date object, ISO string, short ISO string)
  • Multiple display modes: Inline calendar or dropdown with icons
  • Date constraints: Min/max date validation with automatic enforcement
  • Weekend highlighting: Configurable weekend display with custom tooltips
  • Floating labels: Optional labels that animate based on focus and value state
  • Built-in validation: Automatic validation with visual feedback states
  • Locale support: Uses en-GB locale with dd/MM/yyyy display format

This component is ideal for:

  • Form date inputs with validation requirements
  • Event scheduling and booking systems
  • Date range selection with constraints
  • Birthday and anniversary inputs
  • Appointment and calendar applications

Accessibility Notes ​

  • Uses semantic HTML input elements for proper screen reader support
  • Maintains focus states for keyboard navigation
  • Supports ARIA attributes and validation messages
  • Required fields are properly marked for assistive technologies
  • Validation states are communicated visually and programmatically
  • Calendar navigation is keyboard accessible through the underlying vue-datepicker

Format Options ​

The format prop determines how the selected date is output through v-model:

  • 'date': Returns a JavaScript Date object
  • 'iso_string': Returns a full ISO 8601 string (e.g., "2024-12-25T00:00:00.000Z")
  • 'short_iso_string' (default): Returns a short ISO date string (e.g., "2024-12-25")

Choose the format that best matches your backend API requirements or data processing needs.