# Menubar

Roving application menus over package-owned native ActionMenu popovers.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/menubar.tsx)

## Live preview

[Open live menubar preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=menubar&theme=studio-utility)

## Install

```bash
netscript ui:add menubar
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import { Menubar } from '@app/components/ui/menubar.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><Menubar label="Order actions" menus={[{id:"file",label:"File",items:[{id:"save",label:"Save order",onSelect:()=>report("Saved")}]}]} /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `MenubarProps` | `label` | `string` | No |  |
| `MenubarProps` | `menus` | `[object Object]` | No |  |
| `MenubarProps` | `value` | `string \| null` | Yes |  |
| `MenubarProps` | `defaultValue` | `string \| null` | Yes |  |
| `MenubarProps` | `onValueChange` | `(menu: string \| null) => void` | Yes |  |
| `MenubarProps` | `class` | `string` | Yes |  |

```typescript
MenubarProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "onChange">
```

## Keyboard

| Key | Action |
| --- | --- |
| `ArrowLeft/ArrowRight` | Navigate menu triggers |
| `ArrowDown` | Open menu |
| `Escape` | Close menu |
| `Home/End` | Move to first/last enabled trigger or menu item. |
| `Enter/Space` | Open a menu, activate actions or change caller-owned checkbox/radio state. |
| `ArrowRight/ArrowLeft in submenu` | Open/close nested menu, respecting direction. |
| `Tab/Shift+Tab` | Close the menu and leave through the roving trigger. |
| `Printable character` | Find the next matching menu item. |

## Tokens

Semantic contract roles: `border/default`, `radius/input`, `surface/bg`, `surface/hover`.

CSS custom properties referenced directly: `--ns-bg`, `--ns-border`, `--ns-border-width`, `--ns-control-height-sm`, `--ns-control-padding-x`, `--ns-fg`, `--ns-hover`, `--ns-radius-control`, `--ns-radius-input`, `--ns-ring`, `--ns-space-1`, `--ns-text-small`, `--ns-weight-strong`.

## Contract and compatibility

Accessibility pattern: [WAI-ARIA guidance](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/)

- Roving native application menu triggers delegate popovers and collection keys to public ActionMenu; source must hydrate in an island.
- Menu records contain app callbacks and controlled choice state. Nested menu items use private copied menu-items support, not a second public component identity.
- Trigger/content preserve runtime open/closed; disabled/hover/focus are native properties and CSS. value/null controls the open menu.

Design contract values marked planned are not implementation props. The props above describe what ships today.
