Invoice 4821
From Billing · Nov 30
Your November invoice is ready to download.
Package: @ghostvue/themes. Status: experimental (stability policy).
Themed wrappers around headless GhostListbox, GhostListboxOption, GhostListboxGroup, and GhostListboxLabel. Importing from @ghostvue/themes loads ghost-listbox.css: a bordered surface with option rows that match Select and menu rows (control.size.sm tokens for the active density), the GhostSelectOption selected fill, an inset focus ring, a coarse-pointer touch floor, and forced-colors support.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
as | GhostListboxElement | "div" | No | Host element. Options inside a `ul` / `ol` root use `as="li"`; groups are supported only with the default `div`. Forwarded to headless GhostListbox. |
defaultValue | GhostListboxValueInput<Multiple> | — | No | Initial selection in uncontrolled mode. Copied at setup. Forwarded to headless GhostListbox. |
disabled | boolean | false | No | Disables every option. The selection stays visible and unchanged. Forwarded to headless GhostListbox. |
loop | boolean | false | No | Arrow keys wrap from the last option to the first and back. Forwarded to headless GhostListbox. |
modelValue | GhostListboxValueInput<Multiple> | — | No | Controlled selection. `undefined` is uncontrolled. Forwarded to headless GhostListbox. |
multiple | Multiple | — | No | Multiple selection (`string[]` model). Read once at setup. Forwarded to headless GhostListbox. |
orientation | GhostListboxOrientation | "vertical" | No | Which arrow keys move focus. Horizontal arrows follow reading direction. Forwarded to headless GhostListbox. |
selectionBehavior | GhostListboxSelectionBehavior | "toggle" | No | Multiple mode only: what a plain click or tap does. Forwarded to headless GhostListbox. |
selectionFollowsFocus | boolean | false | No | Single mode only: arrow keys, `Home` / `End`, and typeahead also select the newly focused option. Forwarded to headless GhostListbox. |
None declared.
| Prop | Event | Type | Description |
|---|---|---|---|
modelValue | update:modelValue | GhostListboxValueInput<Multiple> | v-model binding for `modelValue`. |
| Name | Description |
|---|---|
default | `GhostListboxOption` and `GhostListboxGroup` children. |
| Name | Type | Description |
|---|---|---|
activeValue | string | undefined | Value of the tab-stop option, or `undefined` when the root is the stop. |
selectedValues | readonly string[] | Current selection in model order, duplicates removed. |
| Name | Type | Description |
|---|---|---|
blur | () => void | Exposed method `blur`. |
element | HTMLElement | null | Exposed property `element`. |
focus | (options?: FocusOptions) => void | Focuses the current tab stop (the active option, or the root). |
focusOption | (value: string, options?: FocusOptions) => boolean | Moves the tab stop and DOM focus to the option with `value` and scrolls it into view (`block: 'nearest'`) unless `options.preventScroll` is set. Returns `false` when that option is not mounted or is disabled. Never changes the selection. |
| Attribute | Value | Description |
|---|---|---|
data-part | listbox | Bordered surface with data-themed. |
data-part | option | Row: hover, selected, disabled, and focus-ring styles; grows past the minimum for rich rows. |
data-part | group | Column of options under a label. |
data-part | label | Muted group label. |
data-state | checked | Selected option. |
data-themed | present | Present on every themed listbox part. |
| Name | Description |
|---|---|
--ghost-control-size-sm-min | Minimum option block size. |
--ghost-surface-muted-bg | Selected option background. |
--ghost-elevation-2-bg | Hovered option background. |
--ghost-focus-ring-color | Focus ring on the focused option. |
--ghost-control-touch-min | Option minimum block size on coarse pointers. |
Role: listbox. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/listbox/.
Required ARIA attributes: aria-label.
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Passed | Every declared key maps to a Chromium browser test that CI runs and requires to pass on every commit. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Themed inbox with a reading pane: selection follows focus, Archive and Delete in a toolbar and in a row context menu, and focus recovery after a delete.
From Billing · Nov 30
Your November invoice is ready to download.
Press Shift+F10 or the Menu key for message actions.
<script setup lang="ts">
import { computed, ref, useId } from 'vue'
import {
GhostButton,
GhostContextMenu,
GhostContextMenuContent,
GhostContextMenuItem,
GhostContextMenuTrigger,
GhostListbox,
GhostListboxOption,
GhostToolbar,
} from '@ghostvue/themes'
interface Message {
id: string
sender: string
subject: string
snippet: string
date: string
}
const messages = ref<Message[]>([
{
id: 'invoice-4821',
sender: 'Billing',
subject: 'Invoice 4821',
snippet: 'Your November invoice is ready to download.',
date: 'Nov 30',
},
{
id: 'nightly-build',
sender: 'Build bot',
subject: 'Nightly build passed',
snippet: 'All 1,284 checks passed on main in 14 minutes.',
date: 'Nov 29',
},
{
id: 'header-spacing',
sender: 'Design review',
subject: 'Header spacing',
snippet: 'Can we tighten the gap under the page title?',
date: 'Nov 28',
},
{
id: 'receipt-4790',
sender: 'Billing',
subject: 'Receipt 4790',
snippet: 'Thanks, we received your payment.',
date: 'Nov 27',
},
{
id: 'ticket-311',
sender: 'Support',
subject: 'Ticket 311 resolved',
snippet: 'The export timeout is fixed in today’s release.',
date: 'Nov 26',
},
])
const selected = ref<string | undefined>('invoice-4821')
const status = ref('')
// Unique ids, so two copies of the example on one page never collide.
const uid = useId()
const current = computed(() =>
messages.value.find((message) => message.id === selected.value),
)
// Removing a message selects the one after it (else the one before), so the
// reading pane keeps showing a message. The listbox moves focus there too.
function removeMessage(id: string | undefined, verb: string): void {
const index = messages.value.findIndex((message) => message.id === id)
const removed = messages.value[index]
if (!removed) return
const next = messages.value[index + 1] ?? messages.value[index - 1]
messages.value = messages.value.filter((message) => message.id !== id)
selected.value = next?.id
status.value = `${verb} “${removed.subject}”.`
}
</script>
<template>
<div class="mail-list-example">
<h2 :id="`${uid}-heading`" class="mail-list-example__heading">Inbox</h2>
<GhostToolbar label="Message actions">
<GhostButton
size="sm"
variant="outline"
:disabled="!current"
@click="removeMessage(selected, 'Archived')"
>
Archive
</GhostButton>
<GhostButton
size="sm"
variant="outline"
:disabled="!current"
@click="removeMessage(selected, 'Deleted')"
>
Delete
</GhostButton>
</GhostToolbar>
<div class="mail-list-example__panes">
<GhostContextMenu>
<GhostContextMenuTrigger as="div" focus-target="descendant">
<GhostListbox
v-model="selected"
class="mail-list-example__list"
selection-follows-focus
:aria-labelledby="`${uid}-heading`"
:aria-describedby="`${uid}-hint`"
>
<!--
The row's text is its name, so speech input can say any of it.
Sender and subject come first so screen readers start there;
text-value keeps typeahead on the sender.
-->
<GhostListboxOption
v-for="message in messages"
:key="message.id"
:value="message.id"
:text-value="message.sender"
>
<span class="mail-list-example__row">
<span class="mail-list-example__sender">
{{ message.sender }}:
</span>
<span class="mail-list-example__subject">
{{ message.subject }}
</span>
<span class="mail-list-example__meta">
{{ message.snippet }} {{ message.date }}
</span>
</span>
</GhostListboxOption>
</GhostListbox>
</GhostContextMenuTrigger>
<GhostContextMenuContent>
<GhostContextMenuItem @select="removeMessage(selected, 'Archived')">
Archive
</GhostContextMenuItem>
<GhostContextMenuItem @select="removeMessage(selected, 'Deleted')">
Delete
</GhostContextMenuItem>
</GhostContextMenuContent>
</GhostContextMenu>
<article class="mail-list-example__pane" aria-label="Reading pane">
<template v-if="current">
<h3 class="mail-list-example__pane-subject">{{ current.subject }}</h3>
<p class="mail-list-example__pane-from">
From {{ current.sender }} · {{ current.date }}
</p>
<p class="mail-list-example__pane-body">{{ current.snippet }}</p>
</template>
<p v-else class="mail-list-example__pane-from">Inbox is empty.</p>
</article>
</div>
<p :id="`${uid}-hint`" class="mail-list-example__hint">
Press Shift+F10 or the Menu key for message actions.
</p>
<p role="status" class="mail-list-example__hint">{{ status }}</p>
</div>
</template>
<style scoped>
.mail-list-example {
display: grid;
gap: var(--ghost-space-gap-sm);
}
.mail-list-example__heading {
font-size: var(--ghost-type-size-md);
margin: 0;
}
.mail-list-example__panes {
display: grid;
gap: var(--ghost-space-gap-md);
grid-template-columns: minmax(0, 1fr);
}
@container ghost-demo (min-width: 560px) {
.mail-list-example__panes {
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
}
.mail-list-example__list {
max-block-size: 18rem;
overflow: auto;
}
.mail-list-example__row {
display: grid;
gap: var(--ghost-space-gap-xs);
grid-template-columns: auto minmax(0, 1fr);
inline-size: 100%;
}
.mail-list-example__subject {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mail-list-example__meta {
color: var(--ghost-text-muted);
font-weight: var(--ghost-type-weight-regular);
grid-column: 1 / -1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mail-list-example__pane {
border: var(--ghost-border-hairline-width) solid var(--ghost-border-default);
border-radius: var(--ghost-radius-lg);
padding: var(--ghost-space-inset-md);
}
.mail-list-example__pane-subject {
font-size: var(--ghost-type-size-md);
margin: 0;
}
.mail-list-example__pane-from,
.mail-list-example__hint {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
margin: 0;
}
.mail-list-example__pane-body {
margin: var(--ghost-space-gap-sm) 0 0;
}
</style>
Themed inbox with desktop-style replace selection, Shift and Ctrl/Cmd clicks, a selection count live region, and toolbar and context menu actions on the selection.
Shift+click selects a range and Ctrl+click (Cmd+click on macOS) adds a row. Press Shift+F10 or the Menu key for actions.
0 messages selected.
<script setup lang="ts">
import { computed, ref, useId } from 'vue'
import {
GhostButton,
GhostContextMenu,
GhostContextMenuContent,
GhostContextMenuItem,
GhostContextMenuTrigger,
GhostListbox,
GhostListboxOption,
GhostToolbar,
type GhostListboxSelectionBehavior,
} from '@ghostvue/themes'
interface Message {
id: string
sender: string
subject: string
date: string
}
const messages = ref<Message[]>([
{
id: 'invoice-4821',
sender: 'Billing',
subject: 'Invoice 4821',
date: 'Nov 30',
},
{
id: 'nightly-build',
sender: 'Build bot',
subject: 'Nightly build passed',
date: 'Nov 29',
},
{
id: 'header-spacing',
sender: 'Design review',
subject: 'Header spacing',
date: 'Nov 28',
},
{
id: 'receipt-4790',
sender: 'Billing',
subject: 'Receipt 4790',
date: 'Nov 27',
},
{
id: 'ticket-311',
sender: 'Support',
subject: 'Ticket 311 resolved',
date: 'Nov 26',
},
])
const selected = ref<string[]>([])
const status = ref('')
// Touch has no Shift or Ctrl, so "Select" mode switches plain taps to toggle.
const selectMode = ref(false)
const behavior = computed<GhostListboxSelectionBehavior>(() =>
selectMode.value ? 'toggle' : 'replace',
)
const uid = useId()
// Range, Ctrl+A, and the keyboard context menu change several rows at once,
// which screen readers do not announce row by row; this count does.
const countText = computed(() => {
const count = selected.value.length
return count === 1
? '1 message selected'
: `${String(count)} messages selected`
})
// Actions read the selection. Removed ids leave the model in the same
// handler, so the selection never holds rows that no longer exist.
function act(verb: string): void {
const ids = new Set(selected.value)
if (ids.size === 0) return
messages.value = messages.value.filter((message) => !ids.has(message.id))
selected.value = []
status.value = `${verb} ${String(ids.size)} ${ids.size === 1 ? 'message' : 'messages'}.`
}
</script>
<template>
<div class="mail-multiple-example">
<h2 :id="`${uid}-heading`" class="mail-multiple-example__heading">
Triage
</h2>
<GhostToolbar label="Selection actions">
<GhostButton
size="sm"
variant="outline"
:disabled="selected.length === 0"
@click="act('Archived')"
>
Archive
</GhostButton>
<GhostButton
size="sm"
variant="outline"
:disabled="selected.length === 0"
@click="act('Deleted')"
>
Delete
</GhostButton>
<GhostButton
size="sm"
variant="ghost"
:aria-pressed="selectMode ? 'true' : 'false'"
@click="selectMode = !selectMode"
>
Select
</GhostButton>
</GhostToolbar>
<GhostContextMenu>
<GhostContextMenuTrigger as="div" focus-target="descendant">
<GhostListbox
v-model="selected"
multiple
class="mail-multiple-example__list"
:selection-behavior="behavior"
:aria-labelledby="`${uid}-heading`"
:aria-describedby="`${uid}-hint`"
>
<GhostListboxOption
v-for="message in messages"
:key="message.id"
:value="message.id"
:text-value="message.sender"
>
<span class="mail-multiple-example__row">
<span>
<span class="mail-multiple-example__sender">
{{ message.sender }}:
</span>
{{ message.subject }}
</span>
<span class="mail-multiple-example__date">
{{ message.date }}
</span>
</span>
</GhostListboxOption>
</GhostListbox>
</GhostContextMenuTrigger>
<GhostContextMenuContent>
<GhostContextMenuItem @select="act('Archived')">
Archive
</GhostContextMenuItem>
<GhostContextMenuItem @select="act('Deleted')">
Delete
</GhostContextMenuItem>
</GhostContextMenuContent>
</GhostContextMenu>
<p :id="`${uid}-hint`" class="mail-multiple-example__hint">
Shift+click selects a range and Ctrl+click (Cmd+click on macOS) adds a
row. Press Shift+F10 or the Menu key for actions.
</p>
<p role="status" class="mail-multiple-example__hint">
{{ countText }}. {{ status }}
</p>
</div>
</template>
<style scoped>
.mail-multiple-example {
display: grid;
gap: var(--ghost-space-gap-sm);
}
.mail-multiple-example__heading {
font-size: var(--ghost-type-size-md);
margin: 0;
}
.mail-multiple-example__list {
max-block-size: 18rem;
overflow: auto;
}
.mail-multiple-example__row {
display: flex;
gap: var(--ghost-space-gap-sm);
inline-size: 100%;
justify-content: space-between;
}
.mail-multiple-example__sender {
font-weight: var(--ghost-type-weight-medium);
}
.mail-multiple-example__date,
.mail-multiple-example__hint {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
}
.mail-multiple-example__hint {
margin: 0;
}
</style>
Themed multiple listbox with the default toggle behavior: click, tap, or Space adds and removes options.
Toppings
Selected: basil
<script setup lang="ts">
import { ref } from 'vue'
import { GhostListbox, GhostListboxOption } from '@ghostvue/themes'
const toppings = [
{ value: 'basil', label: 'Basil' },
{ value: 'mozzarella', label: 'Mozzarella' },
{ value: 'mushroom', label: 'Mushroom' },
{ value: 'olive', label: 'Olive' },
{ value: 'pepper', label: 'Roasted pepper' },
]
const selected = ref<string[]>(['basil'])
</script>
<template>
<div class="listbox-multiple-example">
<p id="toppings-label" class="listbox-multiple-example__label">Toppings</p>
<GhostListbox v-model="selected" multiple aria-labelledby="toppings-label">
<GhostListboxOption
v-for="topping in toppings"
:key="topping.value"
:value="topping.value"
>
{{ topping.label }}
</GhostListboxOption>
</GhostListbox>
<p class="listbox-multiple-example__summary">
Selected: {{ selected.join(', ') || 'none' }}
</p>
</div>
</template>
<style scoped>
.listbox-multiple-example {
display: grid;
gap: var(--ghost-space-gap-xs);
max-inline-size: 18rem;
}
.listbox-multiple-example__label {
font-weight: var(--ghost-type-weight-medium);
margin: 0;
}
.listbox-multiple-example__summary {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
margin: 0;
}
</style>
Themed listbox of saved views in labelled groups, with a disabled option skipped by the arrow keys.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostListbox,
GhostListboxGroup,
GhostListboxLabel,
GhostListboxOption,
} from '@ghostvue/themes'
const groups = [
{
label: 'Pinned',
views: [
{ value: 'my-issues', label: 'My open issues' },
{ value: 'review', label: 'Waiting for my review' },
],
},
{
label: 'Team',
views: [
{ value: 'triage', label: 'Needs triage' },
{ value: 'archived', label: 'Archived board', disabled: true },
{ value: 'release', label: 'Release blockers' },
],
},
]
const view = ref<string | undefined>('review')
</script>
<template>
<div class="listbox-groups-example">
<GhostListbox v-model="view" aria-label="Saved views">
<GhostListboxGroup v-for="group in groups" :key="group.label">
<GhostListboxLabel>{{ group.label }}</GhostListboxLabel>
<GhostListboxOption
v-for="item in group.views"
:key="item.value"
:value="item.value"
:disabled="item.disabled ?? false"
>
{{ item.label }}
</GhostListboxOption>
</GhostListboxGroup>
</GhostListbox>
</div>
</template>
<style scoped>
.listbox-groups-example {
max-inline-size: 18rem;
}
</style>
Themed horizontal listbox where ArrowLeft and ArrowRight follow reading direction, with a right-to-left switch.
Size: M
<script setup lang="ts">
import { ref } from 'vue'
import { GhostListbox, GhostListboxOption, GhostSwitch } from '@ghostvue/themes'
const sizes = ['XS', 'S', 'M', 'L', 'XL']
const size = ref<string | undefined>('M')
const rtl = ref(false)
</script>
<template>
<div class="listbox-horizontal-example">
<GhostSwitch v-model="rtl">Right-to-left</GhostSwitch>
<div :dir="rtl ? 'rtl' : 'ltr'">
<GhostListbox
v-model="size"
orientation="horizontal"
aria-label="Shirt size"
>
<GhostListboxOption v-for="item in sizes" :key="item" :value="item">
{{ item }}
</GhostListboxOption>
</GhostListbox>
</div>
<p class="listbox-horizontal-example__summary">Size: {{ size }}</p>
</div>
</template>
<style scoped>
.listbox-horizontal-example {
display: grid;
gap: var(--ghost-space-gap-sm);
justify-items: start;
}
.listbox-horizontal-example__summary {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
margin: 0;
}
</style>