Raccourci clavier : Ctrl + K
Commencer

Champ de date

VDateInput associe un champ de date localisé à VDatePicker. Il accepte une date, une période ou plusieurs dates.

Utilisation

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const date = ref<string | null>(null)
</script>

<template>
  <VDateInput v-model="date" label="Start date" show-picker />
</template>

Exemples

Libellé, aide et icône

Nommez le champ avec label et ajoutez une aide avec hint.

vue

Type it or pick it from the calendar

The calendar is the only way in

Chargement…

An icon at the start, a spinner at the end while something loads

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'
import { calendar_today as calendarToday, schedule, search } from 'vectis-ui/icons'

const start = ref<string | null>('2026-06-10')
const deadline = ref<string | null>(null)
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="start"
      label="Start date"
      hint="Type it or pick it from the calendar"
      show-picker
      :picker-icon="calendarToday"
    />

    <VDateInput
      v-model="deadline"
      label="Deadline"
      hint="The calendar is the only way in"
      mode="picker"
      :picker-icon="schedule"
    />

    <VDateInput
      v-model="start"
      label="Filter by date"
      hint="An icon at the start, a spinner at the end while something loads"
      :icon-start="search"
      loading
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Tailles

size définit la taille du champ.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const rows = ref(
  (['sm', 'md', 'lg'] as const).map((size) => ({
    key: size,
    size,
    label: size,
    date: '2026-06-10' as string | null,
  })),
)
</script>

<template>
  <div class="column">
    <VDateInput
      v-for="row in rows"
      :key="row.key"
      v-model="row.date"
      :size="row.size"
      :label="row.label"
      show-picker
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Modes

input accepte une date numérique localisée. showPicker y ajoute un calendrier. picker utilise uniquement le calendrier ; les sélections de période et de dates multiples imposent ce mode.

vue

No icon, no panel: the field is the whole control

showPicker adds the icon and opens the panel on focus

Nothing can be typed, so the calendar is the only way in

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const typed = ref<string | null>('2026-06-10')
const withPicker = ref<string | null>('2026-06-10')
const readOnly = ref<string | null>('2026-06-10')
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="typed"
      label="Typed, the default"
      hint="No icon, no panel: the field is the whole control"
    />

    <VDateInput
      v-model="withPicker"
      show-picker
      label="Typed, with the calendar"
      hint="showPicker adds the icon and opens the panel on focus"
    />

    <VDateInput
      v-model="readOnly"
      mode="picker"
      label="Read-only"
      hint="Nothing can be typed, so the calendar is the only way in"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Période

selection="range" utilise un modèle { start, end }. Chaque borne est une date ISO ou null.

vue

Pick the first day, then the last. Typing falls back to read-only here.

2026-06-19 to 2026-06-26
<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput, type DatePickerRange } from 'vectis-ui'

const period = ref<DatePickerRange>({ start: '2026-06-19', end: '2026-06-26' })
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="period"
      selection="range"
      label="Period"
      hint="Pick the first day, then the last. Typing falls back to read-only here."
      clearable
    />
    <output class="value" aria-label="Chosen period">
      {{ period.start ?? 'none' }} to {{ period.end ?? 'none' }}
    </output>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-3);
  max-inline-size: 26rem;
}
.value {
  font-family: var(--vectis-text-family-code);
  font-size: var(--vectis-text-body-sm-size);
  color: var(--vectis-color-text-muted);
}
</style>

Dates multiples

selection="multiple" utilise un tableau de dates ISO. Sélectionnez à nouveau une date pour la retirer.

vue

Click a day to add it, click it again to take it back

2026-06-05, 2026-06-12
<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const dates = ref<string[]>(['2026-06-05', '2026-06-12'])
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="dates"
      selection="multiple"
      label="Dates"
      hint="Click a day to add it, click it again to take it back"
      clearable
    />
    <output class="value" aria-label="Chosen dates">{{ dates.join(', ') || 'none' }}</output>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-3);
  max-inline-size: 26rem;
}
.value {
  font-family: var(--vectis-text-family-code);
  font-size: var(--vectis-text-body-sm-size);
  color: var(--vectis-color-text-muted);
}
</style>

Raccourcis

Ajoutez des dates prédéfinies dans footer. Son rappel close ferme le panneau.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VButton, VDateInput } from 'vectis-ui'

const date = ref<string | null>(null)

