R

Calendar

12 parts

Anatomy

Import the parts and compose them. Each part forwards attributes to its underlying element.

vue
import {
  CalendarRoot,
  CalendarHeader,
  CalendarHeading,
  CalendarPrev,
  CalendarNext,
  CalendarGrid,
  CalendarGridHead,
  CalendarGridBody,
  CalendarGridRow,
  CalendarHeadCell,
  CalendarCell,
  CalendarCellTrigger,
} from '@robonen/primitives/calendar';

<CalendarRoot>
  <CalendarHeader />
  <CalendarHeading />
  <CalendarPrev />
  <CalendarNext />
  <CalendarGrid />
  <CalendarGridHead />
  <CalendarGridBody />
  <CalendarGridRow />
  <CalendarHeadCell />
  <CalendarCell />
  <CalendarCellTrigger />
</CalendarRoot>

API Reference

CalendarRoot

Root
PropTypeDescription
defaultValue?DateUncontrolled default selected date.
defaultPlaceholder?DateUncontrolled default placeholder (displayed month).
minValue?DateMinimum selectable date.
maxValue?DateMaximum selectable date.
isDateUnavailable?(date: Date) => booleanPredicate marking a date as unavailable (not selectable).
isDateDisabled?(date: Date) => booleanPredicate marking a date as disabled.
pagedNavigation?booleanPrev/Next navigate by `numberOfMonths` instead of one month.
weekStartsOn?0 | 1 | 2 | 3 | 4 | 5 | 6First day of week (0=Sun ... 6=Sat).
weekdayFormat?WeekDayFormatWidth of localized weekday names.
fixedWeeks?booleanAlways render 6 weeks per month.
numberOfMonths?numberNumber of months displayed simultaneously.
disabled?booleanDisable the whole calendar.
readonly?booleanMake the calendar read-only.
initialFocus?booleanAuto-focus the calendar on mount.
locale?stringLocale for `Intl` formatting.
dir?'ltr' | 'rtl'Reading direction.
nextPage?(placeholder: Date) => DateOverride "next page" navigation logic.
prevPage?(placeholder: Date) => DateOverride "prev page" navigation logic.
calendarLabel?stringCalendar accessible label prefix.

CalendarHeader

Header

No props or events — renders its element and forwards attributes.

CalendarHeading

Heading

No props or events — renders its element and forwards attributes.

CalendarPrev

Prev
PropTypeDescription
prevPage?(placeholder: Date) => DateOverride the root's `prevPage` for just this button.

CalendarNext

Next
PropTypeDescription
nextPage?(placeholder: Date) => DateOverride the root's `nextPage` for just this button.

CalendarGrid

Grid
PropTypeDescription
month?DateThe month this grid represents. Defaults to the root placeholder's month.

CalendarGridHead

GridHead

No props or events — renders its element and forwards attributes.

CalendarGridBody

GridBody

No props or events — renders its element and forwards attributes.

CalendarGridRow

GridRow

No props or events — renders its element and forwards attributes.

CalendarHeadCell

HeadCell
PropTypeDescription
day?DateThe day this header cell represents — used for `aria-label`.

CalendarCell

Cell
PropTypeDescription
dateDateThe date this cell represents.

CalendarCellTrigger

CellTrigger
PropTypeDescription
dayDateThe day this trigger represents.
month?DateThe month this trigger's cell belongs to. Defaults to grid context.