GhostDatePicker reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed GhostDatePicker root, inputs, trigger, and anchored modal surface using --ghost-* tokens. Sizes follow the shared control scale, which floors to 44px touch targets on coarse pointers.
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 | Date picker parts composed by the consumer. |
Slot props: default
None declared.
Exposed members
None declared.
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | input | Themed text field with .ghost-date-picker-input. |
data-part | trigger | Themed icon button with .ghost-date-picker-trigger. |
data-part | content | Elevated dialog surface with .ghost-date-picker-content; calendar parts inherit the calendar recipe. |
data-state | open | Trigger data-state while the calendar is open. |
CSS variables
| Name | Description |
|---|---|
--ghost-elevation-3-bg | Calendar surface background. |
--ghost-surface-bg | Input background. |
--ghost-border-danger | Invalid input border. |
Accessibility
Role: dialog. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/examples/datepicker-dialog/.
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
date-picker/controlled
Controlled value and open state with an explicit clear action.
Calendar closed
YYYY-MM-DD<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostButton,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
type GhostDatePickerValue,
} from '@ghostvue/themes'
const launch = shallowRef<GhostDatePickerValue>(new CalendarDate(2026, 12, 1))
const open = shallowRef(false)
const today = new CalendarDate(2026, 11, 17)
</script>
<template>
<div class="ghost-theme date-picker-controlled">
<label for="date-picker-controlled-launch">Launch date</label>
<GhostDatePicker
v-slot="{ clear, pending }"
v-model="launch"
v-model:open="open"
:today="today"
>
<span class="date-picker-controlled__row">
<GhostDatePickerInput id="date-picker-controlled-launch" />
<GhostDatePickerTrigger />
<GhostButton type="button" @click="clear">Clear</GhostButton>
</span>
<GhostDatePickerContent />
<p>
Calendar {{ open ? 'open' : 'closed'
}}{{ pending ? ', unsaved text' : '' }}
</p>
</GhostDatePicker>
<output>
{{ launch instanceof CalendarDate ? launch.toString() : 'No date' }}
</output>
</div>
</template>
<style scoped>
.date-picker-controlled {
display: grid;
gap: 0.5rem;
justify-items: start;
}
.date-picker-controlled__row {
display: inline-flex;
flex-wrap: wrap;
gap: 0.25rem;
}
.date-picker-controlled p {
margin: 0;
}
</style>
date-picker/validation
Required range with bounds, validateRange rejecting interior unavailable dates, native submit and reset.
<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostButton,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
type GhostDatePickerRange,
} from '@ghostvue/themes'
const today = new CalendarDate(2026, 11, 17)
const maxNights = 14
const booked = new Set(['2026-11-25', '2026-11-26'])
function isBooked(date: CalendarDate): boolean {
return booked.has(date.toString())
}
// The picker checks endpoints only. Reject booked nights inside the range
// here, after capping the length so the scan stays bounded.
function validateStay(range: GhostDatePickerRange): string | null {
const nights = range.end.compare(range.start)
if (nights > maxNights) {
return `Stays are limited to ${String(maxNights)} nights`
}
for (let offset = 0; offset <= nights; offset += 1) {
if (isBooked(range.start.add({ days: offset }))) {
return 'This stay includes booked nights'
}
}
return null
}
const submitted = shallowRef('')
function onSubmit(event: Event): void {
if (event.target instanceof HTMLFormElement) {
const data = new FormData(event.target)
const field = (name: string) => {
const value = data.get(name)
return typeof value === 'string' ? value : ''
}
submitted.value = `${field('stay[start]')} to ${field('stay[end]')}`
}
}
</script>
<template>
<form class="ghost-theme date-picker-validation" @submit.prevent="onSubmit">
<div
class="date-picker-validation__group"
role="group"
aria-labelledby="date-picker-validation-legend"
>
<span id="date-picker-validation-legend">Stay (required)</span>
<GhostDatePicker
v-slot="{ errors }"
selection-mode="range"
name="stay"
required
:today="today"
:min-value="today"
:is-date-disabled="isBooked"
:validate-range="validateStay"
>
<span class="date-picker-validation__row">
<label for="date-picker-validation-start">Check-in</label>
<GhostDatePickerInput
id="date-picker-validation-start"
part="start"
/>
<label for="date-picker-validation-end">Check-out</label>
<GhostDatePickerInput id="date-picker-validation-end" part="end" />
<GhostDatePickerTrigger />
</span>
<GhostDatePickerContent />
<ul v-if="errors.length > 0" class="date-picker-validation__errors">
<li v-for="error in errors" :key="`${error.part}-${error.code}`">
{{ error.message }}
</li>
</ul>
</GhostDatePicker>
</div>
<span class="date-picker-validation__row">
<GhostButton type="submit">Book</GhostButton>
<GhostButton type="reset" variant="outline">Reset</GhostButton>
</span>
<output>{{ submitted || 'Not submitted' }}</output>
</form>
</template>
<style scoped>
.date-picker-validation {
display: grid;
gap: 0.5rem;
justify-items: start;
}
.date-picker-validation__group {
display: grid;
gap: 0.25rem;
}
.date-picker-validation__row {
align-items: center;
display: inline-flex;
flex-wrap: wrap;
gap: 0.25rem;
}
.date-picker-validation__errors {
margin: 0;
padding-inline-start: 1.25rem;
}
</style>
date-picker/form
Date range inside GhostForm with a maximum stay; the picker's reason shows in the field error and blocks submit.
<script setup lang="ts">
import { computed, shallowReactive, shallowRef } from 'vue'
import { GhostForm, type StandardSchemaV1 } from '@ghostvue/vue'
import {
CalendarDate,
GhostButton,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
GhostField,
GhostFieldControl,
GhostFieldError,
GhostFieldLabel,
type GhostDatePickerRange,
type GhostDatePickerValue,
} from '@ghostvue/themes'
interface StayValues {
checkIn: CalendarDate | null
checkOut: CalendarDate | null
}
interface Stay {
checkIn: CalendarDate
checkOut: CalendarDate
}
const today = new CalendarDate(2026, 11, 17)
const maxNights = 14
// CalendarDate has private fields, so the form values stay shallow.
const values = shallowReactive<StayValues>({ checkIn: null, checkOut: null })
const stay = computed<GhostDatePickerValue>({
get: () =>
values.checkIn && values.checkOut
? { start: values.checkIn, end: values.checkOut }
: null,
set: (next) => {
const range = next && 'start' in next ? next : null
values.checkIn = range?.start ?? null
values.checkOut = range?.end ?? null
},
})
// The schema sees only committed dates, and the picker commits both ends at
// once, so one stay-level message on the check-in path covers an empty stay.
// The picker reports what it rejects (here, the maximum stay) in the same
// field error, and the check-out field stays clear instead of claiming that a
// date it visibly holds is missing.
const staySchema: StandardSchemaV1<StayValues, Stay> = {
'~standard': {
version: 1,
vendor: 'example',
validate(raw) {
const data = raw as StayValues
if (data.checkIn && data.checkOut) {
return { value: { checkIn: data.checkIn, checkOut: data.checkOut } }
}
return {
issues: [
{
message: 'Choose check-in and check-out dates',
path: ['checkIn'],
},
],
}
},
},
}
function validateStay(range: GhostDatePickerRange): string | null {
const nights = range.end.compare(range.start)
return nights > maxNights
? `Stays are limited to ${String(maxNights)} nights`
: null
}
const booked = shallowRef('')
function onSubmit({ output }: { output: Stay }): void {
booked.value = `${output.checkIn.toString()} to ${output.checkOut.toString()}`
}
function onReset(): void {
stay.value = null
booked.value = ''
}
</script>
<template>
<GhostForm
class="ghost-theme date-picker-form"
:schema="staySchema"
:values="values"
@submit="onSubmit"
@reset="onReset"
>
<div
class="date-picker-form__group"
role="group"
aria-labelledby="date-picker-form-legend"
>
<span id="date-picker-form-legend" class="date-picker-form__legend">
Stay (up to {{ maxNights }} nights)
</span>
<GhostDatePicker
v-model="stay"
selection-mode="range"
:today="today"
:min-value="today"
:validate-range="validateStay"
>
<GhostField name="checkIn">
<GhostFieldLabel>Check-in</GhostFieldLabel>
<GhostFieldControl v-slot="field">
<GhostDatePickerInput v-bind="field" part="start" />
</GhostFieldControl>
<GhostFieldError />
</GhostField>
<GhostField name="checkOut">
<GhostFieldLabel>Check-out</GhostFieldLabel>
<!-- The trigger sits beside the last input, so it stays aligned
when a field error appears below. -->
<span class="date-picker-form__control">
<GhostFieldControl v-slot="field">
<GhostDatePickerInput v-bind="field" part="end" />
</GhostFieldControl>
<GhostDatePickerTrigger aria-label="Choose stay dates" />
</span>
<GhostFieldError />
</GhostField>
<GhostDatePickerContent />
</GhostDatePicker>
</div>
<div class="date-picker-form__actions">
<GhostButton type="submit">Book</GhostButton>
<GhostButton type="reset" variant="outline">Reset</GhostButton>
</div>
<output>{{ booked ? `Booked ${booked}` : 'Not booked yet' }}</output>
</GhostForm>
</template>
<style scoped>
.date-picker-form {
display: grid;
gap: var(--ghost-space-gap-md);
justify-items: start;
}
.date-picker-form__group {
align-items: start;
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.date-picker-form__legend {
flex-basis: 100%;
font-weight: var(--ghost-type-weight-semibold);
}
.date-picker-form__control {
align-items: center;
display: flex;
gap: var(--ghost-space-gap-xs);
}
.date-picker-form__actions {
display: flex;
gap: var(--ghost-space-gap-sm);
}
</style>
date-picker/custom-format
Consumer parse and format callbacks for DD.MM.YYYY with an en-GB calendar.
<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
type GhostDatePickerValue,
} from '@ghostvue/themes'
import type { GhostDatePickerFormat, GhostDatePickerParse } from '@ghostvue/vue'
const appointment = shallowRef<GhostDatePickerValue>(
new CalendarDate(2026, 11, 24),
)
const today = new CalendarDate(2026, 11, 17)
const pad = (value: number, length = 2) => String(value).padStart(length, '0')
// Display as DD.MM.YYYY. Form submission stays ISO YYYY-MM-DD.
const format: GhostDatePickerFormat = (date) =>
`${pad(date.day)}.${pad(date.month)}.${pad(date.year, 4)}`
const parse: GhostDatePickerParse = (text) => {
const match = /^(\d{2})\.(\d{2})\.(\d{4})$/.exec(text)
if (!match) return null
const [day, month, year] = [match[1], match[2], match[3]].map(Number)
if (!day || !month || !year || month > 12) return null
const date = new CalendarDate(year, month, day)
// CalendarDate constrains overflow (31.02 becomes 28.02); reject that.
return date.day === day ? date : null
}
</script>
<template>
<div class="ghost-theme date-picker-format">
<label for="date-picker-format-appointment">Appointment</label>
<span class="date-picker-format__row">
<GhostDatePicker
v-model="appointment"
locale="en-GB"
format-hint="DD.MM.YYYY"
:today="today"
:parse="parse"
:format="format"
:validation-message="
(error) =>
error.code === 'parse'
? 'Enter the date as DD.MM.YYYY'
: error.message
"
name="appointment"
>
<GhostDatePickerInput id="date-picker-format-appointment" />
<GhostDatePickerTrigger aria-label="Choose appointment date" />
<GhostDatePickerContent
aria-label="Choose appointment date"
close-label="Close calendar"
/>
</GhostDatePicker>
</span>
</div>
</template>
<style scoped>
.date-picker-format {
display: grid;
gap: 0.5rem;
justify-items: start;
}
.date-picker-format__row {
display: inline-flex;
flex-wrap: wrap;
gap: 0.25rem;
}
</style>
date-picker/rtl
Date picker in an RTL container; arrow keys follow reading direction.
<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
type GhostDatePickerValue,
} from '@ghostvue/themes'
const date = shallowRef<GhostDatePickerValue>(new CalendarDate(2026, 11, 18))
const today = new CalendarDate(2026, 11, 17)
</script>
<template>
<!-- English copy keeps the demo readable; the mirrored calendar and arrow
keys come from dir="rtl", not from the locale. -->
<div class="ghost-theme date-picker-rtl" dir="rtl">
<label for="date-picker-rtl-date">Delivery date</label>
<span class="date-picker-rtl__row">
<GhostDatePicker v-model="date" locale="en-US" :today="today">
<GhostDatePickerInput id="date-picker-rtl-date" dir="ltr" />
<GhostDatePickerTrigger aria-label="Choose delivery date" />
<GhostDatePickerContent
dir="rtl"
aria-label="Choose delivery date"
close-label="Close calendar"
/>
</GhostDatePicker>
</span>
</div>
</template>
<style scoped>
.date-picker-rtl {
display: grid;
gap: 0.5rem;
justify-items: start;
}
.date-picker-rtl__row {
display: inline-flex;
flex-wrap: wrap;
gap: 0.25rem;
}
</style>
date-picker/nested-dialog
Date picker in a modal dialog; Escape closes only the top layer.
<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
GhostDialog,
GhostDialogClose,
GhostDialogContent,
GhostDialogOverlay,
GhostDialogTitle,
GhostDialogTrigger,
type GhostDatePickerValue,
} from '@ghostvue/themes'
const reminder = shallowRef<GhostDatePickerValue>(null)
const today = new CalendarDate(2026, 11, 17)
</script>
<template>
<div class="ghost-theme">
<GhostDialog>
<GhostDialogTrigger>Schedule reminder</GhostDialogTrigger>
<GhostDialogOverlay />
<GhostDialogContent>
<GhostDialogTitle>Schedule reminder</GhostDialogTitle>
<label for="date-picker-nested-date">Remind me on</label>
<span class="reminder-dialog__row">
<GhostDatePicker v-model="reminder" :today="today">
<GhostDatePickerInput id="date-picker-nested-date" />
<GhostDatePickerTrigger />
<GhostDatePickerContent />
</GhostDatePicker>
</span>
<GhostDialogClose class="reminder-dialog__done">
Done
</GhostDialogClose>
</GhostDialogContent>
</GhostDialog>
</div>
</template>
<style scoped>
.reminder-dialog__row {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.reminder-dialog__done {
justify-self: end;
}
</style>
date-picker/themed
Choose departure and return dates with a themed range picker and a labeled field for each endpoint.
<script setup lang="ts">
import { shallowRef } from 'vue'
import {
CalendarDate,
GhostDatePicker,
GhostDatePickerContent,
GhostDatePickerInput,
GhostDatePickerTrigger,
GhostField,
GhostFieldControl,
GhostFieldLabel,
type GhostDatePickerValue,
} from '@ghostvue/themes'
const trip = shallowRef<GhostDatePickerValue>({
start: new CalendarDate(2026, 12, 4),
end: new CalendarDate(2026, 12, 8),
})
const today = new CalendarDate(2026, 11, 17)
</script>
<template>
<div class="ghost-theme date-picker-themed">
<div
class="date-picker-themed__group"
role="group"
aria-labelledby="date-picker-themed-legend"
>
<span id="date-picker-themed-legend" class="date-picker-themed__legend">
Trip booking
</span>
<GhostDatePicker
v-model="trip"
selection-mode="range"
:today="today"
name="trip"
>
<GhostField>
<GhostFieldLabel>Departure</GhostFieldLabel>
<GhostFieldControl v-slot="field">
<GhostDatePickerInput v-bind="field" part="start" />
</GhostFieldControl>
</GhostField>
<GhostField>
<GhostFieldLabel>Return</GhostFieldLabel>
<GhostFieldControl v-slot="field">
<GhostDatePickerInput v-bind="field" part="end" />
</GhostFieldControl>
</GhostField>
<GhostDatePickerTrigger aria-label="Choose trip dates" />
<GhostDatePickerContent />
</GhostDatePicker>
</div>
</div>
</template>
<style scoped>
.date-picker-themed__group {
align-items: end;
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.date-picker-themed__legend {
flex-basis: 100%;
font-weight: var(--ghost-type-weight-semibold);
}
</style>