/* Read today's local date in the click handler to avoid a prerendered value. */
function inDays(offset: number, close: () => void) {
  const day = new Date()
  day.setDate(day.getDate() + offset)
  const month = String(day.getMonth() + 1).padStart(2, '0')
  date.value = `${day.getFullYear()}-${month}-${String(day.getDate()).padStart(2, '0')}`
  close()
}
</script>

<template>
  <div class="column">
    <VDateInput v-model="date" mode="picker" label="Due date" clearable>
      <template #footer="{ close }">
        <VButton variant="ghost" tone="neutral" size="sm" @click="inDays(0, close)">Today</VButton>
        <VButton variant="ghost" tone="neutral" size="sm" @click="inDays(1, close)">
          Tomorrow
        </VButton>
        <VButton variant="ghost" tone="neutral" size="sm" @click="inDays(7, close)">
          In a week
        </VButton>
      </template>
    </VDateInput>
  </div>
</template>

<style scoped>
.column {
  max-inline-size: 26rem;
}
</style>

Bornes et jours fermés

min et max limitent la sélection et la navigation. Excluez certaines dates avec disabledDates.

vue

Between 5 and 24 June 2026: the arrows stop at the bounds

Weekends are struck through: still reachable, never choosable

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const booking = ref<string | null>('2026-06-15')
const appointment = ref<string | null>('2026-06-16')

function isWeekend(iso: string) {
  const day = new Date(`${iso}T00:00:00`).getDay()
  return day === 0 || day === 6
}
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="booking"
      min="2026-06-05"
      max="2026-06-24"
      label="Booking"
      hint="Between 5 and 24 June 2026: the arrows stop at the bounds"
      show-picker
    />

    <VDateInput
      v-model="appointment"
      :disabled-dates="isWeekend"
      label="Appointment"
      hint="Weekends are struck through: still reachable, never choosable"
      show-picker
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Pastilles

events ajoute trois points au maximum par jour. Les libellés des événements font partie du nom accessible du jour.

vue

Open the calendar: June has four marked days

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput, type DatePickerEvent } from 'vectis-ui'

const date = ref<string | null>('2026-06-10')

const events: DatePickerEvent[] = [
  { date: '2026-06-10', label: 'Kick-off' },
  { date: '2026-06-18', color: 'var(--vectis-color-danger)', label: 'Deadline' },
  { date: '2026-06-18', color: 'var(--vectis-color-warning)', label: 'Review' },
  { date: '2026-06-24', color: 'var(--vectis-color-success)', label: 'Release' },
]
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="date"
      :events="events"
      mode="picker"
      label="Sprint date"
      hint="Open the calendar: June has four marked days"
    />
  </div>
</template>

<style scoped>
.column {
  max-inline-size: 26rem;
}
</style>

Cellules de jour personnalisées

Personnalisez le contenu des cellules avec day, à partir de leur date et de leur état de sélection.

vue

The slot replaces the day number, so what it draws follows the selection

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const night = ref<string | null>('2026-06-15')

/* Derive prices from dates so server and client render the same values. */
function priceFor(iso: string) {
  return 80 + ((Number(iso.slice(-2)) * 7) % 60)
}
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="night"
      mode="picker"
      min="2026-06-05"
      max="2026-06-24"
      label="Night"
      hint="The slot replaces the day number, so what it draws follows the selection"
    >
      <template #day="{ day, iso, inMonth, disabled }">
        <span class="number">{{ day }}</span>
        <small v-if="inMonth && !disabled" class="price">€{{ priceFor(iso) }}</small>
      </template>
    </VDateInput>
  </div>
</template>

<style scoped>
.column {
  max-inline-size: 26rem;
}
.number {
  line-height: 1;
}
/* Inherit the selected day's foreground colour to preserve contrast. */
.price {
  font-size: var(--vectis-text-caption-size);
  line-height: 1;
  color: color-mix(in oklab, currentcolor 65%, transparent);
}
</style>

Effacement

clearable ajoute un bouton pour effacer la sélection.

vue

The cross sits to the left of the calendar icon, never in its place

Emptying the field is then the reader's own business

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const withCross = ref<string | null>('2026-06-10')
const withoutCross = ref<string | null>('2026-06-10')
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="withCross"
      clearable
      show-picker
      label="Clearable"
      hint="The cross sits to the left of the calendar icon, never in its place"
    />

    <VDateInput
      v-model="withoutCross"
      show-picker
      label="Not clearable, the default"
      hint="Emptying the field is then the reader's own business"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Jours adjacents

showAdjacentDays affiche les jours voisins. selectAdjacentDays permet aussi de les choisir et ouvre leur mois.

