Date of birth
Choose a calendar date and submit a canonical YYYY-MM-DD value.
Components / Forms
A polished calendar picker with localized formatting and native form behavior.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add date-pickerImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import { ref } from 'vue'
import DatePicker from './components/ui/date-picker/DatePicker.vue'
const date = ref('')
</script>
<template>
<label for="start-date">Start date</label>
<DatePicker
id="start-date"
v-model="date"
name="startDate"
min="2026-01-01"
locale="en-GB"
:messages="{
calendarLabel: 'Choose a start date',
previousMonth: 'Previous month',
nextMonth: 'Next month',
chooseDate: 'Choose date',
clearSelection: 'Clear date',
}"
/>
</template>The custom calendar supports arrows, Home/End, Page Up/Down, and Escape. Its off-screen native date control preserves form serialization and constraints; always provide an associated label or ARIA name.
Choose a calendar date and submit a canonical YYYY-MM-DD value.
Show a local date format while keeping timezone decisions in application scheduling logic.
The model stays YYYY-MM-DD even when the trigger is localized.
<script setup lang="ts">
import { ref } from 'vue'
import DatePicker from './components/ui/date-picker/DatePicker.vue'
const date = ref('')
const messages = {
calendarLabel: 'Choose appointment date',
previousMonth: 'Previous month',
nextMonth: 'Next month',
chooseDate: 'Choose date',
clearSelection: 'Clear date',
}
</script>
<template>
<label for="appointment-date">Appointment date</label>
<DatePicker
id="appointment-date"
v-model="date"
name="appointmentDate"
locale="en-GB"
:first-day-of-week="1"
:messages="messages"
required
/>
</template>Set supported bounds as canonical date strings.
<script setup lang="ts">
import { ref } from 'vue'
import DatePicker from './components/ui/date-picker/DatePicker.vue'
const arrival = ref('')
const messages = {
calendarLabel: 'Choisir une date',
previousMonth: 'Mois précédent',
nextMonth: 'Mois suivant',
chooseDate: 'Choisir une date',
clearSelection: 'Effacer la date',
}
</script>
<template>
<label for="arrival">Date d’arrivée</label>
<DatePicker
id="arrival"
v-model="arrival"
min="2026-10-01"
max="2026-12-31"
locale="fr-FR"
:first-day-of-week="1"
:messages="messages"
/>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
referenceDateprop | string | undefined | Not set | Stable date used to decide which month or year appears first. |
idprop | string | undefined | Not set | Give the control an ID so a label or description can refer to it. |
nameprop | string | undefined | Not set | Name used when this control submits a value with a form. |
formprop | string | undefined | Not set | Associate the control with a form by its ID. |
sizeprop | ControlSize | undefined | "md" | Choose the visual size. Medium is the usual default where available. |
invalidprop | boolean | undefined | Not set | Show the invalid state; also provide a visible error message. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
readonlyprop | boolean | undefined | Not set | Show the value while preventing edits. |
requiredprop | boolean | undefined | Not set | Ask the browser to require a value before form submission. |
minprop | string | undefined | Not set | Smallest allowed value. |
maxprop | string | undefined | Not set | Largest allowed value. |
localeprop | string | undefined | Not set | Choose the language and regional formatting for dates or text. |
firstDayOfWeekprop | 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined | 1 | Choose which weekday begins each calendar row. |
messagesprop | DatePickerMessages | Required | Supply the text this component displays for its built-in actions and states. |
modelValuemodel | string | undefined | "" | Current value. Use v-model to keep it in sync with your page. |
update:modelValueevent | [value: string] | — | Requests a new model value from the parent. |
errorslot | { message: string; messages: string[]; } | Optional | Content for the error area of DatePicker. |
elementexposed | HTMLInputElement | null | — | Reference to the underlying HTML element. |
triggerElementexposed | HTMLButtonElement | null | — | Access trigger element from a component template ref. |
focusexposed | () => void | undefined | — | Move keyboard focus to this control. |
showPickerexposed | () => void | — | Access show picker from a component template ref. |
openexposed | () => void | — | Open this component from application code. |
closeexposed | (restoreFocus?: boolean) => void | — | Close this component from application code. |
// packages/frameworks/vue/components/date-picker/types.ts
import type { ControlSize } from '@getweini/vue/types'
export interface DatePickerMessages {
calendarLabel: string
previousMonth: string
nextMonth: string
chooseDate: string
clearSelection: string
}
export interface DatePickerProps {
referenceDate?: string
id?: string
name?: string
form?: string
size?: ControlSize
invalid?: boolean
disabled?: boolean
readonly?: boolean
required?: boolean
min?: string
max?: string
locale?: string
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6
messages: DatePickerMessages
}
// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
label: string;
value: T;
disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
/** Popup name when no aria-label or aria-labelledby is supplied. */
listboxLabel: string;
empty: string;
clearSelection: string;
}
export interface ListboxProps<T> {
options: readonly SelectOption<T>[];
messages: ListboxMessages;
id?: string;
disabled?: boolean;
required?: boolean;
invalid?: boolean;
name?: string;
form?: string;
placeholder?: string;
size?: ControlSize;
clearable?: boolean;
gap?: number;
/** Supply stable equality for object values. Values must be unique. */
by?: (a: T, b: T) => boolean;
/** Required for meaningful form submission of object values. */
serialize?: (value: T) => string;
}
// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
variant?: Variant;
size?: Size;
disabled?: boolean;
loading?: boolean;
type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
as?: 'button' | 'a' | Component;
asChild?: boolean;
}