Skip to content

GhostCalendar ​

GhostCalendar implements a locale-aware month grid for single-date or range selection, following the WAI-ARIA APG date-picker dialog grid keyboard model. Import the compound parts from @ghostvue/themes for default surfaces. The themed parts add styling only: selection, keyboard navigation, and labels come from the headless parts in @ghostvue/vue. To style the grid yourself, see Advanced: headless composition.

Values are CalendarDate objects from @internationalized/date (shipped as a runtime dependency of @ghostvue/vue and re-exported by both packages). Use date.toString() for ISO YYYY-MM-DD strings and parseDate(iso) when reading user input.

Pick a release date ​

Themed

Styled calendar from @ghostvue/themes.

Release window

June 2024

SunMonTueWedThuFriSat
Selected date: 2024-06-18

The themed GhostCalendar renders a .ghost-themed-scope container (consumer class and style land on it), so the recipe styles every part without a page-level .ghost-theme. Week rows and the weekday header share seven equal-width columns; leading and trailing days from adjacent months fill the first and last weeks in a muted color. Today, selected, range, hover, focus-visible, unavailable (struck through), and outside-month dates each have a distinct style, including in forced colors. Day cells and navigation buttons are squares one small control tall (control.size.sm.min: 28, 32, or 36px by density) and grow to 44px on coarse pointers. In a container wider than the month, the columns share the spare width and each day stays centered in its column.

Themed GhostCalendarPrevButton and GhostCalendarNextButton render a decorative chevron by default and keep their accessible names (Previous month, Next month); pass slot content to replace the icon. The example groups a Today button with the navigation inside GhostCalendarHeader and binds v-model:visible-month so the button can bring June back into view. Pass today when you need deterministic “today” styling in SSR, tests, or snapshots. The today cell also carries aria-current="date". When today is omitted, no implicit runtime clock is used during render.

Range selection ​

Studio availability

Themed range booking with booked days, a pending-end hint, and a conflict check.

Book Studio B

Struck-through days are booked or already past.

June 2024

SunMonTueWedThuFriSat

Set selection-mode="range" and bind v-model to { start, end } (inclusive). The first activation starts a range, the second completes it, and a third starts a new one. Activating a day before the start completes the range in that order. The calendar treats a one-day value as an open start, so the next activation after a one-day range extends it; the studio example replaces that proposal to start a new booking instead.

The studio example combines the range with business rules. min-value keeps past days out of reach, and is-date-disabled marks booked days as unavailable: they are struck through and cannot be activated, though arrow keys still move focus across them. A range can still span a booked day, so the example checks the completed range for overlap before enabling Request booking. Use max-value to cap how far ahead people can book.

Activation events and controlled empty ​

GhostCalendar emits select with the activated CalendarDate once for every accepted activation, after update:modelValue. It also fires when the date is already selected, so a wrapper can tell the first range click from a completed one-day range (both propose { start: day, end: day }). The studio example reads each activation this way to show “Choose the last day” while a range is open. Disabled, unavailable, and outside-month dates emit nothing. useGhostCalendar exposes the same hook as onSelect.

Bind :model-value="null" to keep the calendar controlled while empty. undefined (or omitting the prop) still means uncontrolled. While the value is null, defaultValue is ignored, slots report modelValue as undefined, and update:modelValue proposals change nothing until the parent applies them. Resetting the bound value to null clears a pending range start, which is how Clear dates works in the studio example.

vue
<GhostCalendar
  :model-value="display"
  selection-mode="range"
  @select="onActivate"
>
  <GhostCalendarGrid />
</GhostCalendar>

Locale ​

Office locale

Themed calendar that switches locale and week start per office while the selected date stays the same.

Quarterly review

June 2024

MonTueWedThuFriSatSun
London
Friday, 14 June 2024
Saved as
2024-06-14

locale drives the Intl labels for the month heading, weekday header, and day names, and the first day of the week (Sunday for en-US, Monday for en-GB). Browsers that do not report a locale's week start fall back to Sunday, so set week-starts-on (0 = Sunday) when the layout must match a region everywhere. The example does this for each office.

The calendar does not translate your own copy. In a translated app, pass localized aria-label values to GhostCalendarPrevButton and GhostCalendarNextButton, and set lang on an element around the calendar so screen readers pronounce the localized names. The selected CalendarDate carries no locale: switching offices relabels the grid, but the selected day and its ISO string stay the same.

Custom day cells ​

Release deadlines

Themed #cell slot that keeps the day number and marks days with a deadline.

Release deadlines

A dot marks a day with a deadline.

June 2024

SunMonTueWedThuFriSat

Fri, Jun 14: Copy freeze, Beta build.

Pass a #cell template to GhostCalendarGrid to change what each day shows. The template replaces the cell's content only: the cell keeps its gridcell role, state attributes, keyboard behavior, and accessible name. Render date.day yourself when you still want the day number, then add markers next to or under it.

vue
<GhostCalendarGrid>
  <template #cell="{ date }">
    {{ date.day }}
    <span v-if="hasDeadline(date)" class="marker" aria-hidden="true" />
  </template>