vue

The grid starts and ends on the month itself

The corners are filled with the neighbouring months, greyed and inert

Choosing one moves the calendar to its month

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const hidden = ref<string | null>('2026-06-10')
const shown = ref<string | null>('2026-06-10')
const selectable = ref<string | null>('2026-06-10')
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="hidden"
      mode="picker"
      label="Hidden, the default"
      hint="The grid starts and ends on the month itself"
    />

    <VDateInput
      v-model="shown"
      show-adjacent-days
      mode="picker"
      label="Shown"
      hint="The corners are filled with the neighbouring months, greyed and inert"
    />

    <VDateInput
      v-model="selectable"
      select-adjacent-days
      mode="picker"
      label="Shown and choosable"
      hint="Choosing one moves the calendar to its month"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

États

readonly empêche la saisie, la sélection et l’effacement tout en conservant le focus. loading affiche un indicateur sans désactiver le champ.

vue

For a rule the browser cannot check by itself

Greyed through the colour tokens, and the panel can no longer be opened

No typing, no calendar, no clear cross

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const invalid = ref<string | null>('2026-06-10')
</script>

<template>
  <div class="column">
    <VDateInput
      v-model="invalid"
      invalid
      show-picker
      label="Invalid"
      hint="For a rule the browser cannot check by itself"
    />

    <VDateInput
      model-value="2026-06-10"
      disabled
      show-picker
      label="Disabled, with a value"
      hint="Greyed through the colour tokens, and the panel can no longer be opened"
    />

    <VDateInput model-value="2026-06-10" disabled mode="picker" label="Disabled, picker only" />

    <VDateInput
      model-value="2026-06-10"
      readonly
      show-picker
      clearable
      label="Read-only"
      hint="No typing, no calendar, no clear cross"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Localisation

locale définit les noms et l’ordre des éléments de date. displayFormat personnalise l’affichage en mode calendrier ; il ne modifie pas le masque de saisie.

vue

displayFormat is an Intl option bag, and it only applies where nothing is typed

<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const locales = ref([
  { tag: 'en-US', label: 'en-US, month first, weeks from Sunday', date: '2026-06-10' },
  { tag: 'en-GB', label: 'en-GB, day first, weeks from Monday', date: '2026-06-10' },
  { tag: 'de-DE', label: 'de-DE, dots for separators', date: '2026-06-10' },
  { tag: 'ja-JP', label: 'ja-JP, year first', date: '2026-06-10' },
])

const written = ref<string | null>('2026-06-10')
</script>

<template>
  <div class="column">
    <VDateInput
      v-for="locale in locales"
      :key="locale.tag"
      v-model="locale.date"
      :locale="locale.tag"
      :label="locale.label"
      show-picker
    />

    <VDateInput
      v-model="written"
      locale="fr-FR"
      mode="picker"
      :display-format="{ dateStyle: 'full' }"
      label="fr-FR, written out in full"
      hint="displayFormat is an Intl option bag, and it only applies where nothing is typed"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Placement

placement définit la position souhaitée du calendrier.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VDateInput } from 'vectis-ui'

const placements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'] as const

const dates = ref<Record<string, string | null>>({
  'bottom-start': '2026-06-10',
  'bottom-end': '2026-06-10',
  'top-start': '2026-06-10',
  'top-end': '2026-06-10',
})
</script>

<template>
  <div class="grid">
    <VDateInput
      v-for="placement in placements"
      :key="placement"
      v-model="dates[placement]"
      :placement="placement"
      :label="placement"
      mode="picker"
    />
  </div>
</template>

<style scoped>
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

API

Props

