Forms & inputs
Layout
DatePicker
A text field with a calendar popover for picking a date, a range or a time. Use it in forms where people type or pick a date.
Validating a form? vael-form wires this up with a schemaInstall
import { DatePicker } from 'vael-ui'Playground
single
date
undefined
undefined
Placement, behaviour and animation
bottom
start
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { DatePicker } from 'vael-ui'
import type { CalendarRange } from 'vael-ui'
const value = ref<Date | CalendarRange | null>(null)
const open = ref(false)
</script>
<template>
<DatePicker
placeholder="Choose an option"
locale="en-US"
v-model="value"
v-model:open="open"
/>
</template>Motion New
DatePicker's panel: values or hooks for its parts, like Popover's. valueSwap: false shows a picked date without its crossfade.
<DatePicker
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | positionerpanel | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Combobox pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| A letterA digitSpace | Types a date into the input. |
| ArrowDown | Opens the calendar and focuses the selected day, or today. |
| Enter | Commits the typed date, or opens or closes the calendar when nothing was typed. |
| Escape | Closes the calendar, or else undoes what you typed in the input. |
| ArrowLeftArrowRightArrowUpArrowDown | Moves focus by a day or a week in the calendar. |
| HomeEndPageUpPageDown | Moves focus by week edge or month in the calendar, as in Calendar. |
| EnterSpace | Selects the focused day and closes the calendar. |
| ArrowUpArrowDown | Steps the focused hour or minute field. |
| HomeEnd | Sets the focused hour or minute field to its lowest or highest value. |
| Enter | Closes the calendar from the hour or minute field. |
- The input has
role="combobox",aria-haspopup="dialog",aria-expandedandaria-controls. It reads typed dates in the locale’s order, or asyyyy-mm-dd. Enter or leaving the field commits; an entry that doesn’t read keeps the last value and setsaria-invalid. - It opens on click, ArrowDown, Enter or the calendar button, not on focus. A click keeps focus in the input for typing; the keys and the button move it to the calendar, and closing returns it to the input. The button is named “Choose date” and is out of the tab order.
- The panel is a non-modal
role="dialog"named “Choose date” (thedatePicker.chooseDatemessage). A range stays open until both ends are set, andshowTimestays open for the time. The hour and minute fields arerole="spinbutton"inputs. - Inside a
Field, the label names the input anderrorsetsaria-invalid. Without one, passaria-label. Right to left, ArrowLeft and ArrowRight swap in the calendar.