# Menu

A list of actions that opens from a button.

A list of actions that opens from a button. The raised popup scales out of its trigger and a single highlight glides between rows under the pointer and the arrow keys alike; opening and closing from the keyboard stay instant. Items can carry an icon and a trailing hint, be destructive, or be checkbox and radio options. Behaviour, focus and ARIA come from the Zag menu machine, through Ark UI in React, Vue and Svelte.

Kind: component · Category: Overlays · Status: beta · Targets: React, Vue, Svelte · Behaviour: Zag `menu` machine, through Ark UI

## Add

```bash
npx fndn add menu
```

It writes the folder `menu/` into the project's ui folder (`index.ts`, `menu.tsx`, `Menu.vue`, `Menu.svelte`, `menu.recipe.ts`), and what it is built from: [Button](/components/button.md), [Checkbox](/components/checkbox.md), [Radio Group](/components/radio-group.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { Menu } from "@/components/ui/menu";
```

```vue
import { Menu } from "@/components/ui/menu";
```

```svelte
import { Menu } from "$lib/components/ui/menu";
```

## Parts

In the DOM the root carries `data-slot="menu"` and each part `data-slot="menu-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `menu` |  | Inline wrapper around the trigger |
| `trigger` | `button` | `menu-trigger` |  | Any button; aria-haspopup=menu, data-state=open\|closed. The default trigger is the real Button (outline, sm) with a caret, marked data-menu="trigger" |
| `positioner` | `div` | `menu-positioner` |  | Placed by the engine and rendered in a portal. Exposes --transform-origin and --available-height |
| `content` | `div` | `menu-content` |  | role=menu popup; the shared popup surface (`lib/popup.ts`: surface, motion, keyboard-instant; stacking from base.css) |
| `highlight` | `span` | `menu-highlight` |  | Shared gliding highlight layer (`glideLayer` of `lib/glide.ts`); glides under the pointer and the keyboard |
| `group` | `div` | `menu-group` | optional, repeats | role=group, labelled by its label |
| `label` | `div` | `menu-label` | optional | Group heading; the shared option row's group label (`lib/option.ts`) |
| `item` | `div` | `menu-item` | repeats | role=menuitem \| menuitemcheckbox \| menuitemradio; data-highlighted, data-state=checked\|unchecked on options, data-disabled; composes the shared option row (`lib/option.ts`; the tone prop is its danger variant) |
| `item-icon` | `span` | `menu-item-icon` | optional | Leading icon of an action or a sub-menu row (the `icon` of the entry): the shared option row's icon (`lib/option.ts`), 14px glyph in ink-3, the row's red on a danger action; aria-hidden. React: a node (a Phosphor icon with data-slot="icon" weight="bold"); Vue and Svelte: an icon component, drawn bold. Checkbox and radio options lead with their control instead |
| `item-text` | `span` | `menu-item-text` |  | The shared option row's text (`lib/option.ts`) |
| `item-meta` | `span` | `menu-item-meta` | optional | Trailing hint, e.g. a keyboard shortcut; the shared option row's meta (`lib/option.ts`) |
| `item-caret` | `span` | `menu-item-caret` | optional | Ends a row that opens a sub-menu; a 12px caret (caret-right, mirrored under rtl) in ink-3, aria-hidden |
| `item-control` | `div` | `menu-item-control` | optional | Checkbox options lead with the checkbox's own control (data-slot=checkbox-control, the checkbox recipe's control classes, with its checkbox-mark), radio options with the radio's (data-slot=radio-group-control); data-state=checked\|unchecked follows the option, so the mark is drawn exactly as in those components |
| `separator` | `hr` | `menu-separator` | optional, repeats | the shared option row's separator (`lib/option.ts`) |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `{ type: 'checkbox' \| 'group' \| 'radio-group' \| 'separator' \| 'submenu' \| undefined (action); value: string; label: string; icon: icon? (action, submenu; also an action inside a group). React: a node; Vue / Svelte: a component; meta?: string; tone?: 'danger'; disabled?: boolean; checked: boolean? (checkbox); name: string (radio-group); items: entries (group, radio-group, submenu); closeOnSelect: boolean? (radio-group): close the menu when an option is picked; default false. }[]` |  | Entries in order: actions, checkbox options, groups with a label, radio groups, separators, and sub-menus: a row that opens a nested menu to its side. An action or a sub-menu row may lead with an icon; give icons to every action of a menu or to none, so the labels line up. |
| `triggerLabel` | `string` |  | Label of the default trigger. Pass your own trigger element instead when you need one (children / trigger slot / trigger snippet). |
| `tone` | `"default" \| "danger"` | `"default"` | Per item: danger marks a destructive action. |
| `placement` | `string` | `"bottom-start"` | Preferred side; flips when there is no room. |
| `open` | `boolean` |  | Bindable (React: `defaultOpen` and `onOpenChange`; Vue: `v-model:open`; Svelte: `bind:open`).  |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `select` | (value: string) an action was chosen |
| `checkedChange` | (value: string, checked: boolean) |
| `radioChange` | (name: string, value: string) |
| `openChange` | (open: boolean) |
| `ui:set-open` | No adapter handles it (control `open` instead). { open: boolean } |
| `ui:set-checked` | No adapter handles it. { value, checked } set a checkbox option without a checkedChange |
| `ui:set-value` | No adapter handles it. { name, value } set a radio group without a radioChange |