PropTypeDéfaut
selectionDatePickerSelection'single' | 'range' | 'multiple''single'
Mode de sélection : une date, une période ou plusieurs dates.
localestringaucune
Locale BCP 47 pour l’affichage des dates et le début de semaine. Remplace la locale globale.
firstDayOfWeeknumberaucune
Premier jour de la semaine, de 0 (dimanche) à 6 (samedi). Dépend de la locale par défaut.
minstringaucune
Première date sélectionnable au format YYYY-MM-DD. Limite aussi la navigation.
maxstringaucune
Dernière date sélectionnable au format YYYY-MM-DD. Limite aussi la navigation.
disabledDatesDatePickerMatcheraucune
Dates indisponibles : tableau de chaînes ISO ou prédicat. Les jours restent visibles et accessibles au clavier.
showAdjacentDaysbooleanfalse
Affiche les jours des mois voisins.
selectAdjacentDaysbooleanfalse
Permet de sélectionner les jours des mois voisins et ouvre le mois choisi. Implique showAdjacentDays.
eventsDatePickerEvent[]aucune
Événements représentés par trois points au maximum par jour. Chacun accepte une date, une couleur CSS et un libellé accessible.
modeDateInputMode'picker' | 'input''input'
input pour la saisie, picker pour le calendrier. Les périodes et dates multiples imposent le mode calendrier.
showPickerbooleanfalse
Ajoute un calendrier au mode saisie. Le mode calendrier l’inclut toujours.
labelstringaucune
Libellé visible. Sans nom visible, fournissez aria-label ou aria-labelledby.
hintstringaucune
Texte d’aide lié par aria-describedby.
errorstringaucune
Message d’erreur affiché à la place de l’aide. Pose aria-invalid, est lié par aria-describedby et est annoncé quand il apparaît.
requiredbooleanfalse
Ajoute un astérisque après le libellé et transmet required au champ.
hideLabelbooleanfalse
Masque le libellé visuellement tout en le gardant comme nom accessible.
labelPositionFieldLabelPosition'top' | 'start''top'
Place le libellé au-dessus du champ ou à côté.
placeholderstringaucune
Texte indicatif lorsque le champ est vide.
sizeDateInputSize'sm' | 'md' | 'lg''md'
Taille du composant.
disabledbooleanfalse
Désactive les interactions.
readonlybooleanfalse
Empêche la saisie, la sélection et l’effacement. Le champ conserve le focus.
invalidbooleanfalse
Définit aria-invalid et le style d’erreur. Ne bloque pas à lui seul l’envoi du formulaire.
iconStartIconSourceaucune
Icône de début. Un écouteur @click:icon-start en fait un bouton ; fournissez iconStartLabel.
iconStartLabelstringaucune
Nom accessible du bouton d’icône de début.
pickerLabelstringaucune
Nom accessible du bouton calendrier. Utilise le dictionnaire de la bibliothèque par défaut.
loadingbooleanfalse
Remplace l’icône calendrier par un indicateur. Ne désactive ni la saisie ni le panneau.
loadingTextstringaucune
Texte de chargement et nom accessible de l’indicateur. Utilise le dictionnaire de la bibliothèque par défaut.
clearablebooleanfalse
Ajoute un bouton pour effacer la sélection.
clearLabelstringaucune
Nom accessible du bouton d’effacement. Utilise le dictionnaire de la bibliothèque par défaut.
pickerIconIconSourcecalendar_today
Icône du bouton calendrier, affichée si un panneau est disponible.
displayFormatIntl.DateTimeFormatOptions{ day: 'numeric', month: 'short', year: 'numeric' }
Options d’affichage en mode calendrier. Ne modifie pas le masque de saisie numérique.
placementDateInputPlacement'bottom' | 'bottom-start' | 'bottom-end' | 'top' | 'top-start' | 'top-end''bottom-start'
Position souhaitée du panneau par rapport au champ.
v-modelDatePickerValuenull
Date ISO ou null, période { start, end } ou tableau de dates ISO. La saisie ne modifie le modèle que si elle est complète et autorisée ; les autres valeurs sont annulées à la perte du focus.

Événements

ÉvénementType
click:icon-start[event: MouseEvent]
Le bouton de l’icône de début a été activé.
clear[]
La sélection a été effacée ; le modèle est déjà réinitialisé.

Slots

SlotType
start{}
Contenu après iconStart.
value-end{}
Contenu avant les boutons d’effacement et de calendrier.
dayDatePickerDaySlotProps
Contenu d’une cellule. Reçoit les données du slot de jour de VDatePicker.
footerDateInputFooterSlotProps
Pied du panneau. Reçoit close pour le fermer.

Types

Types utilisés dans les tables d’API. Importez les types exportés depuis vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export interface DateInputFooterSlotProps {
  close: () => void
}
export interface DatePickerDaySlotProps {
  iso: string
  day: number
  inMonth: boolean
  disabled: boolean
  selected: boolean
  today: boolean
  inRange: boolean
  events: DatePickerEvent[]
}
export interface DatePickerEvent {
  date: string
  color?: string
  label?: string
}
export type DatePickerMatcher = string[] | ((iso: string) => boolean)
export interface DatePickerRange {
  start: string | null
  end: string | null
}
export type DatePickerValue = string | null | DatePickerRange | string[]
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender