Skip to content

DatePicker ​

A date field: type the date in the language's format ("mm/dd/yyyy" in US English) or pick it in a calendar.

Usage ​

In a FormField ​

Value: empty

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

const departure = ref(null)
</script>

<template>
  <SuFormField label="Departure date" message="Type mm/dd/yyyy or open the calendar">
    <SuDatePicker v-model="departure" :min="new Date()" />
  </SuFormField>
</template>

Initial value and maximum date ​

vue
<SuDatePicker v-model="birth" :max="new Date()" />

API ​

Props ​

PropTypeDefaultDescription
modelValueDate | nullnullDate (v-model)
min / maxDate-Accepted dates
isDateDisabled(date: Date) => boolean-Refused days
localestringcomponent localeFormat and calendar language
weekStartsOnnumberfrom the languageFirst day of the week
placeholderstringexpected format (dd/mm/yyyy, mm/dd/yyyy…)Placeholder
size'sm' | 'md' | 'lg''md'Size
state'default' | 'error' | 'success' | 'warning''default'Validation state
disabled / readonly / requiredbooleanfalseField states (readonly hides the calendar)
namestring-Field name
openLabelstring'Choose a date' (locale)Calendar button name

Events ​

EventPayloadDescription
update:modelValueDate | nullNew (committed) date
changeDate | nullDate changed by the user
focus / blurFocusEventField focus

Exposed methods ​

MethodDescription
focus()Focuses the field
open() / close()Opens or closes the calendar

Accessibility ​

  • The text field stays the main path: the date is committed when leaving the field or with Enter. An unreadable, non-existent (02/31) or out-of-range date restores the previous value.
  • The button is named with the selected date ("Change date, November 5, 2026") and announces a dialog (aria-haspopup="dialog", aria-expanded).
  • Calendar in a role="dialog": focus on the active day when opening, Tab trapped, Escape or an outside press closes; picking a day closes and returns focus to the button. Alt + ↓ opens the calendar from the field.
  • The month and year in the calendar title open month and year selection (handy for a date of birth); Escape first goes back to the days, then closes the calendar.
  • Calendar keyboard: see Calendar.

Publié sous licence MIT.