## Slots

| Slot | Content |
| --- | --- |
| `trigger` | Your own trigger element (React: children; Vue: trigger slot; Svelte: trigger snippet receiving the props to spread) |

## States

`hover`, `press`, `focus-visible`, `open`, `highlighted`, `checked`, `disabled`

## Keyboard and accessibility

Role: menu.

Keyboard:

- Enter / Space / ArrowDown on the trigger open the menu and move focus into it; ArrowUp opens on the last item
- ArrowDown / ArrowUp move the highlight; Home / End jump
- Typing jumps to the matching item (type-ahead)
- Enter / Space activate the highlighted item; checkbox and radio options toggle
- On a sub-menu row: ArrowRight (ArrowLeft under rtl), Enter or Space open the sub-menu on its first item; ArrowLeft (ArrowRight under rtl) or Escape close it and return to the row. Hovering the row opens it
- Escape closes; focus returns to the trigger. Tab closes and moves on

Notes:

- An icon-only trigger needs an aria-label.
- Opening and closing from the keyboard are instant; the highlight glides under the pointer and the keyboard alike.

## Motion

- popup: the shared popup surface (`lib/popup.ts`): opacity + scale from motion.popup-scale out of the trigger (--transform-origin), duration.popup, easing.out-strong; closes at duration.fast; instant when opened or closed from the keyboard
- mounted open (defaultOpen, or open at mount): the popup is drawn at once, with no entrance (menu-content carries data-mounted-open until it first closes); its close, and every later open, animate as above
- sub-menu: the same popup, growing from the row that opened it; its first row on the same line as that row, its edge 4px clear of the parent panel; that row keeps the highlight while the sub-menu is open
- highlight: one layer glides between rows over duration.move, easing.out-strong, under the pointer and the arrow keys alike
- rows: a pressed row darkens to color.hover-2 over duration.fast
- checkbox and radio options: the checkbox's and the radio's own mark recipe (the fill leads, the mark is drawn); instant from the keyboard
- items: no entrance animation and no stagger (a menu is opened many times a day)

## Tokens

`color.surface`, `color.hover-2`, `color.ink`, `color.ink-3`, `color.line`, `color.red`, `shadow.raised`, `radius.card`, `radius.chip`, `text.2xs`, `text.md`, `duration.fast`, `duration.popup`, `easing.out-strong`, `motion.popup-scale`

## Dependencies

- [Button](/components/button.md)
- [Checkbox](/components/checkbox.md)
- [Radio Group](/components/radio-group.md)

## Examples

### Project row actions

React · `row-actions.tsx`

