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.
Preview
Section titled “Preview”Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add menubar --framework web-componentsnpx @nana-tec/ui add menubar --framework svelteLands in src/lib/components/ui/menubar/ as NanaMenubar.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import
Section titled “Import”
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.
Basic usage
Section titled “Basic usage”<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
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
bordered | bordered | boolean | false | Bordered shell — a self-contained app menu bar |
Events
| Event | Description |
|---|---|
nana-select | Bubbled from a chosen item (detail.value) |
Slots
| Slot | Description |
|---|---|
(default) | nana-menubar-menu children |
CSS parts
| Part | Description |
|---|---|
::part(bar) | The horizontal bar container |
CSS custom properties
| Property | Description |
|---|---|
--nana-menubar-bg | Bar background |
--nana-menubar-gap | Gap between top-level menus |
--nana-menubar-padding | Padding around the bar |
--nana-menubar-radius | Corner 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
| Prop | Type |
|---|---|
label | string |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>.
NanaMenubarMenu
| Prop | Type |
|---|---|
labelrequired | string |
children | Snippet |