Menubar
Arrange related action menus in a horizontal bar.
Demos
Size
Usage
vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Installation
Complete the shared installation. Copy Menubar.vue and index.ts into app/components/ui/menubar/.
app/components/ui/menubar/Menubar.vue
<script setup lang="ts">
import { AlertDialog as Primitive } from 'akaza-ui'
import { computed, useAttrs, useTemplateRef } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import {
alertDialogVariants,
resolveAlertDialogVariants,
type AlertDialogProps,
type AlertDialogSlots,
} from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<AlertDialogProps>(), {
as: undefined,
teleport: undefined,
transition: undefined,
duration: undefined,
title: undefined,
ariaLabel: undefined,
description: undefined,
ui: undefined,
modelValue: undefined,
})
defineSlots<AlertDialogSlots>()
const attrs = useAttrs()
const styles = computed(() => alertDialogVariants(resolveAlertDialogVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'content' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, width: _width, ...native } = props
return native
})
const primitive = useTemplateRef<InstanceType<typeof Primitive>>('primitive')
defineExpose({
get open() {
return primitive.value!.open
},
get close() {
return primitive.value!.close
},
get toggle() {
return primitive.value!.toggle
},
get titleId() {
return primitive.value!.titleId
},
get descriptionId() {
return primitive.value!.descriptionId
},
})
</script>
<template>
<component
:is="Primitive"
ref="primitive"
v-bind="{ ...primitiveProps, ...attrs }"
:ui="mergedUi"
>
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof AlertDialogSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Variants and defaults
| Prop | Values | Default |
|---|---|---|
size | xs, sm, md, lg, xl | sm |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | MenubarItem[] | required | Top-level menu items. Items with children open panels. |
loop | boolean | true | Left/right focus wraps. |
dir | "ltr" | "rtl" | "ltr" | Reverses horizontal arrow behavior for RTL. |
teleport | string | false | "body" | Popup target. Set false for inline panels; ancestor overflow and stacking then apply. |
disabled | boolean | false | Disables the menubar. |
closeOnSelect | boolean | true | Closes after normal item selection. |
radioValues | Record<string, string> | — | State for radio groups inside panels. |
ariaLabel | string | — | Accessible label. |
ariaLabelledby | string | — | Accessible label id. |
ui | MenubarUi | — | Classes for root, triggers, content, and menu parts. |
Slots
| Slot | Props | Description |
|---|---|---|
trigger | item, isOpen | Top-level trigger content. |
[item.slot] | Depends on item type | Per-item panel renderer. |
checkbox-item | item, checked | Shared checkbox item renderer. |
radio-item | item, checked | Shared radio item renderer. |
label | item | Shared label renderer. |
Events
| Event | Payload | Description |
|---|---|---|
open-change | (value: string | null, details) | Fired before active menu changes. |
select | (item, details) | Fired when an item is selected. |
check-change | (item, checked, details) | Fired when checkbox item changes. |
radio-change | (group, value, details) | Fired when radio item changes. |
update:radioValues | (values) | v-model event for radio state. |
Keyboard
Submenus use Menu's viewport collision positioning. Horizontal arrows follow dir even when a submenu flips visually. Opening a submenu does not switch the top-level menu.
Menubar panels join the shared floating-layer stack and teleport to body by default so ancestor clipping and stacking contexts do not trap them. Set --akaza-z-layer-base (default 1200) globally to change its base or set --akaza-z-menubar on the popup to override its z-index. Use ui.content for popup styles; descendant selectors from the menubar root do not cross Teleport. Nested panels share Menu's styling hooks.
| Key | Behavior |
|---|---|
ArrowRight / ArrowLeft | Move between top-level triggers. |
ArrowDown | Open active menu and focus first panel item. |
ArrowUp | Open active menu and focus last panel item. |
Enter / Space | Open a menu or activate a top-level command without children. |
ArrowUp / ArrowDown | Move within an open panel. |
Home / End | Focus first/last enabled top-level item. |
| Character keys | Typeahead across top-level items. |
Escape | Close the open panel and return focus to its trigger. |