```tsx
import { Copy, DotsThree, Folder, PencilSimple, Trash } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";
import { Tooltip } from "@/components/ui/tooltip";

const projects = [
  { name: "web-app", meta: "Deployed 2 min ago by Maya Chen" },
  { name: "billing-api", meta: "Deployed yesterday by Daniel Okafor" },
  { name: "data-pipeline", meta: "No deploys yet" },
];

const actions: MenuEntry[] = [
  { value: "rename", label: "Rename", icon: <PencilSimple data-slot="icon" weight="bold" /> },
  { value: "duplicate", label: "Duplicate", icon: <Copy data-slot="icon" weight="bold" /> },
  { value: "move", label: "Move to…", icon: <Folder data-slot="icon" weight="bold" /> },
  { type: "separator" },
  { value: "delete", label: "Delete", tone: "danger", icon: <Trash data-slot="icon" weight="bold" /> },
];

export default function RowActions() {
  return (
    <ul className="flex w-80 flex-col gap-1">
      {projects.map((project) => (
        <li key={project.name} className="flex items-center gap-3">
          <div className="flex min-w-0 flex-1 flex-col">
            <span className="text-sm font-medium text-ink">{project.name}</span>
            <span className="text-xs text-ink-2">{project.meta}</span>
          </div>
          <Menu placement="bottom-end" items={actions}>
            <Tooltip content="More actions">
              <Button variant="ghost" size="sm" square aria-label={`More actions for ${project.name}`} icon={<DotsThree data-slot="icon" weight="bold" />} />
            </Tooltip>
          </Menu>
        </li>
      ))}
    </ul>
  );
}
```

Vue · `row-actions.vue`

```vue
<script setup lang="ts">
import { PhCopy, PhDotsThree, PhFolder, PhPencilSimple, PhTrash } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";
import { Tooltip } from "@/components/ui/tooltip";

const projects = [
  { name: "web-app", meta: "Deployed 2 min ago by Maya Chen" },
  { name: "billing-api", meta: "Deployed yesterday by Daniel Okafor" },
  { name: "data-pipeline", meta: "No deploys yet" },
];

const actions: MenuEntry[] = [
  { value: "rename", label: "Rename", icon: PhPencilSimple },
  { value: "duplicate", label: "Duplicate", icon: PhCopy },
  { value: "move", label: "Move to…", icon: PhFolder },
  { type: "separator" },
  { value: "delete", label: "Delete", tone: "danger", icon: PhTrash },
];
</script>

<template>
  <ul class="flex w-80 flex-col gap-1">
    <li v-for="project in projects" :key="project.name" class="flex items-center gap-3">
      <div class="flex min-w-0 flex-1 flex-col">
        <span class="text-sm font-medium text-ink">{{ project.name }}</span>
        <span class="text-xs text-ink-2">{{ project.meta }}</span>
      </div>
      <Menu placement="bottom-end" :items="actions">
        <template #trigger>
          <Tooltip content="More actions">
            <Button variant="ghost" size="sm" square :aria-label="`More actions for ${project.name}`">
              <template #icon><PhDotsThree data-slot="icon" weight="bold" /></template>
            </Button>
          </Tooltip>
        </template>
      </Menu>
    </li>
  </ul>
</template>
```

Svelte · `row-actions.svelte`

