Forms & inputs
Layout
Calendar
A month grid for picking a single date or a date range. Use it when the calendar should stay on the page.
Install
import { Calendar } from 'vael-ui'Playground
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
single
date
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Calendar } from 'vael-ui'
import type { CalendarRange } from 'vael-ui'
const value = ref<Date | CalendarRange | null>(null)
</script>
<template>
<Calendar locale="en-US" v-model="value" />
</template>Motion New
How Calendar's label and grid change months. Give each part's look as values, or as a function of where: its direction is 1 going forward and -1 going back.
<Calendar
:motion="{ initial: { label: { opacity: 0, y: 4 } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | labelgrid | 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. |
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 Grid pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowLeftArrowRight | Moves focus one day back or forward. |
| ArrowUpArrowDown | Moves focus one week back or forward. |
| HomeEnd | Moves focus to the first or last day of the week. |
| PageUpPageDown | Moves focus one month back or forward. |
| ShiftPageUpShiftPageDown | Moves focus one year back or forward. |
| EnterSpace | Selects the focused day. |
| ArrowLeftArrowRightArrowUpArrowDown | Moves focus one cell or one row in the month and year views. |
| HomeEnd | Moves focus to the first or last cell in the row, in the month and year views. |
| PageUpPageDown | Moves focus a year back or forward in the month view, or 12 years in the year view. |
| EnterSpace | Picks the focused month or year, and moves focus into the next view. |
- Each month is a
role="grid"named by its month and year. Days aregridcells with the full date asaria-label, plusaria-selected,aria-current="date"for today andaria-disabled. WithshowWeekNumbers, each row starts with arowheader, such as “Week 12”. - One cell is in the tab order at a time (roving tabindex). Moving past the shown month pages the calendar. In a range, every day from the start to the end has
aria-selected. - The previous and next buttons use
aria-disabledatminDateandmaxDate, so they keep focus. The month label is anaria-live="polite"button, so paging announces the new month. - With a
#dayslot, the full date is read from visually hidden text before your content. Right to left, ArrowLeft and ArrowRight swap.