<!-- generated by scripts/gen-docs.mjs from docs/system/dropdown-menu.md. Edit the source and rerun. -->
# DropdownMenu

## Description
A list of commands opened from a button, or by a right click on an area.

`import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuSeparator, menuItemClasses } from "@/components/cobalt/ui/dropdown-menu"`, source `registry/cobalt/ui/dropdown-menu.tsx`, status `ready-with-gaps`.
`import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuSeparator } from "@/components/cobalt/ui/context-menu"`, source `registry/cobalt/ui/context-menu.tsx`, status `ready-with-gaps`.
Foundation: `shadcn dropdown-menu (base-luma, base)` and `shadcn context-menu (base-luma, base)`, customised. Traps checked: `trap/menu-navigation` (Usage, `rule/dropdown-menu-items-that-navigate-are-links`), `trap/menu-only-path` (Usage, `rule/dropdown-menu-trigger-visible-at-rest`, and `rule/context-menu-every-command-has-a-visible-path` for a right click), `trap/menu-diagonal` (n/a, the system ships no submenu, so no diagonal path exists), `trap/list-dead-gap` (States, highlighted: rows touch, the 8px padding belongs to the popup and the rows have no margin, so the highlight does not flicker between rows), `trap/open-trigger-unfocused` (States, open: `aria-expanded` and `data-popup-open` on the trigger, and Button's `aria-expanded:bg-muted` keeps the fill while open; a context menu opens at the press point, which ties it to the area, measured), `trap/overlay-focus-return` (Keyboard, Escape and Enter: focus returns to the trigger, or to the focused element inside the area for a context menu, measured), `trap/escape-nested` (Keyboard, Escape: Base UI handles the key on the popup, so a menu inside a dialog closes alone, by hand), `trap/exit-eats-input` (States, closing: the popup keeps `data-ending-style` for 105ms and takes no pointer input, by hand), `trap/motion-origin` (Motion: nothing scales, so no origin is set; the popup fades in place, a context menu 4px from the press point, and the exit reverses the entry), `trap/motion-frequent` (Motion: 150ms in and 105ms out, the Pop preset for commands seen tens of times a day, D14), `trap/motion-layout-property` (Motion: opacity only), `trap/reduced-motion-ignored` (Motion: under reduce the 150ms fade stays, measured), `trap/hover-unguarded` (Usage, `rule/dropdown-menu-trigger-visible-at-rest`: nothing in the menu shows on hover only), `trap/link-as-button` (Usage, `rule/dropdown-menu-items-that-navigate-are-links`).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Base UI `Menu.Root`, `Trigger` with `aria-haspopup="menu"`, `aria-expanded` and `aria-controls`, `Portal`, `Positioner` with `side`, `align` and the offsets, `Popup` with `role="menu"` named by the trigger, `Group`, `GroupLabel`, `Item` with `role="menuitem"`, `CheckboxItem` with `role="menuitemcheckbox"` and `aria-checked`, `CheckboxItemIndicator`, roving highlight, type-ahead, Home and End, `disabled`, and `Separator`; shadcn's part names and `data-slot` attributes | The portal container from `registry/cobalt/lib/portal.tsx` instead of the body (D22), so the menu keeps every token wherever the root sits; the popup at `rounded-3xl` (16px by default, a control's corner plus `--pad-popup`), `p-(--pad-popup)` (6px), `shadow-floating`, 8px kept from the screen's edge, as wide as its longest row, at least its trigger and 192px, at most 320px and the room on screen, so a long row wraps and an unbreakable one breaks anywhere instead of running past the edge (`registry/cobalt/ui/dropdown-menu.tsx:134`), and no border (D11, G-03); the second click of the double-click that opened it dropped, so it neither closes the menu nor presses a row (`guardOpeningClick`, measured at 1440 in `.design-system/evidence/sheet/phone-sheet-family-2026-10-17.json`); below 640px the sheet of the family `sheet.tsx` heads, with the grabber over rows that scroll, the swipe that closes it past 30 percent or on a flick, and the same slide and scrim as a Sheet (`MenuSheet`, `registry/cobalt/ui/dropdown-menu.tsx:148`), on `popup-motion` with `max-h-(--available-height)` so it scrolls instead of leaving the viewport, with `scroll-fade` softening an edge only while rows are hidden past it; `sideOffset` 4 and `align="start"` as the one picker placement (D8); `menuItemClasses`, the row look: 38px tall (`min-h-9.5`), `rounded-lg` (`--r-lg`, 10px, concentric with the popup's 16px corner and 6px padding in every corner setting), regular weight, no pointer while disabled since Base UI lights the row under the pointer whether or not it is disabled, and the destructive wash, exported so the context menu and the data table's column menu draw the same row (D33); the `inset` and `variant` props on the item; `DropdownMenuCheckboxItem`, the same row with a trailing check in the accent ink (`text-primary-ink`) that fades in on `duration-press`, a label that wraps rather than truncates so it can be read whole (`registry/cobalt/ui/dropdown-menu.tsx:251`), and `closeOnClick` false by default so you can tick several filters or shown columns without the menu closing; a `DropdownMenuLabel` must sit inside a `DropdownMenuGroup`, because Base UI throws without one; shadcn's `RadioItem`, `Sub` and `Shortcut` left out, since the system's menus hold commands and ticks, not choices from a set |
| Base UI `ContextMenu.Root`, `Trigger` that opens on the `contextmenu` event and a long press, `Positioner` anchored to the press point, and the same `Popup`, `Group`, `Item` and `Separator` as the menu above | The keyboard path: Shift+F10 and the ContextMenu key on the focused element inside the trigger raise a `contextmenu` event at its centre, since macOS raises none from the keyboard (`registry/cobalt/ui/context-menu.tsx:47-62`); `select-none` on the trigger so a long press selects no text; the `label` prop, the menu's `aria-label`, since there is no trigger to take a name from, default "Actions"; the same portal, popup look and width limits as the menu above (`registry/cobalt/ui/context-menu.tsx:114`), with the same fade out after Escape or an outside press, which Base UI marks instant (`leaveFadesClasses`; measured 1.00 then gone in one frame before, a five-frame fade after, `.design-system/evidence/sheet/phone-sheet-family-2026-10-17.json`); below 640px the same sheet as the menu above, opened by the long press, whose lifting finger presses nothing in the sheet that rose under it (`guardOpeningPress`, `ContextMenuSheet`, `registry/cobalt/ui/context-menu.tsx:143`), and `phone="popover"` to keep the menu at the finger; `side="inline-end"`, to the right of the press in a left-to-right page and to its left under a Base UI `DirectionProvider` set to `rtl` (`registry/cobalt/ui/context-menu.tsx:83`), `align="start"` and `alignOffset` 4 so the first row sits 4px under the pointer; the rows from `menuItemClasses` (D33); shadcn's `CheckboxItem`, `RadioItem`, `Sub` and `Shortcut` left out, so the context menu holds commands only |

## Examples
Row menus from a ghost More button, and a card whose same commands also open from a right click, a long press or Shift+F10.

Real uses, 0 call sites (`rg -n "<DropdownMenu\b" app registry --glob '!registry/cobalt/ui/*'`): the showcase chrome opens no menu of its own, and the examples folder does not count. ContextMenu has 0 call sites too (`rg -n "<ContextMenu\b" app registry --glob '!registry/cobalt/ui/*'`).

Uses inside the registry, which other components build on (planned as product uses once the first screen lands on the system):
- `menuItemClasses` on every row of the context menu, `registry/cobalt/ui/context-menu.tsx:188`, and the same phone sheet, from `sheet.tsx`, for a long press below 640px.
- `menuItemClasses` on the data table's column menu rows, which are plain buttons in a popover, `registry/cobalt/ui/data-table.tsx:918`.
- `menuItemClasses` on the filter bar's option rows, `registry/cobalt/ui/filter-bar.tsx:101`, and the date picker's preset rows, `registry/cobalt/ui/date-picker.tsx:626`.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/dropdown-menu/default.tsx` | default | Each list's commands under its name, with the one that removes it last |
| Not applicable: every item in default.tsx but the last is the default variant | variant=default | The row in the popover ink, the grey fill under the highlight |
| `docs/system/examples/dropdown-menu/variant-destructive.tsx` | variant=destructive | A destructive row in red text, after a separator |
| Not applicable: every example row carries an icon, so none needs the inset | inset=true | The label starts 36px in, under its neighbours' icons |
| Not applicable: every item in default.tsx is without inset | inset=false | The label starts at the row's 10px padding |
| Not applicable: closed is every example at rest, the trigger alone in the tree | state:closed | The trigger with `aria-expanded="false"` |
| Not applicable: open is reached by pressing any example's trigger, or right-clicking the card in right-click.tsx | state:open | The popup below the trigger, the trigger keeps its fill |
| Not applicable: highlighted is reached with the pointer or the arrows in any example | state:highlighted | The grey fill on one row |
| `docs/system/examples/dropdown-menu/state-disabled.tsx` | state:disabled | A disabled row is dimmed and skipped by the arrow keys |
| Not applicable: a checkbox item is a row for filters and shown columns, and the examples hold commands only | state:checked | `DropdownMenuCheckboxItem`: a trailing check in the accent ink that fades in, the menu staying open on a press |
| Not applicable: closing is the 105ms exit after any close | state:closing | The popup fading out in place |
| `docs/system/examples/dropdown-menu/right-click.tsx` | composition:Card | Right-click or long-press the card, or use its More button, and the same rows open |
| Not applicable: the tiles show each variant, and no example row needs the inset | matrix:variant,inset | Both variants, with and without inset |

Example: Each list's commands under its name, with the one that removes it last (`docs/system/examples/dropdown-menu/default.tsx`)

```tsx
import { useEffect, useRef, useState } from "react";
import { toast } from "sonner";

import { CopyIcon, MoreIcon, ShareIcon, TrashIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

type List = { id: number; name: string; count: number; copying?: boolean };

const saved: List[] = [
  { id: 1, name: "Reading list", count: 12 },
  { id: 2, name: "Q3 13F filings", count: 8 },
  { id: 3, name: "Climate risk papers", count: 21 },
];

export default function Example() {
  const [lists, setLists] = useState(saved);
  const nextId = useRef(saved.length + 1);
  // The row that held the menu is gone after Move to trash, so focus goes to the list instead of
  // dropping to the page.
  const list = useRef<HTMLUListElement>(null);
  const focusList = useRef(false);
  useEffect(() => {
    if (!focusList.current) return;
    focusList.current = false;
    list.current?.focus();
  });

  function duplicate(source: List) {
    const copy = { id: nextId.current++, name: `${source.name} copy`, count: source.count, copying: true };
    // The copy shows at once, faded until the server has it; if the request fails it goes again.
    setLists((was) => {
      const at = was.findIndex((item) => item.id === source.id);
      return [...was.slice(0, at + 1), copy, ...was.slice(at + 1)];
    });
    request().then(
      () => setLists((was) => was.map((item) => (item.id === copy.id ? { ...item, copying: false } : item))),
      () => {
        setLists((was) => was.filter((item) => item.id !== copy.id));
        toast(`${source.name} was not duplicated`, {
          description: "Check your connection and try again.",
          action: { label: "Retry", onClick: () => duplicate(source) },
        });
      },
    );
  }

  function copyLink(item: List) {
    // The menu closes, so the copy cannot show on the row; a toast says so instead.
    navigator.clipboard.writeText(`https://example.com/lists/${item.id}`).then(
      () => toast("Link copied"),
      () => toast("Could not copy the link"),
    );
  }

  function trash(item: List) {
    // The trash keeps it, so it goes at once with Undo instead of a question first.
    const at = lists.findIndex((each) => each.id === item.id);
    focusList.current = true;
    setLists((was) => was.filter((each) => each.id !== item.id));
    toast(`${item.name} moved to the trash`, {
      duration: 10_000,
      action: {
        label: "Undo",
        onClick: () => setLists((was) => [...was.slice(0, at), item, ...was.slice(at)]),
      },
    });
  }

  return (
    <ul ref={list} tabIndex={-1} className="grid w-full max-w-sm gap-1 outline-none">
      {lists.map((item) => (
        <li
          key={item.id}
          aria-busy={item.copying || undefined}
          className="flex items-center gap-3 rounded-2xl bg-muted py-1.5 ps-4 pe-1.5 text-sm transition-opacity aria-busy:opacity-60"
        >
          <span className="min-w-0 flex-1 wrap-break-word">{item.name}</span>
          <span className="shrink-0 text-muted-foreground tabular-nums">
            {item.copying ? "Copying" : `${item.count} items`}
          </span>
          <DropdownMenu>
            <DropdownMenuTrigger
              disabled={item.copying}
              render={<Button variant="ghost" size="icon" aria-label={`More for ${item.name}`} />}
            >
              <MoreIcon />
            </DropdownMenuTrigger>
            <DropdownMenuContent align="end">
              <DropdownMenuGroup>
                <DropdownMenuLabel>{item.name}</DropdownMenuLabel>
                <DropdownMenuItem onClick={() => duplicate(item)}>
                  <CopyIcon />
                  Duplicate
                </DropdownMenuItem>
                <DropdownMenuItem onClick={() => copyLink(item)}>
                  <ShareIcon />
                  Copy link
                </DropdownMenuItem>
              </DropdownMenuGroup>
              <DropdownMenuSeparator />
              <DropdownMenuItem variant="destructive" onClick={() => trash(item)}>
                <TrashIcon />
                Move to trash
              </DropdownMenuItem>
            </DropdownMenuContent>
          </DropdownMenu>
        </li>
      ))}
      {lists.length === 0 && <li className="px-4 py-3 text-sm text-muted-foreground">Every list is in the trash.</li>}
    </ul>
  );
}
```

Example: Right-click or long-press the card, or use its More button, and the same rows open (`docs/system/examples/dropdown-menu/right-click.tsx`)

```tsx
import { useEffect, useRef, useState } from "react";
import { toast } from "sonner";

import { CopyIcon, MoreIcon, ShareIcon, TrashIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/cobalt/ui/card";
import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuSeparator,
  ContextMenuTrigger,
} from "@/components/cobalt/ui/context-menu";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

const name = "Reading list";

export default function Example() {
  const [trashed, setTrashed] = useState(false);
  // The card leaves with Move to trash, so focus goes to the line that says so instead of dropping
  // to the page.
  const result = useRef<HTMLParagraphElement>(null);
  useEffect(() => {
    if (trashed) result.current?.focus();
  }, [trashed]);

  function duplicate() {
    // The copy lands in a list this card does not show, so a toast reports it.
    request().then(
      () => toast(`${name} copy created`, { description: "It is first in your lists." }),
      () =>
        toast(`${name} was not duplicated`, {
          description: "Check your connection and try again.",
          action: { label: "Retry", onClick: duplicate },
        }),
    );
  }

  function copyLink() {
    navigator.clipboard.writeText("https://example.com/lists/reading-list").then(
      () => toast("Link copied"),
      () => toast("Could not copy the link"),
    );
  }

  function trash() {
    // The trash keeps it, so it goes at once with Undo instead of a question first.
    setTrashed(true);
    toast(`${name} moved to the trash`, {
      duration: 10_000,
      action: { label: "Undo", onClick: () => setTrashed(false) },
    });
  }

  if (trashed)
    return (
      <p ref={result} tabIndex={-1} role="status" className="w-full max-w-sm text-sm text-muted-foreground outline-none">
        {name} moved to the trash.
      </p>
    );

  // The two menus list the same rows in the same order, so whichever one you learn, the other matches.
  return (
    <ContextMenu>
      <ContextMenuTrigger className="w-full max-w-sm">
        <Card>
          <CardHeader>
            <CardTitle>{name}</CardTitle>
            <CardDescription>12 articles, 3 unread</CardDescription>
            <CardAction>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={<Button variant="ghost" size="icon-sm" aria-label={`${name} actions`} />}
                >
                  <MoreIcon />
                </DropdownMenuTrigger>
                <DropdownMenuContent align="end">
                  <DropdownMenuItem onClick={duplicate}>
                    <CopyIcon />
                    Duplicate
                  </DropdownMenuItem>
                  <DropdownMenuItem onClick={copyLink}>
                    <ShareIcon />
                    Copy link
                  </DropdownMenuItem>
                  <DropdownMenuSeparator />
                  <DropdownMenuItem variant="destructive" onClick={trash}>
                    <TrashIcon />
                    Move to trash
                  </DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </CardAction>
          </CardHeader>
          <CardContent>
            <p className="text-sm text-muted-foreground">Saved from the browser and the phone, newest first.</p>
          </CardContent>
        </Card>
      </ContextMenuTrigger>
      <ContextMenuContent label={`${name} actions`}>
        <ContextMenuItem onClick={duplicate}>
          <CopyIcon />
          Duplicate
        </ContextMenuItem>
        <ContextMenuItem onClick={copyLink}>
          <ShareIcon />
          Copy link
        </ContextMenuItem>
        <ContextMenuSeparator />
        <ContextMenuItem variant="destructive" onClick={trash}>
          <TrashIcon />
          Move to trash
        </ContextMenuItem>
      </ContextMenuContent>
    </ContextMenu>
  );
}
```

## Variants

### variant
- `default`: a command, in the popover ink. Used at 0 call sites; every example row but the last of each menu.
- `destructive`: a command that removes something, in red on a 10 percent wash when highlighted. Used at 0 call sites; the last row of the default example. `DropdownMenuItem` and `ContextMenuItem` take the same values.

Example: A destructive row in red text, after a separator (`docs/system/examples/dropdown-menu/variant-destructive.tsx`)

```tsx
import { useState } from "react";
import { toast } from "sonner";

import { MoreIcon, ShareIcon, TrashIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";

const lists = ["Reading list", "Q3 13F filings", "Climate risk papers"];

export default function Example() {
  const [trashed, setTrashed] = useState<string[]>([]);
  const shown = lists.filter((list) => !trashed.includes(list));
  return (
    <div className="grid w-full max-w-sm gap-1">
      {shown.map((list) => (
        <div key={list} className="flex items-center gap-3 rounded-2xl bg-muted py-1.5 ps-4 pe-1.5 text-sm">
          <span className="min-w-0 flex-1 wrap-break-word">{list}</span>
          <DropdownMenu>
            <DropdownMenuTrigger
              render={<Button variant="ghost" size="icon" aria-label={`More for ${list}`} />}
            >
              <MoreIcon />
            </DropdownMenuTrigger>
            <DropdownMenuContent>
              <DropdownMenuItem
                onClick={() => {
                  navigator.clipboard.writeText(`https://example.com/lists/${encodeURIComponent(list)}`).then(
                    () => toast("Link copied"),
                    () => toast("Could not copy the link"),
                  );
                }}
              >
                <ShareIcon />
                Copy link
              </DropdownMenuItem>
              <DropdownMenuSeparator />
              <DropdownMenuItem
                variant="destructive"
                onClick={() => {
                  // The trash keeps it, so it goes at once with Undo instead of a question first.
                  setTrashed((was) => [...was, list]);
                  toast(`${list} moved to the trash`, {
                    duration: 10_000,
                    action: {
                      label: "Undo",
                      onClick: () => setTrashed((was) => was.filter((item) => item !== list)),
                    },
                  });
                }}
              >
                <TrashIcon />
                Move to trash
              </DropdownMenuItem>
            </DropdownMenuContent>
          </DropdownMenu>
        </div>
      ))}
      {shown.length === 0 && (
        <div className="flex items-center justify-between gap-3 px-4 py-1.5 text-sm text-muted-foreground">
          Every list is in the trash.
          <Button variant="ghost" size="sm" onClick={() => setTrashed([])}>
            Restore all
          </Button>
        </div>
      )}
    </div>
  );
}
```

### inset
- `true`: the label starts 36px in, under the icon column of its neighbours. Used at 0 call sites.
- `false`: the label starts at the row's 10px padding. Used at 0 call sites; the default.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| closed | render, or `open={false}` | press the trigger, or ArrowDown on it; right-click, long-press or Shift+F10 on a context menu's area | nothing is in the tree but the trigger, which reads `aria-expanded="false"`, or the area with the host's own markup | test |
| open | the trigger, ArrowDown or ArrowUp on it, or `open` | move with the arrows, choose with Enter or Space, press outside, Escape | the popup 4px below the trigger with `role="menu"`, `aria-expanded="true"` and `data-popup-open` on the trigger, which keeps the muted fill | by hand |
| open at the press point | the `contextmenu` event, a long press, Shift+F10 or the ContextMenu key on a focused element inside a `ContextMenuTrigger` | the same as open | the popup with `role="menu"` 4px under the press point, focus on the popup, the area's text unselected | by hand |
| highlighted | pointer over a row, or the arrows | choose it with Enter, Space or a click | `data-highlighted` on the row and focus on it, `tabindex="-1"` on the rest | by hand |
| disabled | `disabled` on an item | nothing; the arrows and the pointer skip it | `data-disabled` on the row, half opacity, no pointer events | test |
| checked | `checked` or `defaultChecked` on a `DropdownMenuCheckboxItem`, after a press | press again to untick; the menu stays open | the trailing check in `--primary-ink` faded to full opacity on `duration-press`, `aria-checked="true"`, `data-checked` | test |
| scrolling | the items run past `--available-height` | scroll the popup | the popup clipped at the available height with `overflow-y: auto` | screenshot |
| closing | a choice, Escape, a press outside, `open={false}`, or on a phone a swipe down let go past 30 percent of the sheet or flicked | press the trigger again once it is gone | `data-ending-style` on the popup, which takes no pointer input while it fades for 105ms, or the sheet sliding out from where the finger let go | by hand |
| sheet | the screen is under 640px and `phone` is `sheet`, from the trigger or, for a context menu, a long press | the same rows and keys, Escape, press the scrim, swipe it down | the menu as a sheet along the bottom over the scrim, the grabber in a 24px strip at its top, 44px rows, `data-sheet`; measured 390x207 for the default menu and 390x175 for the context menu (`.design-system/evidence/sheet/phone-sheet-family-2026-10-17.json`) | screenshot |
| swiping | a finger on the sheet moving down, or the mouse on its grabber | let go past 30 percent of the sheet, or flick, to close it; let go short of that to keep it | the sheet under the finger with no lag and the scrim clearing with it, `data-swiping` on both | by hand |

Example: A disabled row is dimmed and skipped by the arrow keys (`docs/system/examples/dropdown-menu/state-disabled.tsx`)

```tsx
import { toast } from "sonner";

import { CopyIcon, MoreIcon, ShareIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";

const LINK = "https://example.com/lists/reading-list";

export default function Example() {
  return (
    <div className="grid w-full max-w-sm gap-2">
      <div className="flex items-center gap-3 rounded-2xl bg-muted py-1.5 ps-4 pe-1.5 text-sm">
        <span className="min-w-0 flex-1 wrap-break-word">Reading list</span>
        <DropdownMenu>
          <DropdownMenuTrigger
            render={<Button variant="ghost" size="icon" aria-label="More for Reading list" />}
          >
            <MoreIcon />
          </DropdownMenuTrigger>
          <DropdownMenuContent>
            <DropdownMenuItem
              onClick={() => {
                // The menu closes, so the copy cannot show on the row; a toast says so instead.
                navigator.clipboard.writeText(LINK).then(
                  () => toast("Link copied"),
                  () => toast("Could not copy the link"),
                );
              }}
            >
              <ShareIcon />
              Copy link
            </DropdownMenuItem>
            <DropdownMenuItem disabled>
              <CopyIcon />
              Duplicate
            </DropdownMenuItem>
          </DropdownMenuContent>
        </DropdownMenu>
      </div>
      <p className="text-sm text-muted-foreground">10 of 10 lists used. Delete one to duplicate this list.</p>
    </div>
  );
}
```

### State precedence
- Open and closed: Not applicable: a menu is one or the other.
- Highlighted and disabled: disabled wins. A disabled row takes no pointer events and the arrows skip it, so it does not highlight.
- Highlighted and destructive: both show. The destructive row highlights on the red wash with red text instead of the grey fill, `data-[variant=destructive]:focus:bg-destructive/10`.
- Open and scrolling: both show. The popup stays open and scrolls inside its max height; the trigger does not move, and a context menu stays anchored to the press point.
- Closing and open: closing wins. Once the close begins the popup takes no input until it is gone, and a press on the trigger or a second right click during the exit opens it again afterwards.
- Disabled and destructive: both show. The row is red at half opacity.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| closed to open | announce | `popup-motion` (`--t-pop`, 150ms) on `--curve`, a fade in place with no origin set | opacity | the 150ms fade stays, measured `.design-system/evidence/dropdown-menu/reduced-motion-390.json` |
| closed to open at the press point | announce | the same `popup-motion`, anchored to the press point, measured 4px from it in `.design-system/evidence/context-menu/keyboard-1280.json` | opacity | the same 150ms fade |
| open to closed | announce | `popup-motion` at 70 percent (105ms) on `--curve`, the same path back | opacity | the fade alone |
| highlight moves between rows | announce | none, the fill changes in one frame | background-color | the same |
| closed to open below 640px | announce | the menu rises from the bottom edge as a sheet on `--t-sheet` and `--curve-sheet` over the scrim, and leaves on `--t-leave`, the same motion as a Sheet's (`sheetMotionClasses`); measured its top 844, 826, 807, 783 ... 637 on 16ms frames with the scrim 0 to 1 (`.design-system/evidence/sheet/phone-sheet-family-2026-10-17.json`) | translate | a fade on `--t-fade` |
| swipe below 640px | input | none while the finger holds it; let go past 30 percent it leaves on the leave time times the flick's strength from where it is, short of that it settles back on `--t-sheet` | transform | it follows the finger; let go, it fades where it is or is back in one frame |

## Props

<!-- Props generated from registry/cobalt/ui/dropdown-menu.tsx, registry/cobalt/ui/context-menu.tsx with TypeScript by scripts/props-table.mjs -->
### DropdownMenu

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `phone?` | `"popover" \| "sheet"` | `"sheet"` | Below 640px: "sheet", a sheet along the bottom (the default), or "popover", the anchored menu. |

Also accepts from Base UI: `actionsRef`, `closeParentOnEsc`, `defaultOpen`, `defaultTriggerId`, `disabled`, `handle`, `highlightItemOnHover`, `loopFocus`, `modal`, `onItemHighlighted`, `onOpenChange`, `onOpenChangeComplete`, `open`, `orientation`, `triggerId`.

### DropdownMenuTrigger

No props of its own.

Also accepts every native `<button>` attribute; from Base UI: `closeDelay`, `delay`, `disabled`, `handle`, `nativeButton`, `openOnHover`, `payload`, `render`.

### DropdownMenuContent

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `align`, `alignOffset`, `collisionPadding`, `finalFocus`, `id`, `render`, `side`, `sideOffset`.

### DropdownMenuGroup

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `render`.

### DropdownMenuLabel

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `inset?` | `boolean` |  | `true` the label starts 36px in; `false` the label starts at the row's 10px padding. |

Also accepts every native `<div>` attribute; from Base UI: `render`.

### DropdownMenuItem

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `inset?` | `boolean` |  | `true` the label starts 36px in; `false` the label starts at the row's 10px padding. |
| `variant?` | `"default" \| "destructive"` | `"default"` | `default` a command; `destructive` a command that removes something. |

Also accepts every native `<div>` attribute; from Base UI: `closeOnClick`, `disabled`, `id`, `label`, `nativeButton`, `onClick`, `render`.

### DropdownMenuCheckboxItem

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `checked`, `closeOnClick`, `defaultChecked`, `disabled`, `id`, `label`, `nativeButton`, `onCheckedChange`, `onClick`, `render`.

### DropdownMenuSeparator

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `orientation`, `render`.

### ContextMenu

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `phone?` | `"popover" \| "sheet"` | `"sheet"` | Below 640px: "sheet", a sheet along the bottom (the default), or "popover", the menu at the finger. |

Also accepts from Base UI: `actionsRef`, `closeParentOnEsc`, `defaultOpen`, `disabled`, `highlightItemOnHover`, `loopFocus`, `onItemHighlighted`, `onOpenChange`, `onOpenChangeComplete`, `open`, `orientation`.

### ContextMenuTrigger

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `render`.

### ContextMenuContent

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `label?` | `string` | `"Actions"` | The accessible name of the menu, which has no visible trigger to take it from. |

Also accepts every native `<div>` attribute; from Base UI: `align`, `alignOffset`, `finalFocus`, `id`, `render`, `side`, `sideOffset`.

### ContextMenuItem

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `inset?` | `boolean` |  | `true` the label starts 36px in; `false` the label starts at the row's 10px padding. |
| `variant?` | `"default" \| "destructive"` | `"default"` | `default` a command; `destructive` a command that removes something. |

Also accepts every native `<div>` attribute; from Base UI: `closeOnClick`, `disabled`, `id`, `label`, `nativeButton`, `onClick`, `render`.

### ContextMenuSeparator

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `orientation`, `render`.

### ContextMenuGroup

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `render`.

`DropdownMenu` takes `phone`: `sheet` (the default) opens the menu below 640px as a sheet along the bottom of the screen, full width over the scrim, with the grabber, the same rows at 44px and the same keys, and a swipe down closes it (D8); `popover` keeps it anchored to the trigger. The root keeps an `actionsRef` of its own for the swipe's close, and uses the one you pass when you pass one. A menu closed by Escape, an outside press or a key on its trigger fades out like any other close: Base UI marks those closes instant, and the popup's `leaveFadesClasses` keeps the fade (D36). `DropdownMenu` passes every Base UI `Menu.Root` prop: `open`, `defaultOpen`, `onOpenChange`, `modal`, `disabled`. `DropdownMenuTrigger` passes `Menu.Trigger` props and takes `render` for the Button it should be. `DropdownMenuContent` passes `Menu.Popup` props, such as `finalFocus`, and picks `side` (defaults to `bottom`), `align` (`start`), `sideOffset` (4) and `alignOffset` (0) from the positioner. `DropdownMenuItem` passes `Menu.Item` props such as `disabled`, `onClick`, `closeOnClick` and `render`, and adds `variant` and `inset`. `DropdownMenuLabel` adds `inset` and must sit inside a `DropdownMenuGroup`, since Base UI throws for a group label outside a group. `DropdownMenuCheckboxItem` passes `Menu.CheckboxItem` props such as `checked`, `defaultChecked` and `onCheckedChange`, and defaults `closeOnClick` to false; use it for filters and shown columns. `menuItemClasses` is the row's class string for a component that draws a menu row outside this menu. `className` is merged last on each part and is for placement.

`ContextMenu` takes the same `phone` prop: `sheet` (the default) opens the rows below 640px as the menu's phone sheet, and `popover` keeps the menu at the finger. It passes every Base UI `ContextMenu.Root` prop: `open`, `defaultOpen`, `onOpenChange`, `disabled`, `actionsRef`. `ContextMenuTrigger` passes `ContextMenu.Trigger` props and wraps the host's element; the element inside it needs `tabIndex={0}` or to hold a control for the keyboard path. `ContextMenuContent` passes `ContextMenu.Popup` props, picks `side` (defaults to `inline-end`), `align` (`start`), `sideOffset` (0) and `alignOffset` (4) from the positioner, and adds `label`, the menu's accessible name, default "Actions". `ContextMenuItem` takes the same props as `DropdownMenuItem`, `variant` and `inset` included. There is no context menu label, checkbox item, radio item or submenu.

## Usage

### When to use
- A thing on screen has 2 to 5 commands and no room to show them as buttons: a card, a row, a header.
- You choose one command and the menu goes away.
- An area, a card or a row has commands you expect behind a right click or a long press, and the same commands are already behind its More button. Wrap it in a `ContextMenu`.

### When not to use
- You pick a value that stays shown, such as a sort order or a filter. Use Select or SegmentedControl instead.
- The content is a form, a list with its own focus, or anything you read before acting. Use Popover instead.
- The choice is the one next step. Use Button instead, in the view.

### Rules
- `rule/dropdown-menu-trigger-is-a-button`: When a menu opens from a control, render `DropdownMenuTrigger` through `render` with a `Button`, an icon one named by `aria-label`, instead of a bare `div` or `span`, because the trigger carries `aria-haspopup`, `aria-expanded` and the name a screen reader reads before the menu exists. Evidence: principle wcag: 4.1.2 Name, role, value, the trigger is the control you operate; principle platform: a native `<button>` is focusable and pressed by Enter and Space without extra code. Check: test `dropdown-menu.test.tsx` renders the closed menu and expects `<button`, `aria-haspopup="menu"` and the name.
  - Don't: `<DropdownMenuTrigger><MoreIcon /></DropdownMenuTrigger>`
  - Do: `<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More" />}><MoreIcon /></DropdownMenuTrigger>`
- `rule/dropdown-menu-items-that-navigate-are-links`: When an item leads to a page, render the `DropdownMenuItem` or `ContextMenuItem` through `render={<a href="..." />}` or the host's `renderLink` so it opens in a new tab and shows its address, instead of a `navigate()` call in `onClick`, because a button that navigates breaks the middle click and the new-tab path. Evidence: person D5; principle platform: a link is the element that navigates, a button is the element that acts. Check: review of every `DropdownMenuItem` and `ContextMenuItem` whose `onClick` calls a router.
  - Don't: `<DropdownMenuItem onClick={() => navigate("/lists/12")}>Open list</DropdownMenuItem>`
  - Do: `<DropdownMenuItem render={<a href="/lists/12" />}>Open list</DropdownMenuItem>`
- `rule/dropdown-menu-trigger-visible-at-rest`: When a row's commands sit behind a menu, keep its `DropdownMenuTrigger` visible at rest instead of showing it on the row's hover with `group-hover:opacity-100`, because touch has no hover and a trigger that appears on hover leaves a phone no path to the commands. Evidence: person D9; principle input: a coarse pointer has no hover state, so what hover reveals is unreachable. Check: lint trap/hover-unguarded (scripts/check-system.mjs); review of every trigger inside a `group`.
  - Don't: `<DropdownMenuTrigger className="opacity-0 group-hover:opacity-100" render={<Button variant="ghost" size="icon" aria-label="More" />}><MoreIcon /></DropdownMenuTrigger>`
  - Do: `<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More" />}><MoreIcon /></DropdownMenuTrigger>`
- `rule/dropdown-menu-destructive-last`: When a menu, from a button or a right click, holds a command that removes something, give it `variant="destructive"`, place it last and put a `DropdownMenuSeparator` or `ContextMenuSeparator` before it, because the 13px gap keeps a fast arrow press or a pointer slip from landing on Delete beside Rename, and the red text names the risk before the press. Evidence: person D13; principle heuristic: error prevention, distance and a label before an irreversible step. Check: review of every `variant="destructive"` item's position.
  - Don't: `<DropdownMenuContent><DropdownMenuItem variant="destructive">Delete</DropdownMenuItem><DropdownMenuItem>Rename</DropdownMenuItem></DropdownMenuContent>`
  - Do: `<DropdownMenuContent><DropdownMenuItem>Rename</DropdownMenuItem><DropdownMenuSeparator /><DropdownMenuItem variant="destructive">Delete list</DropdownMenuItem></DropdownMenuContent>`
- `rule/dropdown-menu-align-end-in-a-corner`: When the trigger sits at the end of a row or in a card's corner, pass `align="end"` on `DropdownMenuContent` and keep `side="bottom"` with the 4px `sideOffset`, because the one picker placement opens below the trigger and a start-aligned menu from a right corner runs past the card's edge. Evidence: person D8; measured the popup's `transform-origin` at `0px -4px`, the trigger's edge, `.design-system/evidence/dropdown-menu/grow-count-320.json`. Check: review of every trigger inside `CardAction`.
  - Don't: `<CardAction><DropdownMenu><DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More" />}><MoreIcon /></DropdownMenuTrigger><DropdownMenuContent>...</DropdownMenuContent></DropdownMenu></CardAction>`
  - Do: `<CardAction><DropdownMenu><DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More" />}><MoreIcon /></DropdownMenuTrigger><DropdownMenuContent align="end">...</DropdownMenuContent></DropdownMenu></CardAction>`
- `rule/dropdown-menu-label-inside-a-group`: When a `DropdownMenuLabel` names a set of items, put the label and the items inside one `DropdownMenuGroup`, instead of placing the label straight in `DropdownMenuContent`, because Base UI's group label needs a group around it and throws without one. Evidence: principle platform: Base UI's `Menu.GroupLabel` reads its group's id and throws outside `Menu.Group`; single use `docs/system/examples/dropdown-menu/default.tsx:110`, the labelled group sits in a `DropdownMenuGroup`. Check: review of every `DropdownMenuLabel`.
  - Don't: `<DropdownMenuContent><DropdownMenuLabel>Reading list</DropdownMenuLabel><DropdownMenuItem>Rename</DropdownMenuItem></DropdownMenuContent>`
  - Do: `<DropdownMenuContent><DropdownMenuGroup><DropdownMenuLabel>Reading list</DropdownMenuLabel><DropdownMenuItem>Rename</DropdownMenuItem></DropdownMenuGroup></DropdownMenuContent>`
- `rule/dropdown-menu-disabled-stays`: When a command cannot run now, pass `disabled` on its `DropdownMenuItem` or `ContextMenuItem` and keep it in the menu, instead of leaving it out until it can, because a row that comes and goes moves every row under it, and the half-opacity row tells you the command exists. Evidence: principle heuristic: consistency and standards, the menu keeps one shape across states; principle wcag: 3.2.4 Consistent identification, the same command in the same place. Check: test `dropdown-menu.test.tsx` expects `data-disabled:opacity-50` and `data-disabled:pointer-events-none` in `menuItemClasses`.
  - Don't: `{canDuplicate && <DropdownMenuItem>Duplicate</DropdownMenuItem>}`
  - Do: `<DropdownMenuItem disabled={!canDuplicate}>Duplicate</DropdownMenuItem>`
- `rule/context-menu-every-command-has-a-visible-path`: When an area has a context menu, show the same commands in a visible place as well, such as a `DropdownMenu` from a `Button` in the area's corner, instead of making the context menu the only way, because a right click and a long press are found by nobody who does not already know, and a screen reader cannot reach a menu with no trigger. Evidence: principle input: a right click is a discovered gesture, not a visible control; principle wcag: 2.1.1 Keyboard, every command reachable without a pointer gesture. Check: review of every `ContextMenu` for a visible path to each item.
  - Don't: `<ContextMenu><ContextMenuTrigger><Card>...</Card></ContextMenuTrigger><ContextMenuContent><ContextMenuItem>Delete list</ContextMenuItem></ContextMenuContent></ContextMenu>`
  - Do: `<ContextMenu><ContextMenuTrigger><Card><CardAction><DropdownMenu>...the same items...</DropdownMenu></CardAction></Card></ContextMenuTrigger><ContextMenuContent>...</ContextMenuContent></ContextMenu>`
- `rule/context-menu-area-is-focusable`: When the area holds no control of its own, give the element inside `ContextMenuTrigger` `tabIndex={0}`, because Shift+F10 opens the menu at the element that holds focus, and an area nothing can focus has no keyboard path. Evidence: single use registry/cobalt/ui/context-menu.tsx:51, the keyboard path reads `event.target`, so it needs a focused element inside the trigger; measured Shift+F10 on the focused area opening the menu at its centre, `.design-system/evidence/context-menu/keyboard-1280.json`. Check: review of the element inside every `ContextMenuTrigger`.
  - Don't: `<ContextMenuTrigger><div className="h-32 rounded-2xl bg-muted">Reading list</div></ContextMenuTrigger>`
  - Do: `<ContextMenuTrigger><div tabIndex={0} className="h-32 rounded-2xl bg-muted">Reading list</div></ContextMenuTrigger>`
- `rule/context-menu-same-items-as-the-menu-button`: When an area has both a context menu and a `DropdownMenu`, list the same items in the same order in both, because once you learn one list you expect the other to match, and a command in only one of them is lost to whoever uses the other. Evidence: principle wcag: 3.2.4 Consistent identification; principle heuristic: consistency and standards. Check: review of the two item lists in each pair.
  - Don't: `<ContextMenuContent><ContextMenuItem>Rename</ContextMenuItem><ContextMenuItem>Archive</ContextMenuItem></ContextMenuContent>` beside a `DropdownMenuContent` with Rename and Duplicate
  - Do: `<ContextMenuContent><ContextMenuItem>Rename</ContextMenuItem><ContextMenuItem>Duplicate</ContextMenuItem></ContextMenuContent>` beside the same two items in the `DropdownMenuContent`

### Content
- Follows `rule/writing-button-verb`.
- `rule/dropdown-menu-item-verb-label-noun`: When an item is labelled, write the verb and its object in sentence case, such as "Delete list", at most 3 words, and when a `DropdownMenuLabel` names a group, write the noun of what the group holds, such as "Reading list", because a menu is read as a list of commands and a label that is also a verb reads as one more command. Evidence: person D11; principle heuristic: match between system and the real world, the label names what happens. Check: review of the strings inside `DropdownMenuItem`, `ContextMenuItem` and `DropdownMenuLabel`.
  - Don't: `<DropdownMenuLabel>Manage</DropdownMenuLabel><DropdownMenuItem>OK</DropdownMenuItem>`
  - Do: `<DropdownMenuLabel>Reading list</DropdownMenuLabel><DropdownMenuItem>Rename</DropdownMenuItem>`
- `rule/context-menu-label-names-the-thing`: When a context menu is named, pass `label` as the object and the word "actions", such as "Reading list actions", at most 24 characters, instead of the default "Actions" alone, because the menu has no trigger text, so the name is all a screen reader says on open. Evidence: principle wcag: 4.1.2 Name, role, value, the menu's name is its only identification; person D11. Check: review of every `ContextMenuContent` without a `label`.
  - Don't: `<ContextMenuContent>...</ContextMenuContent>`
  - Do: `<ContextMenuContent label="Reading list actions">...</ContextMenuContent>`

### Anti-slop
- `rule/dropdown-menu-commands-only`: When a menu would hold a setting for the whole view, such as dense rows, or one choice from a set, put a `Switch`, `Pill` or `SegmentedControl` in a `Popover` instead of a menu row, because a menu runs commands and ticks filters or shown columns, and a setting stays visible where a row would close or hide it; `DropdownMenuRadioItem` and `DropdownMenuSub` do not exist in it, `DropdownMenuCheckboxItem` is for a set of filters or shown columns only, and the context menu has no checkbox item, so a pin there is one command that says what it does, "Pin list" or "Unpin list". Evidence: principle platform: a `menuitem` runs a command and closes, a `menuitemcheckbox` ticks one member of a set, a setting stays visible; single use registry/cobalt/ui/dropdown-menu.tsx:272-281, the export list holds a checkbox part and no radio or sub part, so a setting has nowhere else to go. Check: lint through `pnpm typecheck`, which fails an import of a part the file does not export.
  - Don't: `<DropdownMenuCheckboxItem checked={dense} onCheckedChange={setDense}>Dense rows</DropdownMenuCheckboxItem>`
  - Do: `<Popover><PopoverTrigger render={<Button variant="secondary">View</Button>} /><PopoverContent><Switch checked={dense} onCheckedChange={setDense}>Dense rows</Switch></PopoverContent></Popover>`
- `rule/dropdown-menu-no-border-or-shortcut`: When an agent writes shadcn's menu by habit, pass no `className` with `border`, `rounded-md` or `shadow-md` on `DropdownMenuContent` or `ContextMenuContent` and add no `DropdownMenuShortcut` column, because the menu is `rounded-3xl` on `shadow-floating` with no border, and the system binds no shortcuts for a column to show. Evidence: person D11; person D12. Check: lint rule/component-override (scripts/check-system.mjs).
  - Don't: `<DropdownMenuContent className="rounded-md border shadow-md"><DropdownMenuItem>Rename <DropdownMenuShortcut>⌘R</DropdownMenuShortcut></DropdownMenuItem></DropdownMenuContent>`
  - Do: `<DropdownMenuContent><DropdownMenuItem>Rename</DropdownMenuItem></DropdownMenuContent>`
- `rule/dropdown-menu-no-red-fill`: When an item removes something, use `variant="destructive"`, which is red text and a 10 percent wash under the highlight, instead of `className="bg-destructive text-white"`, because a destructive row is red text on a light wash. Evidence: person D13; measured the destructive row at 5.61:1 on the popover, `.design-system/evidence/dropdown-menu/grow-count-320.json`. Check: test `dropdown-menu.test.tsx` expects no `bg-destructive` fill in `menuItemClasses`; lint rule/component-override (scripts/check-system.mjs).
  - Don't: `<DropdownMenuItem className="bg-destructive text-white">Delete</DropdownMenuItem>`
  - Do: `<DropdownMenuItem variant="destructive">Delete list</DropdownMenuItem>`
- `rule/context-menu-no-prevent-default-on-the-area`: When the host handles `onKeyDown` on the element inside a `ContextMenuTrigger`, let the event through unless it handled that key, instead of calling `preventDefault()` on every key, because the trigger opens the menu only when the event is not already handled, so a blanket prevent switches the keyboard path off. Evidence: single use registry/cobalt/ui/context-menu.tsx:71, the trigger checks `defaultPrevented` before opening; principle wcag: 2.1.1 Keyboard. Check: review of `onKeyDown` handlers inside a `ContextMenuTrigger`.
  - Don't: `<div tabIndex={0} onKeyDown={(e) => e.preventDefault()}>Reading list</div>`
  - Do: `<div tabIndex={0} onKeyDown={(e) => { if (e.key === "Enter") open(); }}>Reading list</div>`

### Limits
- `rule/dropdown-menu-max-five-items`: When a menu, from a button or a right click, would hold more than 5 items, move the rest to the record's page, or in a `DropdownMenu` split them under 2 `DropdownMenuLabel` groups of at most 5, because at a 320px-tall viewport a menu opened 72px down has 203px, which holds the 8px padding and five 38px rows with a 3px scroll, a sixth row is out of view with nothing saying more is there, and a context menu opened lower on the screen has less. Evidence: measured 203px available, `.design-system/evidence/dropdown-menu/grow-count-320.json`; measured 38px rows on every example menu at 390 and 1440, `.design-system/evidence/dropdown-menu/measure.mjs`. Check: probe `.design-system/scripts/measure-menus-nav.mjs` at 390 by 320.
  - Don't: `<DropdownMenuContent>{seven.map((c) => <DropdownMenuItem key={c}>{c}</DropdownMenuItem>)}</DropdownMenuContent>`
  - Do: `<DropdownMenuContent><DropdownMenuItem>Rename</DropdownMenuItem><DropdownMenuItem>Duplicate</DropdownMenuItem><DropdownMenuItem render={<a href="/lists/12" />}>Open list</DropdownMenuItem></DropdownMenuContent>`

## Accessibility
Rests on Base UI `Menu`: a `<button>` trigger and a `role="menu"` popup of `role="menuitem"` rows. The context menu rests on Base UI `ContextMenu`: the host's element inside a trigger, and the same popup and rows, named by `label`.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Enter, Space or ArrowDown | the trigger | opens the menu | the first item, highlighted and focused, under React and under preact/compat alike: Preact lights the row a microtask after Base UI focuses the menu, and the highlight hands focus to it (`highlightTakesFocus`, `registry/cobalt/ui/dropdown-menu.tsx:58`); measured on the Columns menu, the first enabled row of 46, then ArrowDown on the next, in both builds, where Preact left focus on the menu before (`.design-system/evidence/dropdown-menu/grow-count-320.json`, `arrowOpen`; `.design-system/evidence/perf/menu-focus.json`) | test |
| ArrowUp | the trigger | opens the menu | the last item, focused, in both builds (`.design-system/evidence/perf/menu-focus.json`) | test |
| Shift+F10 or the ContextMenu key | an element inside a `ContextMenuTrigger` | opens the context menu at the element's centre (measured `shiftF10` in `.design-system/evidence/context-menu/keyboard-1280.json`) | the popup | by hand |
| ArrowDown or ArrowUp | an item, or a context menu's popup | moves the highlight to the next or previous enabled item, wrapping at the ends | that item | by hand |
| Home or End | an item | moves the highlight to the first or last enabled item | that item | by hand |
| A letter | an item | moves the highlight to the next item starting with it | that item | by hand |
| Enter or Space | an item | runs the command and closes the menu | the trigger, or the element that had focus inside a context menu's area (`trap/overlay-focus-return`) | by hand |
| Escape | an item | closes the menu only, before any dialog around it (`trap/escape-nested`) | the trigger, or the element that had focus inside the area, measured `afterEscape` | by hand |
| Tab | an item | closes the menu | the next tabbable element after the trigger | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| trigger | button | its text, or `aria-label` on an icon button | `aria-haspopup="menu"`, `aria-expanded`, `aria-controls`, `data-popup-open` while open | the name, "button", "menu pop-up", "collapsed" or "expanded" | test |
| context menu area | the host's own, none by default | the host's text | none from the menu; `data-slot="context-menu-trigger"` on the wrapper | nothing about the menu until it opens | test |
| popup | menu | `aria-labelledby` the trigger, or `aria-label` from `label` on a context menu, "Actions" by default | `data-open`, `tabindex="-1"` | "menu" and the name on open, then the highlighted item | by hand |
| group | group | `aria-labelledby` its `DropdownMenuLabel`, none in a context menu | none | the label when the highlight enters the group | by hand |
| checkbox item | menuitemcheckbox | its text | `aria-checked`, `data-checked`, `data-highlighted`, `aria-disabled` when disabled | the text, "menu item checkbox", "checked" or "not checked" | by hand |
| item | menuitem | its text | `data-highlighted`, `aria-disabled` and `data-disabled` when disabled, `data-variant` | the text, "menu item", "dimmed" when disabled, and its position in the menu | by hand |
| separator | separator | none | none | nothing, or "separator" in some readers | by hand |

## Tokens
| Part | State | Token |
|---|---|---|
| popup | all | `--popover`, `--popover-foreground`, `--shadow-floating` (`--elev-floating`), `--r-3xl` through `rounded-3xl`, `--pad-popup`, `--t-pop`, `--curve` |
| item | rest | `--popover-foreground`, `rounded-lg` (`--r-lg`), 38px tall, weight 400 |
| item | highlighted | `--accent`, `--accent-foreground` |
| item | destructive | `--destructive`, `--destructive` at 10 percent when highlighted, 20 percent in the dark |
| item | disabled | opacity 50 percent |
| checkbox item | checked | `--primary-ink` check, opacity 0 to 1 on `--t-press` |
| label | all | `--muted-foreground` |
| separator | all | `--border` at 50 percent |

## Related
- Popover: a small panel you read or fill in.
- Select: one value from a list, shown in the trigger afterwards.
- IconButton: the named More button the menu opens from.
- AlertDialog: asks for one decision before going on, usually before something is removed.
- Card: the area a context menu most often sits on.
- Grow: a button that expands into a small panel.
- Sheet: holds a task that is taller than a dialog, floating in from the side of the page.
- Collapsible: more detail that opens in place, when nothing is chosen.
- CommandPalette: commands and records found by typing, from any page.
- Item: rows that stay on the page and open or act when pressed.
