GhostCalendar reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed wrappers around the headless GhostCalendar parts. The root adds a .ghost-themed-scope container, and importing from @ghostvue/themes loads the default month-grid stylesheet.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
None declared.
Emits
None declared.
Models
None declared.
Slots
| Name | Description |
|---|---|
default | Container content. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
element | HTMLElement | null | Root element after mount; null before mount. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | Neutral content container. |
CSS variables
| Name | Description |
|---|---|
--ghost-surface-fg | Inherited text color. |
Accessibility
Role: generic. APG pattern: https://www.w3.org/WAI/ARIA/apg/.
Required ARIA attributes: none.
Keyboard
None declared.
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Not reviewed | No declared key is mapped to a browser test yet. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
calendar/themed
Styled calendar from @ghostvue/themes.
<script setup lang="ts">
import { CalendarDate, type DateValue } from '@ghostvue/themes'
import { computed, shallowRef } from 'vue'
import {
GhostButton,
GhostCalendar,
GhostCalendarGrid,
GhostCalendarHeader,
GhostCalendarHeading,
GhostCalendarNextButton,
GhostCalendarPrevButton,
GhostCard,
} from '@ghostvue/themes'
const today = new CalendarDate(2024, 6, 18)
const selected = shallowRef<DateValue>(today)
const visibleMonth = shallowRef<CalendarDate>(new CalendarDate(2024, 6, 1))
const formattedSelected = computed(() => selected.value.toString())
function resetToToday(): void {
selected.value = today
visibleMonth.value = new CalendarDate(2024, 6, 1)
}
</script>
<template>
<GhostCard class="release-calendar">
<template #header>
<span class="release-calendar__title">Release window</span>
</template>
<GhostCalendar
v-model="selected"
v-model:visible-month="visibleMonth"
:today="today"
>
<!--
Today sits in the navigation group with the chevron buttons, so the
month title, jump-to-today, and previous/next read as one toolbar row.
-->
<GhostCalendarHeader class="release-calendar__nav">
<GhostCalendarHeading />
<GhostButton
variant="outline"
tone="neutral"
size="sm"
@click="resetToToday"
>
Today
</GhostButton>
<GhostCalendarPrevButton />
<GhostCalendarNextButton />
</GhostCalendarHeader>
<GhostCalendarGrid />
</GhostCalendar>
<template #footer>
<div class="release-calendar__status" role="status" aria-live="polite">
Selected date: {{ formattedSelected }}
</div>
</template>
</GhostCard>
</template>
<style scoped>
.release-calendar {
inline-size: 100%;
max-inline-size: 22rem;
}
.release-calendar__title {
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
}
.release-calendar__nav :deep(.ghost-calendar-heading) {
text-align: start;
}
.release-calendar__status {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-xs);
font-variant-numeric: tabular-nums;
}
</style>
calendar/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
Mon, Jun 17 – Thu, Jun 20 · 4 days
<script setup lang="ts">
import { computed, shallowRef } from 'vue'
import {
CalendarDate,
GhostButton,
GhostCalendar,
GhostCalendarGrid,
GhostCalendarHeader,
GhostCalendarHeading,
GhostCalendarNextButton,
GhostCalendarPrevButton,
GhostCard,
} from '@ghostvue/themes'
/** Range mode proposes inclusive `{ start, end }` values. */
interface BookingRange {
start: CalendarDate
end: CalendarDate
}
// A fixed "today" keeps the demo, its tests, and its screenshots stable.
const today = new CalendarDate(2024, 6, 3)
const visibleMonth = new CalendarDate(2024, 6, 1)
// Days another team already holds. They render struck through and cannot be
// picked, but a range may still be dragged across them, so the summary
// checks for overlap before the request can be sent.
const booked = [
new CalendarDate(2024, 6, 12),
new CalendarDate(2024, 6, 13),
new CalendarDate(2024, 6, 24),
new CalendarDate(2024, 6, 25),
new CalendarDate(2024, 6, 26),
]
function isBooked(date: CalendarDate): boolean {
return booked.some((day) => day.compare(date) === 0)
}
const range = shallowRef<BookingRange | null>({
start: new CalendarDate(2024, 6, 17),
end: new CalendarDate(2024, 6, 20),
})
/*
* The calendar treats any one-day value as an open start, so after a
* finished one-day booking its next proposal would extend that day instead
* of starting a new booking. The example tracks the open start itself:
* `select` fires after `update:modelValue` for every accepted click, so a
* click with no open start replaces the proposal with a fresh one-day start,
* and the next click completes it (the same day twice is a one-day booking).
*/
const awaitingEnd = shallowRef(false)
function onSelect(date: CalendarDate): void {
if (awaitingEnd.value) {
awaitingEnd.value = false
return
}
range.value = { start: date, end: date }
awaitingEnd.value = true
}
function clear(): void {
// `null` keeps the calendar controlled while empty and drops a pending start.
range.value = null
awaitingEnd.value = false
}
const dayFormat = new Intl.DateTimeFormat('en-US', {
weekday: 'short',
month: 'short',
day: 'numeric',
timeZone: 'UTC',
})
function formatDay(date: CalendarDate): string {
return dayFormat.format(date.toDate('UTC'))
}
const conflict = computed(() => {
const value = range.value
if (!value || awaitingEnd.value) return false
return booked.some(
(day) => day.compare(value.start) >= 0 && day.compare(value.end) <= 0,
)
})
const summary = computed(() => {
const value = range.value
if (!value) return 'Choose the first day of your booking.'
if (awaitingEnd.value) {
return `Starts ${formatDay(value.start)}. Choose the last day.`
}
if (conflict.value) {
return 'This range includes booked days. Choose dates without a strikethrough.'
}
// `end` is inclusive, so a one-day booking still counts as one day.
const days = value.end.compare(value.start) + 1
const dates =
days === 1
? formatDay(value.start)
: `${formatDay(value.start)} – ${formatDay(value.end)}`
return `${dates} · ${String(days)} ${days === 1 ? 'day' : 'days'}`
})
const canRequest = computed(
() => range.value !== null && !awaitingEnd.value && !conflict.value,
)
const requested = shallowRef<string | null>(null)
function request(): void {
requested.value = summary.value
}
</script>
<template>
<GhostCard class="studio-booking">
<template #header>
<div class="studio-booking__header">
<h2 class="studio-booking__title">Book Studio B</h2>
<p class="studio-booking__meta">
Struck-through days are booked or already past.
</p>
</div>
</template>
<GhostCalendar
v-model="range"
selection-mode="range"
:default-visible-month="visibleMonth"
:today="today"
:min-value="today"
:is-date-disabled="isBooked"
@select="onSelect"
>
<GhostCalendarHeader class="studio-booking__nav">
<GhostCalendarHeading />
<GhostCalendarPrevButton />
<GhostCalendarNextButton />
</GhostCalendarHeader>
<GhostCalendarGrid />
</GhostCalendar>
<template #footer>
<div class="studio-booking__footer">
<p
class="studio-booking__summary"
:data-conflict="conflict || undefined"
role="status"
aria-live="polite"
>
{{ summary }}
</p>
<div class="studio-booking__actions">
<GhostButton
variant="outline"
tone="neutral"
size="sm"
:disabled="range === null"
@click="clear"
>
Clear dates
</GhostButton>
<GhostButton size="sm" :disabled="!canRequest" @click="request">
Request booking
</GhostButton>
</div>
<p v-if="requested" class="studio-booking__requested">
Requested: {{ requested }}
</p>
</div>
</template>
</GhostCard>
</template>
<style scoped>
.studio-booking {
inline-size: 100%;
max-inline-size: 22rem;
}
.studio-booking__header {
display: grid;
gap: var(--ghost-space-gap-xs);
}
/* Reset the docs prose heading so the card title keeps the card's type scale. */
.studio-booking__title {
border: 0;
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-tight);
margin: 0;
padding: 0;
}
.studio-booking__meta,
.studio-booking__requested {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-xs);
margin: 0;
}
.studio-booking__nav :deep(.ghost-calendar-heading) {
text-align: start;
}
.studio-booking__footer {
display: grid;
gap: var(--ghost-space-gap-sm);
inline-size: 100%;
}
.studio-booking__summary {
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-sm);
font-variant-numeric: tabular-nums;
margin: 0;
}
.studio-booking__summary[data-conflict] {
color: var(--ghost-text-danger);
}
.studio-booking__actions {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-xs);
justify-content: flex-end;
}
</style>
calendar/office-locale
Themed calendar that switches locale and week start per office while the selected date stays the same.
Quarterly review
June 2024
- London
- Friday, 14 June 2024
- Saved as
2024-06-14
<script setup lang="ts">
import { computed, shallowRef } from 'vue'
import {
CalendarDate,
type DateValue,
GhostCalendar,
GhostCalendarGrid,
GhostCalendarHeader,
GhostCalendarHeading,
GhostCalendarNextButton,
GhostCalendarPrevButton,
GhostCard,
GhostSegmentedControl,
GhostSegmentedControlItem,
} from '@ghostvue/themes'
type OfficeId = 'austin' | 'london'
interface Office {
label: string
locale: string
/** 0 = Sunday. Set explicitly: not every browser reports a locale's week start. */
weekStartsOn: number
}
const offices: Record<OfficeId, Office> = {
austin: { label: 'Austin', locale: 'en-US', weekStartsOn: 0 },
london: { label: 'London', locale: 'en-GB', weekStartsOn: 1 },
}
const officeId = shallowRef<OfficeId>('london')
const office = computed(() => offices[officeId.value])
const today = new CalendarDate(2024, 6, 3)
const visibleMonth = new CalendarDate(2024, 6, 1)
// A `CalendarDate` carries no locale: switching offices relabels the grid,
// but the selected day and the value sent to your API stay the same.
const reviewDay = shallowRef<DateValue>(new CalendarDate(2024, 6, 14))
const localDate = computed(() =>
new Intl.DateTimeFormat(office.value.locale, {
dateStyle: 'full',
timeZone: 'UTC',
}).format(reviewDay.value.toDate('UTC')),
)
function isOfficeId(value: string | undefined): value is OfficeId {
return value !== undefined && Object.hasOwn(offices, value)
}
function selectOffice(value: string | undefined): void {
// The segmented control reports `undefined` when its value is cleared;
// keep the current office so the calendar always has a locale.
if (isOfficeId(value)) officeId.value = value
}
</script>
<template>
<GhostCard class="office-review">
<template #header>
<div class="office-review__header">
<h2 class="office-review__title">Quarterly review</h2>
<GhostSegmentedControl
:model-value="officeId"
aria-label="Office calendar"
@update:model-value="selectOffice"
>
<GhostSegmentedControlItem
v-for="(entry, id) in offices"
:key="id"
:value="id"
>
{{ entry.label }}
</GhostSegmentedControlItem>
</GhostSegmentedControl>
</div>
</template>
<!--
`lang` tells screen readers which locale the month and weekday names
use. The themed root forwards other attributes to the headless
calendar, so the wrapper element carries it.
-->
<div :lang="office.locale">
<GhostCalendar
v-model="reviewDay"
:locale="office.locale"
:week-starts-on="office.weekStartsOn"
:default-visible-month="visibleMonth"
:today="today"
>
<GhostCalendarHeader class="office-review__nav">
<GhostCalendarHeading />
<GhostCalendarPrevButton />
<GhostCalendarNextButton />
</GhostCalendarHeader>
<GhostCalendarGrid />
</GhostCalendar>
</div>
<template #footer>
<div class="office-review__status" role="status" aria-live="polite">
<dl class="office-review__summary">
<div>
<dt>{{ office.label }}</dt>
<dd :lang="office.locale">{{ localDate }}</dd>
</div>
<div>
<dt>Saved as</dt>
<dd>
<code>{{ reviewDay.toString() }}</code>
</dd>
</div>
</dl>
</div>
</template>
</GhostCard>
</template>
<style scoped>
.office-review {
inline-size: 100%;
max-inline-size: 22rem;
}
.office-review__header {
display: grid;
gap: var(--ghost-space-gap-sm);
}
/* Reset the docs prose heading so the card title keeps the card's type scale. */
.office-review__title {
border: 0;
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-tight);
margin: 0;
padding: 0;
}
.office-review__nav :deep(.ghost-calendar-heading) {
text-align: start;
}
.office-review__status {
inline-size: 100%;
}
.office-review__summary {
display: grid;
gap: var(--ghost-space-gap-xs);
font-size: var(--ghost-type-size-xs);
inline-size: 100%;
margin: 0;
}
.office-review__summary div {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-xs);
justify-content: space-between;
}
.office-review__summary dt {
color: var(--ghost-text-muted);
}
.office-review__summary dd {
color: var(--ghost-surface-fg);
font-variant-numeric: tabular-nums;
margin: 0;
}
</style>
calendar/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
Fri, Jun 14: Copy freeze, Beta build.
<script setup lang="ts">
import { computed, shallowRef } from 'vue'
import {
CalendarDate,
GhostCalendar,
GhostCalendarGrid,
GhostCalendarHeader,
GhostCalendarHeading,
GhostCalendarNextButton,
GhostCalendarPrevButton,
GhostCard,
} from '@ghostvue/themes'
// A fixed "today" keeps the demo, its tests, and its screenshots stable.
const today = new CalendarDate(2024, 6, 3)
const visibleMonth = new CalendarDate(2024, 6, 1)
// Deadlines keyed by ISO date, the same string `CalendarDate#toString` gives.
const deadlines: Readonly<Record<string, readonly string[]>> = {
'2024-06-07': ['Design review'],
'2024-06-14': ['Copy freeze', 'Beta build'],
'2024-06-21': ['Release notes'],
'2024-06-28': ['Launch'],
}
function deadlinesOn(date: CalendarDate): readonly string[] {
return deadlines[date.toString()] ?? []
}
const selected = shallowRef<CalendarDate>(new CalendarDate(2024, 6, 14))
const dayFormat = new Intl.DateTimeFormat('en-US', {
weekday: 'short',
month: 'short',
day: 'numeric',
timeZone: 'UTC',
})
/*
* The dot under a day is decorative, and each cell keeps its own accessible
* name (the full date), so the deadlines are also written out here as text.
* The status updates when a day is picked with the pointer or keyboard.
*/
const summary = computed(() => {
const day = dayFormat.format(selected.value.toDate('UTC'))
const due = deadlinesOn(selected.value)
return due.length === 0
? `${day}: no deadlines.`
: `${day}: ${due.join(', ')}.`
})
</script>
<template>
<GhostCard class="release-deadlines">
<template #header>
<div class="release-deadlines__header">
<h2 class="release-deadlines__title">Release deadlines</h2>
<p class="release-deadlines__meta">
A dot marks a day with a deadline.
</p>
</div>
</template>
<GhostCalendar
v-model="selected"
:default-visible-month="visibleMonth"
:today="today"
>
<GhostCalendarHeader class="release-deadlines__nav">
<GhostCalendarHeading />
<GhostCalendarPrevButton />
<GhostCalendarNextButton />
</GhostCalendarHeader>
<GhostCalendarGrid>
<!--
Slot content replaces only what the cell shows. Render the day
number yourself; the cell still names itself with the full date
(the `accessibleLabel` slot prop), so the marker stays aria-hidden.
-->
<template #cell="{ date }">
<span class="release-deadlines__day">
{{ date.day }}
<span
v-if="deadlinesOn(date).length > 0"
class="release-deadlines__marker"
aria-hidden="true"
/>
</span>
</template>
</GhostCalendarGrid>
</GhostCalendar>
<template #footer>
<p class="release-deadlines__summary" role="status" aria-live="polite">
{{ summary }}
</p>
</template>
</GhostCard>
</template>
<style scoped>
.release-deadlines {
inline-size: 100%;
max-inline-size: 22rem;
}
.release-deadlines__header {
display: grid;
gap: var(--ghost-space-gap-xs);
}
/* Reset the docs prose heading so the card title keeps the card's type scale. */
.release-deadlines__title {
border: 0;
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-tight);
margin: 0;
padding: 0;
}
.release-deadlines__meta {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-xs);
margin: 0;
}
.release-deadlines__nav :deep(.ghost-calendar-heading) {
text-align: start;
}
/*
* The marker is positioned under the number instead of stacked with it, so
* days with and without a deadline keep their number on the same baseline
* and the square cell never grows.
*/
.release-deadlines__day {
line-height: 1;
position: relative;
}
/*
* `currentColor` follows the cell's text color, so the dot stays visible on
* selected, today, outside-month, and forced-colors cells without extra rules.
*/
.release-deadlines__marker {
background-color: currentColor;
block-size: 0.25rem;
border-radius: 50%;
inline-size: 0.25rem;
inset-block-start: calc(100% + 0.125rem);
inset-inline: 0;
margin-inline: auto;
position: absolute;
}
.release-deadlines__summary {
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-sm);
margin: 0;
}
</style>