GhostMenubar reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Horizontal menubar with a single top-level Tab stop and support for nested action menus.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
as | Component | string | "div" | No | Declared prop `as`. |
dir | 'ltr' | 'rtl' | — | No | Declared prop `dir`. |
Emits
None declared.
Models
None declared.
Slots
| Name | Description |
|---|---|
default | Container content. |
Slot props: default
None declared.
Exposed members
| Name | Type | Description |
|---|---|---|
element | HTMLElement | null | Root element after mount; null before mount. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | Horizontal container for top-level menu triggers. |
CSS variables
None declared.
Accessibility
Role: menubar. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/menubar/.
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
menubar/basic
Headless menubar with items, checkbox, radio group, label, separator, and disabled item.
<script setup lang="ts">
import { ref } from 'vue'
import {
GhostMenubar,
GhostMenubarCheckboxItem,
GhostMenubarContent,
GhostMenubarItem,
GhostMenubarLabel,
GhostMenubarMenu,
GhostMenubarRadioGroup,
GhostMenubarRadioItem,
GhostMenubarSeparator,
GhostMenubarTrigger,
} from '@ghostvue/vue'
const showHidden = ref(false)
const sort = ref('name')
</script>
<template>
<GhostMenubar>
<GhostMenubarMenu>
<GhostMenubarTrigger>File</GhostMenubarTrigger>
<GhostMenubarContent class="app-menubar-menu" :offset="8">
<GhostMenubarLabel>File</GhostMenubarLabel>
<GhostMenubarSeparator decorative />
<GhostMenubarItem>New</GhostMenubarItem>
<GhostMenubarItem disabled>Archive (disabled)</GhostMenubarItem>
</GhostMenubarContent>
</GhostMenubarMenu>
<GhostMenubarMenu>
<GhostMenubarTrigger>Edit</GhostMenubarTrigger>
<GhostMenubarContent class="app-menubar-menu" :offset="8">
<GhostMenubarCheckboxItem v-model:checked="showHidden">
Show hidden files
</GhostMenubarCheckboxItem>
<GhostMenubarSeparator decorative />
<GhostMenubarRadioGroup v-model="sort">
<GhostMenubarRadioItem value="name"
>Sort by name</GhostMenubarRadioItem
>
<GhostMenubarRadioItem value="date"
>Sort by date</GhostMenubarRadioItem
>
</GhostMenubarRadioGroup>
</GhostMenubarContent>
</GhostMenubarMenu>
</GhostMenubar>
</template>
<style>
/*
* Headless GhostMenubar 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. */
.app-menubar-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;
}
.app-menubar-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. */
.app-menubar-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;
}
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-checked='true'] {
font-weight: 600;
}
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-checked='true']::before {
visibility: visible;
}
/* Radio rows show a dot instead of a check. */
.app-menubar-menu [role='menuitemradio']::before {
block-size: 0;
border: 0.2rem solid currentColor;
border-radius: 50%;
inline-size: 0;
transform: translateY(-50%);
}
.app-menubar-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. */
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
):focus {
background-color: var(--ghost-action-primary-bg, Highlight);
color: var(--ghost-action-primary-fg, HighlightText);
}
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-disabled='true'] {
color: var(--ghost-text-muted, GrayText);
cursor: not-allowed;
}
.app-menubar-menu [data-part='label'] {
color: var(--ghost-text-muted, GrayText);
font-size: 0.8125rem;
padding: 0.375rem 0.75rem 0.25rem 1.75rem;
}
.app-menubar-menu [data-part='separator'] {
border-block-start: 1px solid var(--ghost-border-default, GrayText);
margin-block: 0.25rem;
}
@media (forced-colors: active) {
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
):focus {
background-color: Highlight;
color: HighlightText;
forced-color-adjust: none;
}
.app-menubar-menu
:is(
[role='menuitem'],
[role='menuitemcheckbox'],
[role='menuitemradio']
)[aria-disabled='true'] {
color: GrayText;
}
}
</style>
menubar/themed
Create, duplicate, or export a document from a File, Edit, and View menubar; the document name and status line show each command.
<script setup lang="ts">
import { computed, ref } from 'vue'
import {
GhostButton,
GhostCard,
GhostMenubar,
GhostMenubarCheckboxItem,
GhostMenubarContent,
GhostMenubarItem,
GhostMenubarLabel,
GhostMenubarMenu,
GhostMenubarRadioGroup,
GhostMenubarRadioItem,
GhostMenubarSeparator,
GhostMenubarTrigger,
GhostSubmenu,
GhostSubmenuContent,
GhostSubmenuTrigger,
} from '@ghostvue/themes'
type LayoutMode = 'comfortable' | 'compact'
const wordWrap = ref(true)
const lineNumbers = ref(true)
const layout = ref<LayoutMode>('comfortable')
const documentName = ref('release-notes.md')
const lastAction = ref('Ready')
const statusSummary = computed(() => {
const flags = [
wordWrap.value ? 'Word wrap on' : 'Word wrap off',
lineNumbers.value ? 'Line numbers on' : 'Line numbers off',
layout.value === 'comfortable' ? 'Comfortable layout' : 'Compact layout',
].join(' · ')
return `${lastAction.value} — ${flags}`
})
function runAction(label: string): void {
lastAction.value = label
}
// File commands change the open document, so the result shows in the editor
// body as well as in the status line. Focus returns to the File trigger.
function newDraft(): void {
documentName.value = 'Untitled draft.md'
runAction('Created new draft')
}
function duplicateDocument(): void {
const source = documentName.value
documentName.value = source.replace(/(\.md)?$/, ' copy.md')
runAction(`Duplicated ${source}`)
}
function setLayout(value: string): void {
if (value === 'comfortable' || value === 'compact') {
layout.value = value
lastAction.value = `Layout: ${value}`
}
}
</script>
<template>
<GhostCard class="editor-shell">
<template #header>
<div class="editor-shell__bar">
<GhostMenubar class="editor-menubar" aria-label="Document actions">
<GhostMenubarMenu>
<GhostMenubarTrigger :as="GhostButton" variant="ghost" size="sm">
File
</GhostMenubarTrigger>
<GhostMenubarContent aria-label="File" :offset="6">
<GhostMenubarItem @select="newDraft">
<span class="menubar__indicator" aria-hidden="true" />
New draft
</GhostMenubarItem>
<GhostMenubarItem @select="duplicateDocument">
<span class="menubar__indicator" aria-hidden="true" />
Duplicate
</GhostMenubarItem>
<GhostMenubarSeparator decorative />
<GhostSubmenu>
<GhostSubmenuTrigger>Export</GhostSubmenuTrigger>
<GhostSubmenuContent>
<GhostMenubarItem @select="runAction('Exported PDF')">
PDF
</GhostMenubarItem>
<GhostSubmenu>
<GhostSubmenuTrigger>Text formats</GhostSubmenuTrigger>
<GhostSubmenuContent portal>
<GhostMenubarItem
@select="runAction('Exported Markdown')"
>
Markdown
</GhostMenubarItem>
<GhostMenubarItem
@select="runAction('Exported plain text')"
>
Plain text
</GhostMenubarItem>
</GhostSubmenuContent>
</GhostSubmenu>
</GhostSubmenuContent>
</GhostSubmenu>
<GhostMenubarItem disabled>
<span class="menubar__indicator" aria-hidden="true" />
Publish (read-only)
</GhostMenubarItem>
</GhostMenubarContent>
</GhostMenubarMenu>
<GhostMenubarMenu>
<GhostMenubarTrigger :as="GhostButton" variant="ghost" size="sm">
Edit
</GhostMenubarTrigger>
<GhostMenubarContent aria-label="Edit" :offset="6">
<GhostMenubarItem @select="runAction('Undid last change')">
<span class="menubar__indicator" aria-hidden="true" />
Undo
</GhostMenubarItem>
<GhostMenubarItem @select="runAction('Redid change')">
<span class="menubar__indicator" aria-hidden="true" />
Redo
</GhostMenubarItem>
<GhostMenubarSeparator decorative />
<GhostMenubarItem @select="runAction('Opened find & replace')">
<span class="menubar__indicator" aria-hidden="true" />
Find & replace
</GhostMenubarItem>
</GhostMenubarContent>
</GhostMenubarMenu>
<GhostMenubarMenu>
<GhostMenubarTrigger :as="GhostButton" variant="ghost" size="sm">
View
</GhostMenubarTrigger>
<GhostMenubarContent aria-label="View" :offset="6">
<GhostMenubarLabel>Editor</GhostMenubarLabel>
<GhostMenubarCheckboxItem v-model:checked="wordWrap">
<span class="menubar__indicator" aria-hidden="true">
{{ wordWrap ? '✓' : '' }}
</span>
Word wrap
</GhostMenubarCheckboxItem>
<GhostMenubarCheckboxItem v-model:checked="lineNumbers">
<span class="menubar__indicator" aria-hidden="true">
{{ lineNumbers ? '✓' : '' }}
</span>
Line numbers
</GhostMenubarCheckboxItem>
<GhostMenubarSeparator decorative />
<GhostMenubarLabel>Density</GhostMenubarLabel>
<GhostMenubarRadioGroup
:model-value="layout"
@update:model-value="setLayout"
>
<GhostMenubarRadioItem value="comfortable">
<span class="menubar__indicator" aria-hidden="true">
{{ layout === 'comfortable' ? '●' : '' }}
</span>
Comfortable
</GhostMenubarRadioItem>
<GhostMenubarRadioItem value="compact">
<span class="menubar__indicator" aria-hidden="true">
{{ layout === 'compact' ? '●' : '' }}
</span>
Compact
</GhostMenubarRadioItem>
</GhostMenubarRadioGroup>
</GhostMenubarContent>
</GhostMenubarMenu>
</GhostMenubar>
</div>
</template>
<div class="editor-shell__body">
<span class="editor-shell__doc">{{ documentName }}</span>
<span class="editor-shell__hint">
Use ArrowLeft / ArrowRight across menus, ArrowDown to open.
</span>
</div>
<template #footer>
<div class="editor-shell__status" role="status" aria-live="polite">
{{ statusSummary }}
</div>
</template>
</GhostCard>
</template>
<style scoped>
.editor-shell {
inline-size: 100%;
max-inline-size: 32rem;
}
.editor-shell__bar {
display: flex;
flex-wrap: wrap;
}
.editor-menubar {
display: flex;
flex-wrap: wrap;
gap: var(--ghost-space-gap-xs);
}
.editor-shell__body {
display: grid;
gap: var(--ghost-space-gap-xs);
}
.editor-shell__doc {
color: var(--ghost-surface-fg);
font-size: var(--ghost-type-size-sm);
font-weight: var(--ghost-type-weight-semibold);
}
.editor-shell__hint,
.editor-shell__status {
color: var(--ghost-text-muted);
font-size: var(--ghost-type-size-xs);
}
.menubar__indicator {
display: inline-block;
inline-size: 1em;
text-align: center;
}
</style>