# AppMenuBar

> The window's application menu bar, with access keys, accelerators and submenus; what app.menuBar draws.

A menu bar drawn by the app, in the theme: the same on every system, in a framed or
frameless window, or inside a `TitleBar`. Arrow keys move along the bar and through a
menu, Enter/Space choose, Escape closes; menus open on click and follow the pointer
while one is open, like a system menu bar. `app.menuBar(items)` places one at the top
of the window (after a `TitleBar`) and adds Alt access keys, F10 and accelerators.

- Category: [Navigation](https://tarve.dev/docs.md#navigation)
- Import: `import { AppMenuBar } from "@tarve/core";`
- Props type: `AppMenuBarProps`
- Source: [packages/core/src/menu-bar.ts:72](https://github.com/omarcosr/tarve/blob/main/packages/core/src/menu-bar.ts#L72)

## Usage

```tsx title="AppMenuBar.tsx"
import { AppMenuBar, Column, Text, TitleBar, Window, darkTheme } from "@tarve/core";

<Window title="Notes" width={640} height={260} theme={darkTheme}>
  <TitleBar height={36}>
    <AppMenuBar
      items={[
        {
          label: "&File",
          items: [
            { id: "new", label: "New", accelerator: "Ctrl+N" },
            { id: "open", label: "Open…", accelerator: "Ctrl+O" },
            { type: "separator" },
            { label: "Recent", items: [{ id: "recent-1", label: "notes.md" }] },
          ],
        },
        { label: "&View", items: [{ id: "wrap", label: "Word wrap", checked: true }] },
      ]}
      onSelect={(id) => console.log("menu", id)}
    />
  </TitleBar>
  <Column flex={1} padding={24}>
    <Text>Alt+F opens File; F10 focuses the bar.</Text>
  </Column>
</Window>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` (required) | `readonly MenuBarItem[]` | — |  |
| `onSelect` | `(id: string) => void` | — | After an item's own `onSelect`, with its id (`menu-<n>` when it has none). |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="MenuBarItem"
type MenuBarItem =
  | { type: "separator" }
  | { type?: "item"; id?: string; label: string; accelerator?: string; checked?: boolean; disabled?: boolean; onSelect?: () => void; items?: MenuBarItem[] };
```

Previous: [Menubar](https://tarve.dev/docs/components/Menubar.md) · Next: [Sidebar](https://tarve.dev/docs/components/Sidebar.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/AppMenuBar · Index for agents: https://tarve.dev/llms.txt
