Launch briefs
3 active · 1 published
- Spring launch briefPublished
- Pricing page refreshDraft
- Onboarding email seriesDraft
GhostDropdownMenu is the floating actions menu for GHO-80 (WAI-ARIA APG Menu Button semantics, not dialog, tooltip, or native <select>).
Import the parts from @ghostvue/themes for the elevated menu surface and interactive item styling. Every preview before the advanced section uses those themed parts. To style the menu yourself, see Advanced: headless composition, which shows the headless @ghostvue/vue parts.
Brief list with a per-row actions menu: grouped edit, duplicate, and status items, a destructive Archive with undo, and focus that follows each outcome.
3 active · 1 published
<script setup lang="ts">
import { computed, nextTick, ref, useTemplateRef } from 'vue'
import {
GhostBadge,
GhostButton,
GhostCard,
GhostDropdownMenu,
GhostDropdownMenuContent,
GhostDropdownMenuGroup,
GhostDropdownMenuItem,
GhostDropdownMenuSeparator,
GhostDropdownMenuTrigger,
GhostInput,
} from '@ghostvue/themes'
type BriefStatus = 'draft' | 'published'
interface Brief {
id: string
title: string
owner: string
updated: string
status: BriefStatus
}
// Deterministic seed data: no clocks or random ids, so every render matches.
const records = ref<Brief[]>([
{
id: 'spring-launch',
title: 'Spring launch brief',
owner: 'Maya Chen',
updated: 'Nov 12',
status: 'published',
},
{
id: 'pricing-refresh',
title: 'Pricing page refresh',
owner: 'Jonas Weber',
updated: 'Nov 14',
status: 'draft',
},
{
id: 'onboarding-emails',
title: 'Onboarding email series',
owner: 'Priya Natarajan',
updated: 'Nov 18',
status: 'draft',
},
])
const root = useTemplateRef<HTMLElement>('root')
const status = ref('')
const editingId = ref<string | null>(null)
const draftTitle = ref('')
// Only the latest archive can be undone, at the position it left.
const lastArchived = ref<{ record: Brief; index: number } | null>(null)
let copies = 0
const summary = computed(() => {
const count = records.value.length
const published = records.value.filter(
(record) => record.status === 'published',
).length
return `${String(count)} active · ${String(published)} published`
})
/*
* A menu item closes the menu, and the menu returns focus to its trigger in
* the same update. Waiting one tick lets that finish before focus moves to the
* target the action calls for (the title field, or a neighbouring row when
* the row that owned the trigger is gone).
*/
async function focusAfterUpdate(selector: string): Promise<void> {
await nextTick()
root.value?.querySelector<HTMLElement>(selector)?.focus()
}
function triggerSelector(id: string): string {
return `[data-record-trigger="${id}"]`
}
function startEdit(record: Brief): void {
editingId.value = record.id
draftTitle.value = record.title
status.value = ''
void focusAfterUpdate('[data-record-title-input]')
}
function finishEdit(record: Brief, save: boolean): void {
const title = draftTitle.value.trim()
if (save && title !== '' && title !== record.title) {
record.title = title
record.updated = 'Just now'
status.value = `Renamed to “${title}”.`
} else if (save && title === '') {
// An empty title is not saved; keep editing so the user can fix it.
status.value = 'Enter a title to save.'
return
}
editingId.value = null
void focusAfterUpdate(triggerSelector(record.id))
}
function duplicate(record: Brief): void {
copies += 1
const index = records.value.indexOf(record)
records.value.splice(index + 1, 0, {
...record,
id: `${record.id}-copy-${String(copies)}`,
title: `${record.title} (copy)`,
updated: 'Just now',
status: 'draft',
})
status.value = `Duplicated “${record.title}” as a draft.`
}
function toggleStatus(record: Brief): void {
record.status = record.status === 'draft' ? 'published' : 'draft'
record.updated = 'Just now'
status.value =
record.status === 'published'
? `Published “${record.title}”.`
: `Moved “${record.title}” back to drafts.`
}
function archive(record: Brief): void {
const index = records.value.indexOf(record)
if (index === -1) return
records.value.splice(index, 1)
lastArchived.value = { record, index }
if (editingId.value === record.id) editingId.value = null
status.value = `Archived “${record.title}”.`
// The trigger left with its row: focus the row that took its place, the one
// before it, or Undo when the list is empty.
const next = records.value[index] ?? records.value[index - 1]
void focusAfterUpdate(next ? triggerSelector(next.id) : '[data-record-undo]')
}
function undoArchive(): void {
const archived = lastArchived.value
if (!archived) return
records.value.splice(
Math.min(archived.index, records.value.length),
0,
archived.record,
)
lastArchived.value = null
status.value = `Restored “${archived.record.title}”.`
void focusAfterUpdate(triggerSelector(archived.record.id))
}
</script>
<template>
<div ref="root" class="briefs">
<GhostCard>
<template #header>
<!--
The heading has no id: VitePress builds the page outline from
headings with ids, and this one belongs to the demo, not the page.
-->
<div class="briefs__header">
<h2 class="briefs__title">Launch briefs</h2>
<p class="briefs__summary">{{ summary }}</p>
</div>
</template>
<ul
v-if="records.length > 0"
class="briefs__list"
aria-label="Launch briefs"
>
<li v-for="record in records" :key="record.id" class="briefs__row">
<form
v-if="editingId === record.id"
class="briefs__edit"
@submit.prevent="finishEdit(record, true)"
@keydown.esc.stop="finishEdit(record, false)"
>
<div class="briefs__edit-field">
<GhostInput
v-model="draftTitle"
aria-label="Brief title"
name="title"
autocomplete="off"
size="sm"
block
data-record-title-input
/>
</div>
<div class="briefs__edit-actions">
<GhostButton
variant="ghost"
tone="neutral"
size="sm"
@click="finishEdit(record, false)"
>
Cancel
</GhostButton>
<GhostButton type="submit" size="sm">Save</GhostButton>
</div>
</form>
<template v-else>
<div class="briefs__record">
<span class="briefs__name">{{ record.title }}</span>
<span class="briefs__meta">
{{ record.owner }} · Updated {{ record.updated }}
</span>
</div>
<span class="briefs__badge">
<GhostBadge
:tone="record.status === 'published' ? 'accent' : 'neutral'"
>
{{ record.status === 'published' ? 'Published' : 'Draft' }}
</GhostBadge>
</span>
<GhostDropdownMenu>
<!-- Icon-only, so the accessible name carries the record title. -->
<GhostDropdownMenuTrigger
:as="GhostButton"
variant="ghost"
tone="neutral"
size="sm"
icon-only
:aria-label="`Actions for ${record.title}`"
:data-record-trigger="record.id"
>
<svg
data-part="icon"
aria-hidden="true"
viewBox="0 0 16 16"
width="16"
height="16"
>
<circle cx="3" cy="8" r="1.25" fill="currentColor" />
<circle cx="8" cy="8" r="1.25" fill="currentColor" />
<circle cx="13" cy="8" r="1.25" fill="currentColor" />
</svg>
</GhostDropdownMenuTrigger>
<!--
bottom-end keeps the panel under the trigger at the row's end;
flip and shift (on by default) keep it inside the viewport when
the row sits near the bottom or the inline edge.
-->
<GhostDropdownMenuContent
class="record-menu"
placement="bottom-end"
:offset="4"
>
<GhostDropdownMenuGroup aria-label="Edit">
<GhostDropdownMenuItem @select="startEdit(record)">
<svg
class="record-menu__icon"
aria-hidden="true"
viewBox="0 0 16 16"
>
<path d="M10.5 3l2.5 2.5L6 12.5H3.5V10z" />
</svg>
Edit title
</GhostDropdownMenuItem>
<GhostDropdownMenuItem @select="duplicate(record)">
<svg
class="record-menu__icon"
aria-hidden="true"
viewBox="0 0 16 16"
>
<path d="M5.5 5.5h7v7h-7z M3.5 10.5v-7h7" />
</svg>
Duplicate
</GhostDropdownMenuItem>
</GhostDropdownMenuGroup>
<GhostDropdownMenuSeparator />
<GhostDropdownMenuGroup aria-label="Status">
<GhostDropdownMenuItem @select="toggleStatus(record)">
<svg
class="record-menu__icon"
aria-hidden="true"
viewBox="0 0 16 16"
>
<path
v-if="record.status === 'draft'"
d="M8 11V3M4.5 6.5L8 3l3.5 3.5M3 13h10"
/>
<path v-else d="M3 4h10M3 8h10M3 12h6" />
</svg>
{{
record.status === 'draft' ? 'Publish' : 'Move to drafts'
}}
</GhostDropdownMenuItem>
</GhostDropdownMenuGroup>
<GhostDropdownMenuSeparator />
<!-- Destructive: set apart last, in the danger text color. -->
<GhostDropdownMenuItem
class="record-menu__danger"
@select="archive(record)"
>
<svg
class="record-menu__icon"
aria-hidden="true"
viewBox="0 0 16 16"
>
<path d="M2.5 3.5h11v3h-11z M3.5 6.5v6h9v-6 M6.5 9h3" />
</svg>
Archive
</GhostDropdownMenuItem>
</GhostDropdownMenuContent>
</GhostDropdownMenu>
</template>
</li>
</ul>
<p v-else class="briefs__empty">No active briefs.</p>
<template #footer>
<div class="briefs__footer">
<p class="briefs__status" role="status">{{ status }}</p>
<GhostButton
v-if="lastArchived"
variant="outline"
tone="neutral"
size="sm"
data-record-undo
@click="undoArchive"
>
Undo archive
</GhostButton>
</div>
</template>
</GhostCard>
</div>
</template>
<style scoped>
/* The card owns its width and shrinks with the preview on phones. */
.briefs {
max-inline-size: 36rem;
}
.briefs__header {
display: grid;
gap: var(--ghost-space-gap-xs);
min-inline-size: 0;
}
/* Native text picks up docs prose styles, so each element resets its own. */
.briefs__title {
border: 0;
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;
padding: 0;
}
.briefs__summary,
.briefs__status,
.briefs__empty {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-snug);
margin: 0;
}
.briefs__list {
display: grid;
list-style: none;
margin: 0;
padding: 0;
}
/*
* Title and meta take the free space; the badge and the trigger keep their
* size at the row's end. Below about 22rem the badge drops under the title so
* the trigger never leaves the row.
*/
.briefs__row {
align-items: center;
border-block-start: var(--ghost-border-hairline-width) solid
var(--ghost-border-default);
column-gap: var(--ghost-space-gap-md);
display: grid;
grid-template-areas:
'record trigger'
'badge trigger';
grid-template-columns: minmax(0, 1fr) auto;
margin: 0;
padding-block: var(--ghost-space-stack-sm);
row-gap: var(--ghost-space-gap-xs);
}
.briefs__row:first-child {
border-block-start: 0;
}
.briefs__record {
display: grid;
gap: var(--ghost-space-gap-xs);
grid-area: record;
min-inline-size: 0;
}
.briefs__badge {
display: flex;
grid-area: badge;
justify-content: flex-start;
}
.briefs__row > :deep([data-part='trigger']) {
grid-area: trigger;
}
@container ghost-demo (min-width: 22rem) {
.briefs__row {
grid-template-areas: 'record badge trigger';
grid-template-columns: minmax(0, 1fr) auto auto;
}
.briefs__badge {
justify-content: flex-end;
}
}
.briefs__name {
color: var(--ghost-text-default);
font-size: var(--ghost-type-size-sm);
font-weight: var(--ghost-type-weight-medium);
line-height: var(--ghost-type-line-snug);
overflow-wrap: anywhere;
}
.briefs__meta {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-xs);
line-height: var(--ghost-type-line-snug);
overflow-wrap: anywhere;
}
.briefs__edit {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm);
grid-column: 1 / -1;
margin: 0;
}
.briefs__edit-field {
flex: 1 1 12rem;
min-inline-size: 0;
}
.briefs__edit-actions {
display: flex;
gap: var(--ghost-space-gap-sm);
margin-inline-start: auto;
}
.briefs__footer {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm) var(--ghost-space-gap-md);
justify-content: flex-end;
}
.briefs__status {
flex: 1 1 auto;
}
.record-menu__icon {
block-size: 1rem;
fill: none;
flex: none;
inline-size: 1rem;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.5;
}
</style>
<style>
/* Keep the entire portaled surface opaque as soon as the menu opens so
* Archive keeps its danger-text contrast against the menu background.
* The theme supplies the scale entrance only when motion is enabled. */
.record-menu[data-state='open'] {
transition-property: scale;
}
/*
* Unscoped on purpose: the class lands on a menu item component's root inside
* a body portal, where a scoped attribute is not guaranteed. The destructive
* action keeps the theme's item geometry and focus ring and changes only
* color, so hover and focus never shift layout.
*/
.record-menu__danger {
color: var(--ghost-text-danger);
}
.record-menu__danger:hover,
.record-menu__danger:focus-visible {
background-color: var(--ghost-status-danger-bg);
color: var(--ghost-status-danger-fg);
}
</style>
Every part in this example comes from @ghostvue/themes. Focus a row's Actions button and press Enter, Space, or ArrowDown to open its menu on the first item (ArrowUp opens it on the last). Move with the arrow keys and press Enter to run a command.
Each brief has an icon-only Actions trigger whose accessible name includes the brief title. The menu groups Edit title and Duplicate, then the status action, and sets Archive apart after a separator in the danger text color. Every action changes the list and is announced in the role="status" line. Focus follows the outcome: Edit title moves focus to the title field, Save, Cancel, and Escape return it to the row's trigger, and Archive moves it to the next row's trigger (or Undo archive when the list is empty) because the trigger that opened the menu has gone. The panel opens at bottom-end under the trigger; flip and shift keep it inside the viewport when a row sits near the bottom or the inline edge. Below about 22rem the status badge moves under the title so the trigger stays on the row. The menu surface is fully opaque from the first frame so Archive keeps its contrast while the panel opens. It scales into place with normal motion and opens immediately when reduced motion is requested.
Open a portaled submenu to choose an export format and include report notes.
Choose a format to export this report.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostButton,
GhostDropdownMenu,
GhostDropdownMenuCheckboxItem,
GhostDropdownMenuContent,
GhostDropdownMenuItem,
GhostDropdownMenuTrigger,
GhostSubmenu,
GhostSubmenuContent,
GhostSubmenuTrigger,
} from '@ghostvue/themes'
const includeNotes = ref(false)
const message = ref('Choose a format to export this report.')
function exportReport(format: string): void {
message.value = `Prepared ${format}${includeNotes.value ? ' with notes' : ''}.`
}
</script>
<template>
<div>
<GhostDropdownMenu>
<GhostDropdownMenuTrigger
:as="GhostButton"
variant="outline"
tone="neutral"
>
Report actions
</GhostDropdownMenuTrigger>
<GhostDropdownMenuContent aria-label="Report actions">
<GhostDropdownMenuItem @select="message = 'Report copied.'">
Copy report
</GhostDropdownMenuItem>
<GhostSubmenu>
<GhostSubmenuTrigger>Export</GhostSubmenuTrigger>
<GhostSubmenuContent portal>
<GhostDropdownMenuCheckboxItem v-model:checked="includeNotes">
Include notes
</GhostDropdownMenuCheckboxItem>
<GhostDropdownMenuItem @select="exportReport('PDF')">
PDF
</GhostDropdownMenuItem>
<GhostDropdownMenuItem @select="exportReport('CSV')">
CSV
</GhostDropdownMenuItem>
</GhostSubmenuContent>
</GhostSubmenu>
</GhostDropdownMenuContent>
</GhostDropdownMenu>
<p role="status">{{ message }}</p>
</div>
</template>
Place GhostSubmenu inside the menu content and give GhostSubmenuTrigger a visible label. The child uses ordinary dropdown items, including toggleable checkboxes and radio items. Use portal on GhostSubmenuContent when an ancestor would clip the child. The accessible name and focus behavior still follow the trigger with a custom portalTo.
Enter, Space, or the inline-end arrow opens a child and focuses its first enabled item. The inline-start arrow or Escape closes that level and returns focus to its trigger. Tab and Shift+Tab close the branch and continue from the dropdown button. The arrows reverse in RTL.
Bind v-model:open on GhostSubmenu to control visibility. If a controlled child declines to close, opening a sibling leaves that branch in place.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen | boolean | false | Initially opens the child in uncontrolled mode. |
open | boolean | — | Controlled request for the child to open. |
| Slot | Slot props | Description |
|---|---|---|
default | — | Primary content. |
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Excludes this trigger from roving focus, typeahead, and activation. |
| Slot | Slot props | Description |
|---|---|---|
default | — | Primary content. |
| Prop | Type | Default | Description |
|---|---|---|---|
portal | boolean | false | Renders the child via a Vue teleport. |
portalTo | GhostPortalTarget | "body" | Destination for a portaled child menu. |
| Slot | Slot props | Description |
|---|---|---|
default | — | Primary content. |
Inbox toolbar view menu with checkbox and radio items, visible check indicators, and a reset action on the elevation-3 surface.
<script setup lang="ts">
import { computed, ref, useId } from 'vue'
import {
GhostButton,
GhostDropdownMenu,
GhostDropdownMenuCheckboxItem,
GhostDropdownMenuContent,
GhostDropdownMenuGroup,
GhostDropdownMenuItem,
GhostDropdownMenuLabel,
GhostDropdownMenuRadioGroup,
GhostDropdownMenuRadioItem,
GhostDropdownMenuSeparator,
GhostDropdownMenuTrigger,
} from '@ghostvue/themes'
type Sort = 'newest' | 'oldest' | 'sender'
const defaults = { unreadFirst: true, previews: true, sort: 'newest' } as const
const unreadFirst = ref<boolean>(defaults.unreadFirst)
const previews = ref<boolean>(defaults.previews)
const sort = ref<Sort>(defaults.sort)
const sortOptions: readonly { value: Sort; label: string }[] = [
{ value: 'newest', label: 'Newest first' },
{ value: 'oldest', label: 'Oldest first' },
{ value: 'sender', label: 'Sender A–Z' },
]
const showLabelId = useId()
const sortLabelId = useId()
const summary = computed(() =>
[
sortOptions.find((option) => option.value === sort.value)?.label,
unreadFirst.value ? 'unread on top' : null,
previews.value ? 'previews on' : 'previews off',
]
.filter(Boolean)
.join(' · '),
)
// The radio group emits plain strings; accept only the options listed above.
function setSort(value: string): void {
const option = sortOptions.find((candidate) => candidate.value === value)
if (option) sort.value = option.value
}
function resetView(): void {
unreadFirst.value = defaults.unreadFirst
previews.value = defaults.previews
sort.value = defaults.sort
}
</script>
<template>
<div class="inbox-bar">
<div class="inbox-bar__summary">
<span class="inbox-bar__title">Inbox</span>
<span class="inbox-bar__meta">{{ summary }}</span>
</div>
<GhostDropdownMenu>
<GhostDropdownMenuTrigger
:as="GhostButton"
variant="outline"
tone="neutral"
>
View
</GhostDropdownMenuTrigger>
<GhostDropdownMenuContent placement="bottom-end" :offset="4">
<GhostDropdownMenuGroup :aria-labelledby="showLabelId">
<GhostDropdownMenuLabel :id="showLabelId"
>Show</GhostDropdownMenuLabel
>
<!--
The theme does not draw a check mark, so each item renders its own
indicator. aria-checked already carries the state; the glyph is
hidden from assistive technology.
-->
<GhostDropdownMenuCheckboxItem v-model:checked="unreadFirst">
<span class="view-menu__check" aria-hidden="true">
{{ unreadFirst ? '✓' : '' }}
</span>
Unread on top
</GhostDropdownMenuCheckboxItem>
<GhostDropdownMenuCheckboxItem v-model:checked="previews">
<span class="view-menu__check" aria-hidden="true">
{{ previews ? '✓' : '' }}
</span>
Message previews
</GhostDropdownMenuCheckboxItem>
</GhostDropdownMenuGroup>
<GhostDropdownMenuSeparator />
<GhostDropdownMenuLabel :id="sortLabelId"
>Sort by</GhostDropdownMenuLabel
>
<GhostDropdownMenuRadioGroup
:model-value="sort"
:aria-labelledby="sortLabelId"
@update:model-value="setSort"
>
<GhostDropdownMenuRadioItem
v-for="option in sortOptions"
:key="option.value"
:value="option.value"
>
<span class="view-menu__check" aria-hidden="true">
{{ sort === option.value ? '●' : '' }}
</span>
{{ option.label }}
</GhostDropdownMenuRadioItem>
</GhostDropdownMenuRadioGroup>
<GhostDropdownMenuSeparator />
<GhostDropdownMenuItem @select="resetView">
<span class="view-menu__check" aria-hidden="true" />
Reset view
</GhostDropdownMenuItem>
</GhostDropdownMenuContent>
</GhostDropdownMenu>
</div>
</template>
<style scoped>
/* The summary takes the free space; the View trigger stays at the end. */
.inbox-bar {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-sm) var(--ghost-space-gap-md);
justify-content: space-between;
max-inline-size: 36rem;
}
.inbox-bar__summary {
display: grid;
flex: 1 1 12rem;
gap: var(--ghost-space-gap-xs);
min-inline-size: 0;
}
.inbox-bar__title {
color: var(--ghost-text-default);
font-size: var(--ghost-type-size-md);
font-weight: var(--ghost-type-weight-semibold);
line-height: var(--ghost-type-line-snug);
}
.inbox-bar__meta {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-sm);
line-height: var(--ghost-type-line-normal);
}
/* A fixed-width slot keeps labels aligned whether or not an item is checked. */
.view-menu__check {
flex: none;
inline-size: 1em;
text-align: center;
}
</style>
The inbox View menu changes how the list above it reads. It labels its checkbox group and radio group with GhostDropdownMenuLabel through aria-labelledby. Checkbox items toggle without closing, and the summary line updates as you go. Choosing a sort order or Reset view closes the menu and returns focus to View. The theme does not draw a check mark, so the example renders its own aria-hidden indicator in a fixed-width slot; aria-checked carries the state for assistive technology.
Checkbox item model
GhostDropdownMenuCheckboxItem binds its state with v-model:checked or plain v-model. Both names stay in sync; if you bind both, checked decides what the item shows.
Importing from @ghostvue/themes loads default.css, styling .ghost-dropdown-menu-content with elevation-3 surface tokens and [data-part="item"], checkbox, radio, label, and separator hooks inside the panel. The themed GhostDropdownMenuContent sets data-themed so portaled menus pick up tokens outside a .ghost-theme host.
Teams that bring their own design system can import the same parts from @ghostvue/vue. They keep the menu behavior and paint nothing, so the example brings its own consumer CSS for the panel and item states.
Headless menu button with items, checkbox, radio group, label, separator, and disabled item.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostDropdownMenu,
GhostDropdownMenuCheckboxItem,
GhostDropdownMenuContent,
GhostDropdownMenuItem,
GhostDropdownMenuLabel,
GhostDropdownMenuRadioGroup,
GhostDropdownMenuRadioItem,
GhostDropdownMenuSeparator,
GhostDropdownMenuTrigger,
} from '@ghostvue/vue'
const showHidden = ref(false)
const sort = ref('name')
</script>
<template>
<GhostDropdownMenu>
<GhostDropdownMenuTrigger>File actions</GhostDropdownMenuTrigger>
<GhostDropdownMenuContent
class="file-actions-menu"
:offset="8"
placement="bottom-start"
>
<GhostDropdownMenuLabel>Actions</GhostDropdownMenuLabel>
<GhostDropdownMenuSeparator decorative />
<GhostDropdownMenuItem>Edit</GhostDropdownMenuItem>
<GhostDropdownMenuItem disabled>Archive (disabled)</GhostDropdownMenuItem>
<GhostDropdownMenuSeparator decorative />
<GhostDropdownMenuCheckboxItem v-model:checked="showHidden">
Show hidden files
</GhostDropdownMenuCheckboxItem>
<GhostDropdownMenuSeparator decorative />
<GhostDropdownMenuRadioGroup v-model="sort">
<GhostDropdownMenuRadioItem value="name">
Sort by name
</GhostDropdownMenuRadioItem>
<GhostDropdownMenuRadioItem value="date">
Sort by date
</GhostDropdownMenuRadioItem>
</GhostDropdownMenuRadioGroup>
</GhostDropdownMenuContent>
</GhostDropdownMenu>
</template>
<style>
/*
* Headless GhostDropdownMenu ships behavior and positioning only, so this
* sample brings its own consumer CSS. It is unscoped on purpose so the block
* can be copied into an app stylesheet as is, and the prefix keeps the
* classes from colliding with page styles.
*
* Colors read GhostVue semantic tokens when a theme is loaded and fall back
* to CSS system colors, which follow light and dark on their own. Items keep
* fixed geometry: highlight, hover, checked and disabled states only change
* color or a mark's visibility, so the menu never shifts. The highlight
* follows focus, which roves through the items. Nothing animates, so reduced
* motion needs no override.
*/
/* An opaque, layered panel above page content. */
.file-actions-menu {
background-color: var(--ghost-elevation-3-bg, Canvas);
border: 1px solid var(--ghost-elevation-3-border, GrayText);
border-radius: var(--ghost-radius-md, 0.375rem);
box-shadow: var(--ghost-elevation-3-shadow, 0 0.5rem 1.5rem rgb(0 0 0 / 20%));
box-sizing: border-box;
color: var(--ghost-surface-fg, CanvasText);
max-block-size: min(18rem, calc(100dvh - 2rem));
max-inline-size: calc(100vw - 2rem);
min-inline-size: 11rem;
overflow: auto;
padding: 0.25rem;
z-index: 50;
}
.file-actions-menu
:is([role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio']) {
border-radius: var(--ghost-radius-sm, 0.25rem);
cursor: default;
/* A transparent outline turns into a visible ring under forced colors. */
outline: 2px solid transparent;
outline-offset: -2px;
padding: 0.375rem 0.75rem 0.375rem 1.75rem;
position: relative;
}
/* Check mark slot, shown only on the checked row. */
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)::before {
block-size: 0.55rem;
border-block-end: 2px solid currentColor;
border-inline-end: 2px solid currentColor;
content: '';
inline-size: 0.3rem;
inset-block-start: 50%;
inset-inline-start: 0.7rem;
position: absolute;
transform: translateY(-65%) rotate(45deg);
visibility: hidden;
}
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-checked='true'] {
font-weight: 600;
}
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-checked='true']::before {
visibility: visible;
}
/* Radio rows show a dot instead of a check. */
.file-actions-menu [role='menuitemradio']::before {
block-size: 0;
border: 0.2rem solid currentColor;
border-radius: 50%;
inline-size: 0;
transform: translateY(-50%);
}
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
):hover:not(
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-disabled='true']
) {
background-color: var(--ghost-surface-muted-bg, Canvas);
}
/* Keyboard highlight. */
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
):focus {
background-color: var(--ghost-action-primary-bg, Highlight);
color: var(--ghost-action-primary-fg, HighlightText);
}
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-disabled='true'] {
color: var(--ghost-text-muted, GrayText);
cursor: not-allowed;
}
.file-actions-menu [data-part='label'] {
color: var(--ghost-text-muted, GrayText);
font-size: 0.8125rem;
padding: 0.375rem 0.75rem 0.25rem 1.75rem;
}
.file-actions-menu [data-part='separator'] {
border-block-start: 1px solid var(--ghost-border-default, GrayText);
margin-block: 0.25rem;
}
@media (forced-colors: active) {
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
):focus {
background-color: Highlight;
color: HighlightText;
forced-color-adjust: none;
}
.file-actions-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-disabled='true'] {
color: GrayText;
}
}
</style>
The headless GhostDropdownMenu owns open via useControllableState, assigns deterministic IDs via useGhostId, positions the panel with useFloating, renders through GhostPortal by default, unmounts content with v-if when closed, closes on Escape and outside pointerdown through useDismissableLayer, restores focus to the trigger on close via useFocusScope, and delegates item roving, typeahead, and activation keys to useGhostMenuCollection.
See the generated component references for props, emits, slots, exposed members, styling hooks, CSS variables, and executable examples.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen | boolean | false | Declared prop defaultOpen. |
open | boolean | — | Declared prop open. |
| Slot | Slot props | Description |
|---|---|---|
default | close: () => void, open: boolean | Primary content. |
@ghostvue/themes adds no props, events, or slots to the headless GhostDropdownMenu API, which it forwards.
GhostDropdownMenu (root) Emits update:open with (open: boolean). The default slot receives { open: boolean, close: () => void }.
GhostDropdownMenuTrigger Sets type="button" (when as="button"), aria-haspopup="menu", aria-expanded, aria-controls, data-part="trigger", and data-state="open" | "closed". ArrowDown / ArrowUp opens the menu and focuses the first or last item. Exposes { element, focus, blur }.
GhostDropdownMenuContent Keeps visibility: hidden until useFloating().isPositioned resolves. Sets role="menu", tabindex="-1", data-part="content", and data-state. Exposes { element, focus, blur }.
GhostDropdownMenuItem — role="menuitem"; emits select with the activating event. The menu closes unless the handler calls event.preventDefault().GhostDropdownMenuCheckboxItem — role="menuitemcheckbox" with v-model:checked or plain v-model; toggles without closing.GhostDropdownMenuRadioGroup / GhostDropdownMenuRadioItem — menuitemradio collection with v-model; selecting a radio emits (value, event) and closes unless event.preventDefault().GhostDropdownMenuLabel, GhostDropdownMenuSeparator, GhostDropdownMenuGroup — structural parts with data-part hooks only (no roving focus).aria-haspopup="menu"; content uses role="menu" with roving tabindex="-1" items (not a dialog or listbox).Home / End jump; typeahead focuses the next match; Enter / Space activate; checkbox items toggle on Space without dismissing; Escape closes and returns focus to the trigger. Keys owned by an active IME composition are left to the input method.Escape use useDismissableLayer with the trigger ignored so trigger clicks toggle cleanly.See GhostDropdownMenu specification and ADR 0011.