Invoice 4821
From Billing · Nov 30
Your November invoice is ready to download.
GhostListbox is a visible list where one or more rows are the current selection and the user moves through the rows with the keyboard: a mail message list beside a reading pane, a list of files or saved views, or a picker panel that stays open on the page. It follows the WAI-ARIA APG listbox pattern: one Tab stop, arrow, Home / End, and typeahead movement, single or multiple selection with the APG multi-select keys, desktop-style pointer selection, and a supported route to a context menu on a row.
Import GhostListbox, GhostListboxOption, GhostListboxGroup, and GhostListboxLabel from @ghostvue/themes for styled rows. The advanced section uses the same interface from @ghostvue/vue.
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>
The inbox above imports from @ghostvue/themes. It uses selection-follows-focus, so Down Arrow, End, and typing a sender's first letter move the selection and the reading pane follows. Archive and Delete live in the toolbar above the list and in a context menu on the row: right-click a message, or focus it and press Shift+F10 or the Menu key. After a delete, focus moves to the next message.
<GhostToolbar label="Message actions">
<GhostButton :disabled="!selected" @click="archive(selected)">Archive</GhostButton>
</GhostToolbar>
<GhostContextMenu>
<GhostContextMenuTrigger as="div" focus-target="descendant">
<GhostListbox v-model="selected" aria-labelledby="inbox-heading" aria-describedby="inbox-hint">
<GhostListboxOption v-for="message in messages" :key="message.id" :value="message.id">
…
</GhostListboxOption>
</GhostListbox>
</GhostContextMenuTrigger>
<GhostContextMenuContent>
<GhostContextMenuItem @select="archive(selected)">Archive</GhostContextMenuItem>
</GhostContextMenuContent>
</GhostContextMenu>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>
multiple makes the model a string[]. With selection-behavior="replace", a plain click selects only that row as in a desktop mail client, Shift+click selects a range, and Ctrl+click (Cmd+click on macOS) adds or removes one row. Touch has no modifiers, so the Select button switches plain taps to the default toggle behavior. The polite status line announces the selection count, because range and select-all changes are not announced row by row.
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>
The default selection-behavior="toggle" adds or removes a row on click, tap, or Space, like a multiple GhostSelect. The model keeps selection order: a new value is appended, and a range or select-all appends the new values in rendered order.
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>
GhostListboxGroup renders role="group" named by the GhostListboxLabel inside it. Labels are not focusable. Disabled options are skipped by the arrow keys, typeahead, ranges, and Ctrl+A.
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>
orientation="horizontal" moves focus with Left Arrow and Right Arrow in reading order, flipped under dir="rtl".
| Need | Use |
|---|---|
| A value picked from a popup, or submitted with a form | GhostSelect (or GhostCombobox to filter by typing) |
| One choice from a few, always visible, inside a form | GhostRadioGroup |
| Several independent checkboxes in a form | GhostCheckboxGroup |
| Nested items with expand and collapse | GhostTree |
| Rows with cells, or buttons and inputs inside rows | GhostDataGrid |
| A focus-only composite with no selection | useRovingFocus |
The listbox has no name and renders no hidden inputs. Forms submit the model themselves or use the form controls above.
v-model is string | undefined. Clicking the selected option, or pressing Space on it, keeps it selected and emits nothing; clear the selection in code by setting undefined.v-model is string[], never undefined. The listbox never mutates the array you pass, emits a new array for every change, and tolerates frozen arrays.toggle behavior, and Ctrl+A keep values whose option is not mounted; a replacing gesture (a plain or Shift+click with replace, or opening the context menu on an unselected row) drops them, so an action never reaches rows the user cannot see. To make "delete removes from the selection" true, update the model in the same handler that removes the data.@keydown, @click, and @contextmenu listeners on the root or an option run first. Call preventDefault() to skip the listbox's handling, for example to open a message on Enter or delete it on Delete.Options cannot contain buttons, so row actions take two routes:
GhostContextMenuTrigger with focus-target="descendant". The wrapper is not a tab stop, the menu opens for the option under the pointer or the focused option, and focus returns to that option on close.When the menu opens on an option that is not selected, the selection becomes that option; on a selected option the whole selection is kept. So the menu always acts on the selection and always includes the row it was opened on. In multiple mode, opening it from the keyboard on an unselected row collapses a multi-row selection to that row; announce the new count in a live region, as the mail examples do. Disabled options, group labels, the list's padding, an empty list, and a disabled list do not open the menu.
A short hint such as "Press Shift+F10 or the Menu key for message actions" can be referenced with aria-describedby on the listbox. It is a supplement: screen readers do not reliably read a listbox description when focus lands on an option.
Keys act on the focused option. On macOS, Cmd takes the place of Ctrl in every Ctrl chord. Unlisted chords and keys that belong to an IME composition are left to the browser.
| Key | Single mode | Multiple mode |
|---|---|---|
| Tab / Shift+Tab | Enter or leave the list through its one tab stop. | Same. |
| Down Arrow / Up Arrow | Focus the next or previous enabled option. | Same; the selection does not change. |
| Home / End | Focus the first or last enabled option. | Same. |
| Printable characters | Typeahead on textValue (500 ms buffer). | Same. |
| Space | Select the focused option. | Toggle it and set the range anchor. |
| Enter | Select the focused option. | Not handled; use it for your own action. |
| Shift+Down Arrow / Up Arrow | Same as without Shift. | Move and toggle the newly focused option. |
| Shift+Space | Not handled. | Select from the anchor to the focused option. |
| Ctrl+Shift+Home / End | Not handled. | Select to the first or last option and focus it. |
| Ctrl+A | Not handled. | Select every enabled option, or deselect them all. |
| Shift+F10 / Menu | Open the row's context menu inside a descendant-mode trigger. | Same. |
| Escape | Not handled, so an enclosing dialog closes. | Same. |
With selection-follows-focus in single mode, arrows, Home / End, and typeahead also select. loop wraps the arrow keys.
A click or tap focuses the option without a visible ring and then:
| Gesture | Single | Multiple, toggle | Multiple, replace |
|---|---|---|---|
| Click or tap | Select it. | Toggle it. | Select only it. |
| Ctrl / Cmd+click | Select it. | Toggle it. | Toggle it. |
| Shift+click | Select it. | Add the range from the anchor. | Replace the selection with the range. |
Shift+click does not select page text. On macOS Ctrl+click is a secondary click and opens the context menu.
Before the user moves in the list, the tab stop is the first selected enabled option, else the first enabled option. An empty or disabled list is itself the tab stop, so Tab still reaches its name. When options are removed, the tab stop moves to the option that followed the removed one (even if the same update moved it), else the one before it; an option inserted in its place in the same update comes first. If the removed option had focus, focus moves too. Recovery never changes the selection.
focusOption(value) on a template ref moves the tab stop and focus to an option without selecting it, and returns false for a missing or disabled option.
Server HTML carries the roles, aria-selected from the initial model, and ids from useGhostId. The selected option (or the first option when nothing is selected) renders tabindex="0"; a disabled root renders it on the root. A stale model value or an empty list renders no stop until the page hydrates. Hydration does not move focus.
aria-label or aria-labelledby; a missing name logs a development warning.text-value to make typeahead match them.GhostDataGrid for rows with in-row controls.aria-selected. Announce bulk changes, such as "12 messages selected", in your own polite live region.GhostScrollArea around it, a height and overflow: auto. Keyboard movement keeps the focused option in view.For teams that bring their own design system, the same parts ship unstyled from @ghostvue/vue. Style them through data-part (listbox, option, group, label), aria-selected or data-state="checked", data-disabled, and :focus-visible.
Headless single-selection listbox with consumer CSS on the data-part and aria-selected hooks.
Deploying to us-east
<script setup lang="ts">
import { ref } from 'vue'
import { GhostListbox, GhostListboxOption } from '@ghostvue/vue'
const regions = [
{ value: 'us-east', label: 'US East' },
{ value: 'us-west', label: 'US West' },
{ value: 'eu-central', label: 'EU Central' },
{ value: 'ap-south', label: 'Asia Pacific South' },
]
const region = ref<string | undefined>('us-east')
</script>
<template>
<div class="listbox-basic-demo">
<GhostListbox
v-model="region"
class="listbox-basic-demo__list"
aria-label="Deploy region"
>
<GhostListboxOption
v-for="item in regions"
:key="item.value"
:value="item.value"
class="listbox-basic-demo__option"
>
{{ item.label }}
</GhostListboxOption>
</GhostListbox>
<p class="listbox-basic-demo__summary">Deploying to {{ region }}</p>
</div>
</template>
<style scoped>
.listbox-basic-demo {
display: grid;
gap: 0.5rem;
max-inline-size: 16rem;
}
.listbox-basic-demo__list {
border: 1px solid var(--ghost-border-default, CanvasText);
border-radius: 0.5rem;
padding: 0.25rem;
}
.listbox-basic-demo__option {
border-radius: 0.25rem;
cursor: default;
padding: 0.375rem 0.5rem;
}
.listbox-basic-demo__option[aria-selected='true'] {
background: var(--ghost-surface-muted-bg, Highlight);
font-weight: 600;
}
.listbox-basic-demo__option:focus-visible {
outline: 2px solid var(--ghost-focus-ring-color, Highlight);
outline-offset: -2px;
}
.listbox-basic-demo__summary {
margin: 0;
}
@media (forced-colors: active) {
.listbox-basic-demo__option[aria-selected='true'] {
background: Highlight;
color: HighlightText;
}
}
</style>
See the generated component references for props, emits, slots, exposed members, and styling hooks.
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostListboxElement | "div" | Host element. Options inside a ul / ol root use as="li"; groups are supported only with the default div. |
defaultValue | GhostListboxValueInput<Multiple> | — | Initial selection in uncontrolled mode. Copied at setup. |
disabled | boolean | false | Disables every option. The selection stays visible and unchanged. |
loop | boolean | false | Arrow keys wrap from the last option to the first and back. |
modelValue | GhostListboxValueInput<Multiple> | — | Controlled selection. undefined is uncontrolled. |
multiple | Multiple | — | Multiple selection (string[] model). Read once at setup. |
orientation | GhostListboxOrientation | "vertical" | Which arrow keys move focus. Horizontal arrows follow reading direction. |
selectionBehavior | GhostListboxSelectionBehavior | "toggle" | Multiple mode only: what a plain click or tap does. |
selectionFollowsFocus | boolean | false | Single mode only: arrow keys, Home / End, and typeahead also select the newly focused option. |
| Slot | Slot props | Description |
|---|---|---|
default | activeValue: string | undefined, selectedValues: readonly string[] | GhostListboxOption and GhostListboxGroup children. |
@ghostvue/themes adds no props, events, or slots to the headless GhostListbox API, which it forwards.
GhostListboxOption | Prop | Type | Default | Description |
|---|---|---|---|
as | string | "div" | Host element. Use li inside a ul / ol root. |
disabled | boolean | false | The option cannot be focused or selected. |
textValue | string | — | Text used for typeahead; defaults to the trimmed text content. |
value | string | Required | Identity of the option. Unique within the root; '' is unsupported. |
| Slot | Slot props | Description |
|---|---|---|
default | active: boolean, disabled: boolean, focused: boolean, selected: boolean | Option content; receives selected, disabled, active, and focused. |
GhostListboxGroup and GhostListboxLabel GhostListboxGroup takes as (default div) and renders role="group" labelled by its GhostListboxLabel. Groups cannot be nested and are supported only with the default div root.
See the GhostListbox specification.