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
Styled calendar from @ghostvue/themes.
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
Themed range booking with booked days, a pending-end hint, and a conflict check.
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.
<GhostCalendar
:model-value="display"
selection-mode="range"
@select="onActivate"
>
<GhostCalendarGrid />
</GhostCalendar>Locale
Themed calendar that switches locale and week start per office while the selected date stays the same.
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
Themed #cell slot that keeps the day number and marks days with a deadline.
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.
<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
Single-date month grid with keyboard and pointer selection.
Headless range
Inclusive range selection across a month grid.
Controlled month
Controlled month with min, max, and unavailable dates.
v-model:visible-month controls which month is displayed. Combine with min-value / max-value and is-date-disabled for business rules.
Headless locale
Monday week start with the en-GB locale.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | GhostCalendarValue | — | Declared prop defaultValue. |
defaultVisibleMonth | CalendarDate | — | Declared prop defaultVisibleMonth. |
disabled | boolean | false | Declared prop disabled. |
isDateDisabled | ((date: CalendarDate) => boolean) | — | Declared prop isDateDisabled. |
locale | string | "en-US" | Declared prop locale. |
maxValue | CalendarDate | — | Declared prop maxValue. |
minValue | CalendarDate | — | Declared prop minValue. |
modelValue | GhostCalendarValue | null | — | Declared prop modelValue. |
selectionMode | GhostCalendarSelectionMode | "single" | Declared prop selectionMode. |
today | CalendarDate | — | Declared prop today. |
visibleMonth | CalendarDate | — | Declared prop visibleMonth. |
weekStartsOn | number | — | Declared prop weekStartsOn. |
| Event | Payload | Description |
|---|---|---|
select | CalendarDate | Emitted as select. |
| Slot | Slot props | Description |
|---|---|---|
default | modelValue: GhostCalendarValue, selectionMode: GhostCalendarSelectionMode, visibleMonth: CalendarDate | Container content. |
@ghostvue/themes adds no props, events, or slots to the headless GhostCalendar API, which it forwards.
GhostCalendarGrid
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostCalendarGridElement | "div" | Declared prop as. |
| Slot | Slot props | Description |
|---|---|---|
cell | accessibleLabel: string, date: CalendarDate, disabled: boolean, focused: boolean, formattedDate: string, outsideMonth: boolean, selected: boolean, state: GhostCalendarCellState, today: boolean | Replaces 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
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostCalendarCellElement | "button" | Declared prop as. |
date | CalendarDate | Required | Declared prop date. |
| Slot | Slot props | Description |
|---|---|---|
default | accessibleLabel: string, date: CalendarDate, disabled: boolean, focused: boolean, formattedDate: string, outsideMonth: boolean, selected: boolean, state: GhostCalendarCellState, today: boolean | Content 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
| Part | Role | Key attributes |
|---|---|---|
GhostCalendar | — | v-model, selectionMode, locale |
GhostCalendarGrid | grid | aria-labelledby, keyboard navigation |
GhostCalendarCell | gridcell | date, aria-selected, data-state |
GhostCalendarPrevButton | button | Previous month |
GhostCalendarNextButton | button | Next 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.