```svelte
<script lang="ts">
  import Copy from "phosphor-svelte/lib/CopyIcon";
  import DotsThree from "phosphor-svelte/lib/DotsThreeIcon";
  import Folder from "phosphor-svelte/lib/FolderIcon";
  import PencilSimple from "phosphor-svelte/lib/PencilSimpleIcon";
  import Trash from "phosphor-svelte/lib/TrashIcon";
  import { Button } from "$lib/components/ui/button";
  import { Menu, type MenuEntry } from "$lib/components/ui/menu";
  import { Tooltip } from "$lib/components/ui/tooltip";

  const projects = [
    { name: "web-app", meta: "Deployed 2 min ago by Maya Chen" },
    { name: "billing-api", meta: "Deployed yesterday by Daniel Okafor" },
    { name: "data-pipeline", meta: "No deploys yet" },
  ];

  const actions: MenuEntry[] = [
    { value: "rename", label: "Rename", icon: PencilSimple },
    { value: "duplicate", label: "Duplicate", icon: Copy },
    { value: "move", label: "Move to…", icon: Folder },
    { type: "separator" },
    { value: "delete", label: "Delete", tone: "danger", icon: Trash },
  ];
</script>

<ul class="flex w-80 flex-col gap-1">
  {#each projects as project (project.name)}
    <li class="flex items-center gap-3">
      <div class="flex min-w-0 flex-1 flex-col">
        <span class="text-sm font-medium text-ink">{project.name}</span>
        <span class="text-xs text-ink-2">{project.meta}</span>
      </div>
      <Menu placement="bottom-end" items={actions}>
        {#snippet trigger(menuProps)}
          <Tooltip content="More actions" {...menuProps()}>
            {#snippet trigger(tipProps)}
              <Button {...tipProps()} variant="ghost" size="sm" square aria-label={`More actions for ${project.name}`}>
                {#snippet icon()}<DotsThree data-slot="icon" weight="bold" />{/snippet}
              </Button>
            {/snippet}
          </Tooltip>
        {/snippet}
      </Menu>
    </li>
  {/each}
</ul>
```

### Sort and columns of a table

React · `view-options.tsx`

```tsx
import { SlidersHorizontal } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";

/* options keep their own state; pass onRadioChange / onCheckedChange to store them */
const items: MenuEntry[] = [
  {
    type: "radio-group",
    name: "sort",
    label: "Sort by",
    value: "deployed",
    items: [
      { value: "deployed", label: "Last deploy" },
      { value: "name", label: "Project name" },
      { value: "status", label: "Status" },
    ],
  },
  { type: "separator" },
  {
    type: "group",
    label: "Columns",
    items: [
      { type: "checkbox", value: "branch", label: "Branch", checked: true },
      { type: "checkbox", value: "author", label: "Deployed by", checked: true },
      { type: "checkbox", value: "duration", label: "Build time" },
    ],
  },
];

export default function ViewOptions() {
  return (
    <Menu items={items}>
      <Button size="sm" icon={<SlidersHorizontal data-slot="icon" weight="bold" />}>View</Button>
    </Menu>
  );
}
```

Vue · `view-options.vue`

```vue
<script setup lang="ts">
import { PhSlidersHorizontal } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";

/* options keep their own state; listen to @radio-change / @checked-change to store them */
const items: MenuEntry[] = [
  {
    type: "radio-group",
    name: "sort",
    label: "Sort by",
    value: "deployed",
    items: [
      { value: "deployed", label: "Last deploy" },
      { value: "name", label: "Project name" },
      { value: "status", label: "Status" },
    ],
  },
  { type: "separator" },
  {
    type: "group",
    label: "Columns",
    items: [
      { type: "checkbox", value: "branch", label: "Branch", checked: true },
      { type: "checkbox", value: "author", label: "Deployed by", checked: true },
      { type: "checkbox", value: "duration", label: "Build time" },
    ],
  },
];
</script>

<template>
  <Menu :items="items">
    <template #trigger>
      <Button size="sm">
        <template #icon><PhSlidersHorizontal data-slot="icon" weight="bold" /></template>
        View
      </Button>
    </template>
  </Menu>
</template>
```

Svelte · `view-options.svelte`

