Editor commands
Expose File, Edit, and View commands in a persistent desktop-style bar.
Components / Navigation
A persistent desktop-style command bar with managed top-level and nested menu focus.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add menubarImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import Menubar from './components/ui/menubar/Menubar.vue'
import MenubarContent from './components/ui/menubar/MenubarContent.vue'
import MenubarItem from './components/ui/menubar/MenubarItem.vue'
import MenubarMenu from './components/ui/menubar/MenubarMenu.vue'
import MenubarTrigger from './components/ui/menubar/MenubarTrigger.vue'
function run(action: { id: string }) {
console.log(action.id)
}
</script>
<template>
<Menubar>
<MenubarMenu value="file" @select="run">
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent aria-label="File commands">
<MenubarItem id="new" label="New document">New document</MenubarItem>
<MenubarItem id="open" label="Open document">Open document</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu value="edit" @select="run">
<MenubarTrigger>Edit</MenubarTrigger>
<MenubarContent aria-label="Edit commands">
<MenubarItem id="undo" label="Undo">Undo</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
</template>The arrow marks a trigger with menu content, and a flush triangle on the open menu points back to it across the standard 12px gap. The open menu stays visibly active. Click or use Left and Right to switch top-level menus; hover alone does not switch them. Add #prefix and #suffix content to menu items. Typeahead finds items, and Escape closes the menu.
Expose File, Edit, and View commands in a persistent desktop-style bar.
Group document operations without filling the main toolbar.
Handle selected item IDs in application code.
<script setup lang="ts">
import Menubar from './components/ui/menubar/Menubar.vue'
import MenubarContent from './components/ui/menubar/MenubarContent.vue'
import MenubarItem from './components/ui/menubar/MenubarItem.vue'
import MenubarMenu from './components/ui/menubar/MenubarMenu.vue'
import MenubarTrigger from './components/ui/menubar/MenubarTrigger.vue'
function run(action: { id: string }) {
console.log(action.id)
}
</script>
<template>
<Menubar>
<MenubarMenu value="file" @select="run">
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent aria-label="File commands">
<MenubarItem id="new" label="New document">New document</MenubarItem>
<MenubarItem id="open" label="Open document">Open document</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu value="edit" @select="run">
<MenubarTrigger>Edit</MenubarTrigger>
<MenubarContent aria-label="Edit commands">
<MenubarItem id="undo" label="Undo">Undo</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
</template>A single menu also works when a compact application needs one command group.
<script setup lang="ts">
import Menubar from './components/ui/menubar/Menubar.vue'
import MenubarContent from './components/ui/menubar/MenubarContent.vue'
import MenubarItem from './components/ui/menubar/MenubarItem.vue'
import MenubarMenu from './components/ui/menubar/MenubarMenu.vue'
import MenubarTrigger from './components/ui/menubar/MenubarTrigger.vue'
function select(action: { id: string }) {
console.log(action.id)
}
</script>
<template>
<Menubar>
<MenubarMenu value="view" @select="select">
<MenubarTrigger>View</MenubarTrigger>
<MenubarContent aria-label="View commands">
<MenubarItem id="zoom-in" label="Zoom in">Zoom in</MenubarItem>
<MenubarItem id="zoom-out" label="Zoom out">Zoom out</MenubarItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
modelValuemodel | string | undefined | Not set | Current value. Use v-model to keep it in sync with your page. |
defaultValueprop | string | undefined | Not set | Starting value when the parent does not control the value. |
dirprop | "ltr" | "rtl" | undefined | "ltr" | Set the text direction used for keyboard and layout behavior. |
update:modelValueevent | [value: string | undefined] | — | Requests a new model value from the parent. |
valueChangeevent | [value: string | undefined] | — | Emitted after this value or state changes. |
defaultslot | {} | Optional | Content shown inside Menubar. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
idprop | string | Required | Give the control an ID so a label or description can refer to it. |
labelprop | string | Required | Visible or accessible name for this item. |
checkedprop | boolean | undefined | Not set | Current checked state of this choice. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
destructiveprop | boolean | undefined | Not set | Show that an action has a potentially destructive result. |
shortcutprop | string | undefined | Not set | Keyboard shortcut displayed beside this action. |
defaultslot | {} | Optional | Content shown inside MenubarCheckboxItem. |
prefixslot | {} | Optional | Content shown before the main label or value. |
suffixslot | {} | Optional | Content shown after the main label or value. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarGroup. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarItem. |
prefixslot | {} | Optional | Content shown before the main label or value. |
suffixslot | {} | Optional | Content shown after the main label or value. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarLabel. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
valueprop | string | Required | Value represented by this control or option. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
selectevent | [action: DropdownMenuAction] | — | Emitted when the user selects an item. |
defaultslot | {} | Optional | Content shown inside MenubarMenu. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarRadioGroup. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
idprop | string | Required | Give the control an ID so a label or description can refer to it. |
valueprop | string | Required | Value represented by this control or option. |
labelprop | string | Required | Visible or accessible name for this item. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
shortcutprop | string | undefined | Not set | Keyboard shortcut displayed beside this action. |
defaultslot | {} | Optional | Content shown inside MenubarRadioItem. |
prefixslot | {} | Optional | Content shown before the main label or value. |
suffixslot | {} | Optional | Content shown after the main label or value. |
| Name | Type or signature | Default | What it does |
|---|
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarSub. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarSubContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarSubTrigger. |
prefixslot | {} | Optional | Content shown before the main label or value. |
suffixslot | {} | Optional | Content shown after the main label or value. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside MenubarTrigger. |
// packages/frameworks/vue/components/menubar/types.ts
export interface MenubarProps {
modelValue?: string
defaultValue?: string
dir?: 'ltr' | 'rtl'
}
export interface MenubarMenuProps {
value: string
disabled?: boolean
}