</GhostCalendarGrid>

The accessibleLabel slot prop is the full localized date, such as “Saturday, June 15, 2024”, that the cell already uses as its aria-label. It is not the visible day, and the cell applies it for you; use it only to repeat the name elsewhere, such as in a tooltip. Because that label names the cell, a screen reader does not announce text inside the template. Keep markers aria-hidden and write the information they stand for somewhere readable, as the example does in its status line. The older formattedDate slot prop is a deprecated alias of accessibleLabel: it is still passed, and it will not be removed before 1.0. See the slot tables for every slot prop.

Advanced: headless composition ​

The examples in this section are headless: they import the parts from @ghostvue/vue, which ships behavior only. Each one brings the same small block of consumer CSS, shown in its source, that lays out the month grid and styles the today, selected, range, unavailable, and outside-month states through the parts' data-part and data-state attributes. Copy that block once per app when you write your own calendar styles.

Basic use ​

Basic Headless

Single-date month grid with keyboard and pointer selection.

June 2024

SunMonTueWedThuFriSat

Headless range ​

Range Headless

Inclusive range selection across a month grid.

June 2024

SunMonTueWedThuFriSat

Controlled month ​

Controlled Headless

Controlled month with min, max, and unavailable dates.

January 2024

SunMonTueWedThuFriSat

v-model:visible-month controls which month is displayed. Combine with min-value / max-value and is-date-disabled for business rules.

Headless locale ​

Locale Headless

Monday week start with the en-GB locale.

June 2024

MonTueWedThuFriSatSun

API ​

See the specification. Generated manifest data lives under packages/vue/manifests/ghost-calendar.manifest.json and themed packages/themes/manifests/ghost-calendar.manifest.json.

PropTypeDefaultDescription
defaultValueGhostCalendarValue—Declared prop defaultValue.
defaultVisibleMonthCalendarDate—Declared prop defaultVisibleMonth.
disabledbooleanfalseDeclared prop disabled.
isDateDisabled((date: CalendarDate) => boolean)—Declared prop isDateDisabled.
localestring"en-US"Declared prop locale.
maxValueCalendarDate—Declared prop maxValue.
minValueCalendarDate—Declared prop minValue.
modelValueGhostCalendarValue | null—Declared prop modelValue.
selectionModeGhostCalendarSelectionMode"single"Declared prop selectionMode.
todayCalendarDate—Declared prop today.
visibleMonthCalendarDate—Declared prop visibleMonth.
weekStartsOnnumber—Declared prop weekStartsOn.
EventPayloadDescription
selectCalendarDateEmitted as select.
SlotSlot propsDescription
defaultmodelValue: GhostCalendarValue, selectionMode: GhostCalendarSelectionMode, visibleMonth: CalendarDateContainer content.

@ghostvue/themes adds no props, events, or slots to the headless GhostCalendar API, which it forwards.

GhostCalendarGrid ​

PropTypeDefaultDescription
asGhostCalendarGridElement"div"Declared prop as.
SlotSlot propsDescription
cellaccessibleLabel: string, date: CalendarDate, disabled: boolean, focused: boolean, formattedDate: string, outsideMonth: boolean, selected: boolean, state: GhostCalendarCellState, today: booleanReplaces the content of every day cell; the cell keeps its role, state attributes, and accessible name. Without it, the cell shows date.day. Props: date is the day (render date.day for the number); accessibleLabel is the full localized date already used as the cell's aria-label, not the visible day; disabled, selected, focused, today, and outsideMonth report the cell's state, and state is its data-state value. formattedDate is a deprecated alias of accessibleLabel.
default—Primary content.

GhostCalendarCell ​

PropTypeDefaultDescription
asGhostCalendarCellElement"button"Declared prop as.
dateCalendarDateRequiredDeclared prop date.
SlotSlot propsDescription
defaultaccessibleLabel: string, date: CalendarDate, disabled: boolean, focused: boolean, formattedDate: string, outsideMonth: boolean, selected: boolean, state: GhostCalendarCellState, today: booleanContent of this day cell; the cell keeps its role, state attributes, and accessible name. Without it, the cell shows date.day. Props: date is the day (render date.day for the number); accessibleLabel is the full localized date already used as the cell's aria-label, not the visible day; disabled, selected, focused, today, and outsideMonth report the cell's state, and state is its data-state value. formattedDate is a deprecated alias of accessibleLabel.

Parts ​

PartRoleKey attributes
GhostCalendar—v-model, selectionMode, locale
GhostCalendarGridgridaria-labelledby, keyboard navigation
GhostCalendarCellgridcelldate, aria-selected, data-state
GhostCalendarPrevButtonbuttonPrevious month
GhostCalendarNextButtonbuttonNext month

Accessibility ​

Keyboard support on the grid includes arrow keys (day/week), Home/End (week boundaries), Page Up/Down (month), and Shift+Page Up/Down (year). The focused date uses roving tabindex. See the calendar specification.