GhostCheckboxGroup reference
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed wrapper around headless GhostCheckboxGroup with fieldset reset and vertical stack spacing. Adds no visual props or per-component tokens.
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 | Member checkboxes, labels, legend, descriptions, and non-member content. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Blurs the active member if it is inside the group. Delegates to the unstyled GhostCheckboxGroup. |
element | HTMLElement | null | The group root element after mount; null before mount. Delegates to the unstyled GhostCheckboxGroup. |
focus | (options?: FocusOptions) => void | Focuses the first enabled checked member in DOM order, else the first enabled member. Delegates to the unstyled GhostCheckboxGroup. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | The group fieldset or host inside the display:contents themed scope. |
data-state | invalid | Group-level error state. |
data-state | disabled | Whole group disabled. |
CSS variables
| Name | Description |
|---|---|
--ghost-space-stack-sm | Vertical stack gap between group children and space below the direct legend. |
--ghost-text-default | Direct legend text color. |
--ghost-type-size-md | Direct legend font size. |
--ghost-type-weight-semibold | Direct legend font weight. |
--ghost-type-line-tight | Direct legend line height. |
Accessibility
Role: group. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/.
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
checkbox-group/notification-preferences
Themed notification preferences with array v-model, mixed select-all, locked choice, and FormData.getAll readout.
<script setup lang="ts">
import { computed, ref } from 'vue'
import {
GhostButton,
GhostCard,
GhostCheckbox,
GhostCheckboxGroup,
GhostField,
GhostFieldControl,
GhostFieldDescription,
GhostFieldLabel,
} from '@ghostvue/themes'
type ProjectNotification = 'mentions' | 'assignments' | 'digest'
type AccountNotification = 'security' | 'billing'
interface Option<TValue extends string> {
value: TValue
label: string
description: string
/** Workspace policy owns this choice; members cannot change it. */
locked?: boolean
}
const projectOptions: readonly Option<ProjectNotification>[] = [
{
value: 'mentions',
label: 'Comments and mentions',
description: 'Someone replies to you or mentions you by name.',
},
{
value: 'assignments',
label: 'Task assignments',
description: 'A task is assigned to you or its due date changes.',
},
{
value: 'digest',
label: 'Weekly digest',
description: 'A Monday summary of activity across your projects.',
},
]
const accountOptions: readonly Option<AccountNotification>[] = [
{
value: 'security',
label: 'Security alerts',
description:
'New sign-ins and password changes. Required by your workspace.',
locked: true,
},
{
value: 'billing',
label: 'Billing receipts',
description: 'Invoices, payment confirmations, and failed charges.',
},
]
const projectDefaults: readonly ProjectNotification[] = [
'mentions',
'assignments',
]
const accountDefaults: readonly AccountNotification[] = ['security']
// The consumer owns these arrays. The group emits new arrays and never
// mutates them.
const project = ref<ProjectNotification[]>([...projectDefaults])
const account = ref<AccountNotification[]>([...accountDefaults])
const submittedValues = ref<string[] | null>(null)
// Select-all counts enabled options only so disabled choices never trap it in mixed.
const projectEnabled = computed(() =>
projectOptions.filter((option) => !option.locked).map((o) => o.value),
)
const projectOnCount = computed(
() => projectEnabled.value.filter((v) => project.value.includes(v)).length,
)
const allProject = computed(
() =>
projectEnabled.value.length > 0 &&
projectOnCount.value === projectEnabled.value.length,
)
const someProject = computed(
() => projectOnCount.value > 0 && !allProject.value,
)
function setAllProject(checked: boolean): void {
const enabled = new Set<ProjectNotification>(projectEnabled.value)
project.value = checked
? [
...project.value,
...projectEnabled.value.filter((v) => !project.value.includes(v)),
]
: project.value.filter((v) => !enabled.has(v))
}
// Listen to native `change` (user activation only), never `update:modelValue`
// which also fires on native form reset.
function onAllProjectChange(event: Event): void {
if (event.target instanceof HTMLInputElement) {
setAllProject(event.target.checked)
}
}
function restoreDefaults(): void {
project.value = [...projectDefaults]
account.value = [...accountDefaults]
submittedValues.value = null
}
function clearSaved(): void {
submittedValues.value = null
}
function save(event: Event): void {
const form = event.currentTarget as HTMLFormElement
submittedValues.value = new FormData(form)
.getAll('notifications')
.filter((entry): entry is string => typeof entry === 'string')
}
</script>
<template>
<form class="prefs" @submit.prevent="save" @change="clearSaved">
<GhostCard as="section" aria-labelledby="prefs-title">
<template #header>
<div class="prefs__header">
<h2 id="prefs-title" class="prefs__title">Email notifications</h2>
<p class="prefs__lead">
Choose what reaches ada@analytical-engines.example.
</p>
</div>
</template>
<div class="prefs__groups">
<GhostCheckboxGroup
v-model="project"
name="notifications"
aria-describedby="prefs-project-hint"
>
<legend>Project activity</legend>
<p id="prefs-project-hint" class="prefs__group-hint">
Updates from projects you follow.
</p>
<!-- No `value`: keeps standalone boolean contract and mixed state. -->
<GhostField class="pref">
<GhostFieldControl v-slot="field">
<GhostCheckbox
v-bind="field"
:model-value="allProject"
:indeterminate="someProject"
@change="onAllProjectChange"
/>
</GhostFieldControl>
<GhostFieldLabel>All project activity</GhostFieldLabel>
<GhostFieldDescription>
{{ projectOnCount }} of {{ projectEnabled.length }} on
</GhostFieldDescription>
</GhostField>
<div class="prefs__children">
<GhostField
v-for="option in projectOptions"
:key="option.value"
:disabled="Boolean(option.locked)"
class="pref"
>
<GhostFieldControl v-slot="field">
<GhostCheckbox v-bind="field" :value="option.value" />
</GhostFieldControl>
<GhostFieldLabel>{{ option.label }}</GhostFieldLabel>
<GhostFieldDescription>
{{ option.description }}
</GhostFieldDescription>
</GhostField>
</div>
</GhostCheckboxGroup>
<GhostCheckboxGroup
v-model="account"
name="notifications"
aria-describedby="prefs-account-hint"
class="prefs__group--separated"
>
<legend>Account</legend>
<p id="prefs-account-hint" class="prefs__group-hint">
Security and billing for you.
</p>
<GhostField
v-for="option in accountOptions"
:key="option.value"
:disabled="Boolean(option.locked)"
class="pref"
>
<GhostFieldControl v-slot="field">
<GhostCheckbox v-bind="field" :value="option.value" />
</GhostFieldControl>
<GhostFieldLabel>{{ option.label }}</GhostFieldLabel>
<GhostFieldDescription>
{{ option.description }}
</GhostFieldDescription>
</GhostField>
</GhostCheckboxGroup>
<dl class="prefs__readout">
<div class="prefs__readout-row">
<dt>Model</dt>
<dd>
<code>{{ JSON.stringify([...project, ...account]) }}</code>
</dd>
</div>
<div class="prefs__readout-row">
<dt>FormData</dt>
<dd>
<code>{{
submittedValues === null
? 'Submit to inspect getAll("notifications")'
: JSON.stringify(submittedValues)
}}</code>
</dd>
</div>
</dl>
</div>
<template #footer>
<div class="prefs__actions">
<p class="prefs__status" role="status">
{{
submittedValues === null
? ''
: `Saved ${submittedValues.length} preference${submittedValues.length === 1 ? '' : 's'}.`
}}
</p>
<GhostButton
type="button"
variant="ghost"
tone="neutral"
class="prefs__action"
@click="restoreDefaults"
>
Restore defaults
</GhostButton>
<GhostButton type="submit" class="prefs__action">
Save preferences
</GhostButton>
</div>
</template>
</GhostCard>
</form>
</template>
<style scoped>
.prefs {
max-inline-size: 42rem;
}
.prefs__header {
display: grid;
gap: var(--ghost-space-gap-xs);
padding-block-end: var(--ghost-space-stack-sm);
}
.prefs__title {
color: var(--ghost-text-default);
font-size: var(--ghost-type-size-lg);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-tight);
margin: 0;
}
.prefs__lead,
.prefs__group-hint,
.prefs__status {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-snug);
margin: 0;
overflow-wrap: anywhere;
}
.prefs__groups {
display: grid;
gap: var(--ghost-space-stack-md);
}
.prefs__group--separated {
border-block-start: var(--ghost-border-hairline-width) solid
var(--ghost-border-muted);
padding-block-start: var(--ghost-space-stack-md);
}
.prefs__children {
display: grid;
gap: var(--ghost-space-stack-sm);
padding-inline-start: calc(
var(--ghost-control-size-md-min) + var(--ghost-space-gap-sm)
);
}
.prefs :deep(.pref) {
column-gap: var(--ghost-space-gap-sm);
display: grid;
grid-template-columns: auto minmax(0, 1fr);
row-gap: var(--ghost-space-gap-xs);
}
.prefs :deep(.pref > .ghost-themed-scope) {
display: flex;
grid-row: 1 / span 2;
}
.prefs :deep(.pref > [data-part='label']) {
cursor: pointer;
grid-column: 2;
padding-block-start: calc((var(--ghost-control-size-md-min) - 1lh) / 2);
}
.prefs :deep(.pref[data-state='disabled'] > [data-part='label']) {
cursor: not-allowed;
}
.prefs :deep(.pref > [data-part='description']) {
grid-column: 2;
overflow-wrap: anywhere;
}
.prefs__readout {
border-block-start: var(--ghost-border-hairline-width) solid
var(--ghost-border-muted);
display: grid;
gap: var(--ghost-space-gap-xs);
margin: 0;
padding-block-start: var(--ghost-space-stack-sm);
}
.prefs__readout-row {
display: flex;
flex-wrap: wrap;
font-size: var(--ghost-type-size-xs);
gap: var(--ghost-space-gap-xs);
}
.prefs__readout-row dt {
color: var(--ghost-text-muted);
font-weight: var(--ghost-type-weight-medium);
}
.prefs__readout-row dd {
color: var(--ghost-text-default);
margin: 0;
overflow-wrap: anywhere;
}
.prefs__actions {
display: grid;
gap: var(--ghost-space-gap-sm) var(--ghost-space-gap-md);
}
.prefs :deep(.prefs__action) {
inline-size: 100%;
}
@container ghost-demo (min-width: 30rem) {
.prefs__actions {
align-items: center;
display: flex;
justify-content: flex-end;
}
.prefs__status {
flex: 1 1 auto;
}
.prefs :deep(.prefs__action) {
inline-size: auto;
}
}
</style>
checkbox-group/room-extras
Booking extras as GhostCheckboxCard choices, each its own tab stop, with the array model.
Extras: breakfast
<script setup lang="ts">
import { ref } from 'vue'
import { GhostCheckboxCard, GhostCheckboxGroup } from '@ghostvue/themes'
type Extra = 'breakfast' | 'late-checkout' | 'parking'
const extras = ref<Extra[]>(['breakfast'])
</script>
<template>
<div class="extras">
<!--
Each card is its own tab stop. Space toggles the focused card, and a
click anywhere on a card toggles it.
-->
<GhostCheckboxGroup v-model="extras" name="extras" class="extras__grid">
<legend class="extras__legend">Extras</legend>
<GhostCheckboxCard value="breakfast">
Breakfast
<template #description>Served 7 to 10 AM · $18 a person</template>
</GhostCheckboxCard>
<GhostCheckboxCard value="late-checkout">
Late checkout
<template #description>Leave at 2 PM · $30</template>
</GhostCheckboxCard>
<GhostCheckboxCard value="parking">
Parking
<template #description>Covered garage · $25 a night</template>
</GhostCheckboxCard>
</GhostCheckboxGroup>
<p class="extras__status" role="status">
Extras: {{ extras.length ? extras.join(', ') : 'none' }}
</p>
</div>
</template>
<style scoped>
.extras {
display: grid;
gap: var(--ghost-space-stack-md);
max-inline-size: 40rem;
}
/* The themed group puts `class` on its inner fieldset, so reach it with :deep(). */
.extras :deep(.extras__grid) {
display: grid;
gap: var(--ghost-space-gap-md);
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}
.extras__legend {
font-weight: var(--ghost-type-weight-semibold);
margin-block-end: var(--ghost-space-stack-sm);
padding: 0;
}
.extras__status {
color: var(--ghost-text-muted);
margin: 0;
}
</style>
checkbox-group/basic
Themed checkbox group with a legend and three visible options.
Selected: email
<script setup lang="ts">
import { ref } from 'vue'
import { GhostCheckbox, GhostCheckboxGroup } from '@ghostvue/themes'
type Channel = 'email' | 'slack' | 'webhooks'
const channels = ref<Channel[]>(['email'])
</script>
<template>
<div class="basic-group">
<GhostCheckboxGroup v-model="channels" name="channels">
<legend>Release updates</legend>
<label class="basic-group__option">
<GhostCheckbox value="email" />
Email digest
</label>
<label class="basic-group__option">
<GhostCheckbox value="slack" />
Slack channel
</label>
<label class="basic-group__option">
<GhostCheckbox value="webhooks" />
Webhook events
</label>
</GhostCheckboxGroup>
<p class="basic-group__summary">
Selected: {{ channels.length ? channels.join(', ') : 'none' }}
</p>
</div>
</template>
<style scoped>
.basic-group {
display: grid;
gap: var(--ghost-space-stack-sm);
}
.basic-group__option {
align-items: center;
color: var(--ghost-text-default);
cursor: pointer;
display: inline-flex;
font-size: var(--ghost-type-size-sm);
gap: var(--ghost-space-gap-sm);
line-height: var(--ghost-type-line-snug);
}
.basic-group__summary {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
margin: 0;
}
</style>
checkbox-group/form
Native form submission and reset restoring the default selection.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostButton,
GhostCheckbox,
GhostCheckboxGroup,
} from '@ghostvue/themes'
type ExportColumn = 'id' | 'customer' | 'total' | 'tax'
const defaultColumns: readonly ExportColumn[] = ['id', 'total']
const columns = ref<ExportColumn[]>([...defaultColumns])
const submitted = ref<string[] | null>(null)
function onSubmit(event: Event): void {
const form = event.currentTarget as HTMLFormElement
submitted.value = new FormData(form)
.getAll('columns')
.filter((entry): entry is string => typeof entry === 'string')
}
function onReset(): void {
submitted.value = null
}
</script>
<template>
<form class="export-form" @submit.prevent="onSubmit" @reset="onReset">
<GhostCheckboxGroup
v-model="columns"
:default-value="defaultColumns"
name="columns"
>
<legend>Export columns</legend>
<label class="export-form__option">
<GhostCheckbox value="id" />
Invoice ID
</label>
<label class="export-form__option">
<GhostCheckbox value="customer" />
Customer name
</label>
<label class="export-form__option">
<GhostCheckbox value="total" />
Total amount
</label>
<label class="export-form__option">
<GhostCheckbox value="tax" />
Tax breakdown
</label>
</GhostCheckboxGroup>
<div class="export-form__actions">
<GhostButton type="reset" variant="ghost" tone="neutral">
Reset
</GhostButton>
<GhostButton type="submit">Export CSV</GhostButton>
</div>
<p class="export-form__result" role="status">
{{
submitted === null
? `Model: ${JSON.stringify(columns)}`
: `Submitted getAll("columns"): ${JSON.stringify(submitted)}`
}}
</p>
</form>
</template>
<style scoped>
.export-form {
display: grid;
gap: var(--ghost-space-stack-md);
max-inline-size: 28rem;
}
.export-form__option {
align-items: center;
color: var(--ghost-text-default);
cursor: pointer;
display: inline-flex;
font-size: var(--ghost-type-size-sm);
gap: var(--ghost-space-gap-sm);
line-height: var(--ghost-type-line-snug);
}
.export-form__actions {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
}
.export-form__result {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
margin: 0;
overflow-wrap: anywhere;
}
</style>
checkbox-group/field
Group-level invalid state and error text linked via aria-describedby.
Choose at least one token scope before generating a key.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { GhostCheckbox, GhostCheckboxGroup } from '@ghostvue/themes'
type Scope = 'read' | 'write' | 'admin'
const scopes = ref<Scope[]>([])
const isInvalid = computed(() => scopes.value.length === 0)
</script>
<template>
<div class="scope-field">
<GhostCheckboxGroup
v-model="scopes"
name="scopes"
:invalid="isInvalid"
:aria-describedby="isInvalid ? 'scope-error' : 'scope-hint'"
>
<legend>API token scopes</legend>
<p id="scope-hint" class="scope-field__hint">
Select at least one permission for this token.
</p>
<label class="scope-field__option">
<GhostCheckbox value="read" />
Read deployments
</label>
<label class="scope-field__option">
<GhostCheckbox value="write" />
Trigger builds
</label>
<label class="scope-field__option">
<GhostCheckbox value="admin" />
Manage billing
</label>
</GhostCheckboxGroup>
<p v-if="isInvalid" id="scope-error" class="scope-field__error">
Choose at least one token scope before generating a key.
</p>
</div>
</template>
<style scoped>
.scope-field {
display: grid;
gap: var(--ghost-space-gap-xs);
}
.scope-field__hint {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-snug);
margin: 0;
}
.scope-field__option {
align-items: center;
color: var(--ghost-text-default);
cursor: pointer;
display: inline-flex;
font-size: var(--ghost-type-size-sm);
gap: var(--ghost-space-gap-sm);
line-height: var(--ghost-type-line-snug);
}
.scope-field__error {
color: var(--ghost-status-danger-fg);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-snug);
margin: 0;
}
</style>