Skip to content
Nana UI

Navigation

Menubar

An application-style menu bar — a horizontal row of nana-menubar-menu top-level menus (File, Edit, View…), each opening a dropdown of nana-menu-item rows. Implements the WAI-ARIA menubar pattern: roving tabindex across the triggers, arrow-key switching between menus (with the open panel following), hover-to-switch once a menu is open, and dismissal on outside click or Escape.

View .md Download

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add menubar --framework web-components
npx @nana-tec/ui add menubar --framework svelte

Lands in src/lib/components/ui/menubar/ as NanaMenubar.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/menubar";

Copied in with npx @nana-tec/ui add menubar? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<script lang="ts">
import { NanaMenubar, NanaMenubarItem, NanaMenubarMenu } from '$lib/components/ui/menubar';
</script>
<NanaMenubar label="Ledger">
<NanaMenubarMenu label="File">
<NanaMenubarItem onclick={newInvoice}>New invoice</NanaMenubarItem>
</NanaMenubarMenu>
</NanaMenubar>

One stop in the tab order: Left and Right move between menus, Home and End to the ends. Down, Enter or Space opens a menu at its first item, Up at its last. With a menu open, Left and Right open the neighbouring one and pointing at another trigger switches to it. Escape closes the menu and returns to its trigger.

<nana-menubar bordered>
<nana-menubar-menu label="File">
<nana-menu-item value="new" shortcut="⌘N">New</nana-menu-item>
<nana-menu-item value="open" shortcut="⌘O">Open</nana-menu-item>
</nana-menubar-menu>
</nana-menubar>

Properties

PropertyAttributeTypeDefaultDescription
borderedborderedbooleanfalseBordered shell — a self-contained app menu bar

Events

EventDescription
nana-selectBubbled from a chosen item (detail.value)

Slots

SlotDescription
(default)nana-menubar-menu children

CSS parts

PartDescription
::part(bar)The horizontal bar container

CSS custom properties

PropertyDescription
--nana-menubar-bgBar background
--nana-menubar-gapGap between top-level menus
--nana-menubar-paddingPadding around the bar
--nana-menubar-radiusCorner radius of the bar

The bar itself has almost no attributes — each top-level trigger is a nana-menubar-menu, which owns its own label, open and disabled.

NanaMenubar

PropType
labelstring
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>.

NanaMenubarMenu

PropType
labelrequiredstring
childrenSnippet