```svelte
<script lang="ts">
  import SlidersHorizontal from "phosphor-svelte/lib/SlidersHorizontalIcon";
  import { Button } from "$lib/components/ui/button";
  import { Menu, type MenuEntry } from "$lib/components/ui/menu";

  /* options keep their own state; pass onradiochange / oncheckedchange to store them */
  const items: MenuEntry[] = [
    {
      type: "radio-group",
      name: "sort",
      label: "Sort by",
      value: "deployed",
      items: [
        { value: "deployed", label: "Last deploy" },
        { value: "name", label: "Project name" },
        { value: "status", label: "Status" },
      ],
    },
    { type: "separator" },
    {
      type: "group",
      label: "Columns",
      items: [
        { type: "checkbox", value: "branch", label: "Branch", checked: true },
        { type: "checkbox", value: "author", label: "Deployed by", checked: true },
        { type: "checkbox", value: "duration", label: "Build time" },
      ],
    },
  ];
</script>

<Menu {items}>
  {#snippet trigger(props)}
    <Button {...props()} size="sm">
      {#snippet icon()}<SlidersHorizontal data-slot="icon" weight="bold" />{/snippet}
      View
    </Button>
  {/snippet}
</Menu>
```

### Pick an environment

React · `environment-picker.tsx`

```tsx
import { useState } from "react";
import { Menu, type MenuEntry } from "@/components/ui/menu";

const environments = [
  { value: "production", label: "Production" },
  { value: "staging", label: "Staging" },
  { value: "preview", label: "Preview" },
];

/* a pick is the whole job, so the menu closes on it (closeOnSelect) */
export default function EnvironmentPicker() {
  const [environment, setEnvironment] = useState("production");
  const items: MenuEntry[] = [
    { type: "radio-group", name: "environment", label: "Show logs from", value: environment, closeOnSelect: true, items: environments },
  ];
  const current = environments.find((e) => e.value === environment)?.label;
  return <Menu triggerLabel={current} items={items} onRadioChange={(_, value) => setEnvironment(value)} />;
}
```

Vue · `environment-picker.vue`

```vue
<script setup lang="ts">
import { computed, ref } from "vue";
import { Menu, type MenuEntry } from "@/components/ui/menu";

const environments = [
  { value: "production", label: "Production" },
  { value: "staging", label: "Staging" },
  { value: "preview", label: "Preview" },
];

/* a pick is the whole job, so the menu closes on it (closeOnSelect) */
const environment = ref("production");
const items = computed<MenuEntry[]>(() => [
  { type: "radio-group", name: "environment", label: "Show logs from", value: environment.value, closeOnSelect: true, items: environments },
]);
const current = computed(() => environments.find((e) => e.value === environment.value)?.label);
</script>

<template>
  <Menu :triggerLabel="current" :items="items" @radio-change="(_, value) => (environment = value)" />
</template>
```

Svelte · `environment-picker.svelte`

```svelte
<script lang="ts">
  import { Menu, type MenuEntry } from "$lib/components/ui/menu";

  const environments = [
    { value: "production", label: "Production" },
    { value: "staging", label: "Staging" },
    { value: "preview", label: "Preview" },
  ];

  /* a pick is the whole job, so the menu closes on it (closeOnSelect) */
  let environment = $state("production");
  const items: MenuEntry[] = $derived([
    { type: "radio-group", name: "environment", label: "Show logs from", value: environment, closeOnSelect: true, items: environments },
  ]);
  const current = $derived(environments.find((e) => e.value === environment)?.label);
</script>

<Menu triggerLabel={current} {items} onradiochange={(_, value) => (environment = value)} />
```

### Request review from a sub-menu

React · `pull-request-actions.tsx`

