Calendar
| S | M | T | W | T | F | S | 
|---|---|---|---|---|---|---|
29  | 30  | 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  | 31  | 1  | 2  | 
3  | 4  | 5  | 6  | 7  | 8  | 9  | 
Features
- Full keyboard navigation
 - Can be controlled or uncontrolled
 - Focus is fully managed
 - Localization support
 - Highly composable
 
Preface
The component depends on the @internationalized/date package, which solves a lot of the problems that come with working with dates and times in JavaScript.
We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components.
Installation
Install the date package.
$ npm add @internationalized/dateInstall the component from your command line.
$ npm add reka-uiAnatomy
Import all parts and piece them together.
<script setup>
import {
  CalendarCell,
  CalendarCellTrigger,
  CalendarGrid,
  CalendarGridBody,
  CalendarGridHead,
  CalendarGridRow,
  CalendarHeadCell,
  CalendarHeader,
  CalendarHeading,
  CalendarNext,
  CalendarPrev,
  CalendarRoot
} from 'reka-ui'
</script>
<template>
  <CalendarRoot>
    <CalendarHeader>
      <CalendarPrev />
      <CalendarHeading />
      <CalendarNext />
    </CalendarHeader>
    <CalendarGrid>
      <CalendarGridHead>
        <CalendarGridRow>
          <CalendarHeadCell />
        </CalendarGridRow>
      </CalendarGridHead>
      <CalendarGridBody>
        <CalendarGridRow>
          <CalendarCell>
            <CalendarCellTrigger />
          </CalendarCell>
        </CalendarGridRow>
      </CalendarGridBody>
    </CalendarGrid>
  </CalendarRoot>
</template>API Reference
Root
Contains all the parts of a calendar
| Slots (default) | Payload | 
|---|---|
date | DateValueThe current date of the placeholder  | 
grid | Grid<DateValue>[]The grid of dates  | 
weekDays | string[]The days of the week  | 
weekStartsOn | 0 | 1 | 2 | 3 | 4 | 5 | 6The start of the week  | 
locale | stringThe calendar locale  | 
fixedWeeks | booleanWhether or not to always display 6 weeks in the calendar  | 
modelValue | CalendarDate | CalendarDateTime | ZonedDateTimeThe current date of the calendar  | 
| Data Attribute | Value | 
|---|---|
[data-readonly] | Present when readonly | 
[data-disabled] | Present when disabled | 
[data-invalid] | Present when invalid | 
Header
Contains the navigation buttons and the heading segments.
| Prop | Default | Type | 
|---|---|---|
as | 'div' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
Prev Button
Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view.
| Prop | Default | Type | 
|---|---|---|
as | 'button' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | |
prevPage | ((placeholder: DateValue) => DateValue)The function to be used for the prev page. Overwrites the   | 
| Data Attribute | Value | 
|---|---|
[data-disabled] | Present when disabled | 
Next Button
Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view.
| Prop | Default | Type | 
|---|---|---|
as | 'button' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | |
nextPage | ((placeholder: DateValue) => DateValue)The function to be used for the next page. Overwrites the   | 
| Data Attribute | Value | 
|---|---|
[data-disabled] | Present when disabled | 
Heading
Heading for displaying the current month and year
| Prop | Default | Type | 
|---|---|---|
as | 'div' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
| Slots (default) | Payload | 
|---|---|
headingValue | stringCurrent month and year  | 
| Data Attribute | Value | 
|---|---|
[data-disabled] | Present when disabled | 
Grid
Container for wrapping the calendar grid.
| Prop | Default | Type | 
|---|---|---|
as | 'table' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
| Data Attribute | Value | 
|---|---|
[data-readonly] | Present when readonly | 
[data-disabled] | Present when disabled | 
Grid Head
Container for wrapping the grid head.
| Prop | Default | Type | 
|---|---|---|
as | 'thead' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
Grid Body
Container for wrapping the grid body.
| Prop | Default | Type | 
|---|---|---|
as | 'tbody' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
Grid Row
Container for wrapping the grid row.
| Prop | Default | Type | 
|---|---|---|
as | 'tr' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
Head Cell
Container for wrapping the head cell. Used for displaying the week days.
| Prop | Default | Type | 
|---|---|---|
as | 'th' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | 
Cell
Container for wrapping the calendar cells.
| Prop | Default | Type | 
|---|---|---|
as | 'td' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | |
date* | DateValueThe date value for the cell  | 
| Data Attribute | Value | 
|---|---|
[data-disabled] | Present when disabled | 
Cell Trigger
Interactable container for displaying the cell dates. Clicking it selects the date.
| Prop | Default | Type | 
|---|---|---|
as | 'div' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by   | 
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details.  | |
day* | DateValueThe date value provided to the cell trigger  | |
month* | DateValueThe month in which the cell is rendered  | 
| Slots (default) | Payload | 
|---|---|
dayValue | stringCurrent day  | 
| Data Attribute | Value | 
|---|---|
[data-selected] | Present when selected | 
[data-value] | The ISO string value of the date. | 
[data-disabled] | Present when disabled | 
[data-unavailable] | Present when unavailable | 
[data-today] | Present when today | 
[data-outside-view] | Present when the date is outside the current month it is displayed in. | 
[data-outside-visible-view] | Present when the date is outside the months that are visible on the calendar. | 
[data-focused] | Present when focused | 
Examples
Calendar with Year Incrementation
This example showcases a calendar which allows incrementing the year.
| S | M | T | W | T | F | S | 
|---|---|---|---|---|---|---|
29  | 30  | 31  | 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  | 31  | 1  | 
2  | 3  | 4  | 5  | 6  | 7  | 8  | 
Calendar with Locale and Calendar System Selection
This example showcases some of the available locales and how the calendar systems are displayed.
| S | M | T | W | T | F | S | 
|---|---|---|---|---|---|---|
29  | 30  | 31  | 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  | 31  | 1  | 
2  | 3  | 4  | 5  | 6  | 7  | 8  | 
Accessibility
Keyboard Interactions
| Key | Description | 
|---|---|
Tab  | When focus moves onto the calendar, focuses the first navigation button.  | 
Space  | 
      
          When the focus is on either  CalendarNext or CalendarPrev, it navigates the calendar. Otherwise, it selects the date.
      
     | 
Enter  | 
      
          When the focus is on either  CalendarNext or CalendarPrev, it navigates the calendar. Otherwise, it selects the date.
      
     | 
ArrowLeftArrowRightArrowUpArrowDown  | 
        When the focus is on  CalendarCellTrigger, it navigates the dates, changing the month/year/decade if necessary.
       | 