```tsx
import { useState } from "react";
import { DotsThree, Tag, UserPlus, X } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";
import { Tooltip } from "@/components/ui/tooltip";

const people: Record<string, string> = {
  priya: "Priya Raman",
  lucas: "Lucas Moreau",
  aiko: "Aiko Tanaka",
  sofia: "Sofia Alvarez",
};

/* a sub-menu keeps a second-level choice out of the first list */
const items: MenuEntry[] = [
  {
    type: "submenu",
    label: "Request review",
    icon: <UserPlus data-slot="icon" weight="bold" />,
    items: Object.entries(people).map(([value, label]) => ({ value, label })),
  },
  {
    type: "submenu",
    label: "Add label",
    icon: <Tag data-slot="icon" weight="bold" />,
    items: [
      { value: "bug", label: "bug" },
      { value: "reliability", label: "reliability" },
      { value: "needs-docs", label: "needs-docs" },
    ],
  },
  { type: "separator" },
  { value: "close", label: "Close pull request", tone: "danger", icon: <X data-slot="icon" weight="bold" /> },
];

export default function PullRequestActions() {
  const [reviewer, setReviewer] = useState("");
  return (
    <div className="flex w-80 items-center gap-3">
      <div className="flex min-w-0 flex-1 flex-col">
        <span className="text-sm font-medium text-ink">#482 Add retry to webhook delivery</span>
        <span className="text-xs text-ink-2">{reviewer ? `Review requested from ${reviewer}` : "Daniel Okafor wants to merge into main"}</span>
      </div>
      <Menu placement="bottom-end" items={items} onSelect={(value) => people[value] && setReviewer(people[value])}>
        <Tooltip content="More actions">
          <Button variant="ghost" size="sm" square aria-label="More actions for #482" icon={<DotsThree data-slot="icon" weight="bold" />} />
        </Tooltip>
      </Menu>
    </div>
  );
}
```

Vue · `pull-request-actions.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PhDotsThree, PhTag, PhUserPlus, PhX } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Menu, type MenuEntry } from "@/components/ui/menu";
import { Tooltip } from "@/components/ui/tooltip";

const people: Record<string, string> = {
  priya: "Priya Raman",
  lucas: "Lucas Moreau",
  aiko: "Aiko Tanaka",
  sofia: "Sofia Alvarez",
};

/* a sub-menu keeps a second-level choice out of the first list */
const items: MenuEntry[] = [
  {
    type: "submenu",
    label: "Request review",
    icon: PhUserPlus,
    items: Object.entries(people).map(([value, label]) => ({ value, label })),
  },
  {
    type: "submenu",
    label: "Add label",
    icon: PhTag,
    items: [
      { value: "bug", label: "bug" },
      { value: "reliability", label: "reliability" },
      { value: "needs-docs", label: "needs-docs" },
    ],
  },
  { type: "separator" },
  { value: "close", label: "Close pull request", tone: "danger", icon: PhX },
];

const reviewer = ref("");
</script>

<template>
  <div class="flex w-80 items-center gap-3">
    <div class="flex min-w-0 flex-1 flex-col">
      <span class="text-sm font-medium text-ink">#482 Add retry to webhook delivery</span>
      <span class="text-xs text-ink-2">{{ reviewer ? `Review requested from ${reviewer}` : "Daniel Okafor wants to merge into main" }}</span>
    </div>
    <Menu placement="bottom-end" :items="items" @select="(value) => people[value] && (reviewer = people[value])">
      <template #trigger>
        <Tooltip content="More actions">
          <Button variant="ghost" size="sm" square aria-label="More actions for #482">
            <template #icon><PhDotsThree data-slot="icon" weight="bold" /></template>
          </Button>
        </Tooltip>
      </template>
    </Menu>
  </div>
</template>
```

Svelte · `pull-request-actions.svelte`

```svelte
<script lang="ts">
  import DotsThree from "phosphor-svelte/lib/DotsThreeIcon";
  import Tag from "phosphor-svelte/lib/TagIcon";
  import UserPlus from "phosphor-svelte/lib/UserPlusIcon";
  import X from "phosphor-svelte/lib/XIcon";
  import { Button } from "$lib/components/ui/button";
  import { Menu, type MenuEntry } from "$lib/components/ui/menu";
  import { Tooltip } from "$lib/components/ui/tooltip";

  const people: Record<string, string> = {
    priya: "Priya Raman",
    lucas: "Lucas Moreau",
    aiko: "Aiko Tanaka",
    sofia: "Sofia Alvarez",
  };

  /* a sub-menu keeps a second-level choice out of the first list */
  const items: MenuEntry[] = [
    {
      type: "submenu",
      label: "Request review",
      icon: UserPlus,
      items: Object.entries(people).map(([value, label]) => ({ value, label })),
    },
    {
      type: "submenu",
      label: "Add label",
      icon: Tag,
      items: [
        { value: "bug", label: "bug" },
        { value: "reliability", label: "reliability" },
        { value: "needs-docs", label: "needs-docs" },
      ],
    },
    { type: "separator" },
    { value: "close", label: "Close pull request", tone: "danger", icon: X },
  ];

  let reviewer = $state("");
</script>

<div class="flex w-80 items-center gap-3">
  <div class="flex min-w-0 flex-1 flex-col">
    <span class="text-sm font-medium text-ink">#482 Add retry to webhook delivery</span>
    <span class="text-xs text-ink-2">{reviewer ? `Review requested from ${reviewer}` : "Daniel Okafor wants to merge into main"}</span>
  </div>
  <Menu placement="bottom-end" {items} onselect={(value) => people[value] && (reviewer = people[value])}>
    {#snippet trigger(menuProps)}
      <Tooltip content="More actions" {...menuProps()}>
        {#snippet trigger(tipProps)}
          <Button {...tipProps()} variant="ghost" size="sm" square aria-label="More actions for #482">
            {#snippet icon()}<DotsThree data-slot="icon" weight="bold" />{/snippet}
          </Button>
        {/snippet}
      </Tooltip>
    {/snippet}
  </Menu>
</div>
```

## Recipe

`menu.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";
import { popup } from "../lib/popup";
import { option } from "../lib/option";
import { glideLayer } from "../lib/glide";

/* menu — a raised list of actions that scales out of its trigger.
 * Behaviour comes from the Zag menu machine (data-state, data-highlighted, data-disabled…).
 * The popup lives in a portal, so nothing below depends on the root being an ancestor.
 *
 * The popup surface, the option rows (with the separator and the group label) and the one gliding
 * highlight are shared (the popup and option recipes, glideLayer of lib/glide.ts), composed into the parts below; only
 * what a menu adds is written here. The positioner takes its stacking from base.css. An action's
 * tone is a variant of the item and its icon (danger: red text and icon). Parts are found by data-slot (menu, menu-content, menu-item, …); the root
 * slot is `base`.
 *
 * The default trigger is the real Button (outline, sm) with a trailing caret (its trailingIcon),
 * marked data-menu="trigger". Checkbox and radio options lead with the checkbox's and the radio's
 * own control (the item-control part), written by hand (the adapters render a whole labelled
 * control with its native input) with those recipes' classes and slots (checkbox-control and
 * checkbox-mark, radio-group-control), driven by their data-state. A sub-menu is a nested Ark menu
 * whose trigger is a row like the others, with a caret (item-caret); its popup is this same
 * recipe, and keeps the row that opened it highlighted. */

const row = option();
const danger = option({ tone: "danger" });

export const menu = tv({
  slots: {
    base: "inline-flex min-w-0",
    /* the trigger is any button; only its place in the row is ours */
    trigger: "shrink-0",
    positioner: "",
    content: [popup(), "min-w-[160px] max-w-[min(320px,calc(100vw-16px))]"],
    /* the popup's 4px: the highlight sits on the rows */
    highlight: [glideLayer, "inset-x-1"],
    group: "flex flex-col",
    label: row.label(),
    item: row.base(),
    itemIcon: row.icon(),
    itemText: row.text(),
    itemMeta: row.meta(),
    /* a row that opens a sub-menu ends with a caret pointing to the side it opens on (mirrored
     * under rtl); an icon, it is ink-3 as the row's icon is, and sits where a meta would */
    itemCaret: "inline-flex shrink-0 ms-auto text-[12px] text-ink-3 rtl:-scale-x-100 [&>[data-slot=icon]]:size-3",
    separator: row.separator(),
  },
  variants: {
    tone: {
      default: {},
      danger: { item: danger.base(), itemIcon: danger.icon() },
    },
  },
  defaultVariants: { tone: "default" },
});

export type MenuRecipeProps = VariantProps<typeof menu>;
```
