---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Context menu

A menu of a target's secondary actions, opened at the pointer, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ContextMenu`.

## When to use

- A menu of a target's secondary actions, opened at the pointer.
- Also called: right-click menu.

## When not to use

- For a button's menu use DropdownMenu.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Context menu on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-context-menu.json --yes
```

```text
Add the Goop Context menu to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import {
  ContextMenu, ContextMenuTrigger, ContextMenuPortal, ContextMenuContent, ContextMenuGroup, ContextMenuLabel, ContextMenuShortcut, ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioGroup,
  ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubTrigger, ContextMenuSubContent,
} from '@/components/ui/goop/context-menu';
import { Card, CardAction, CardText, CardTitle } from '@/components/ui/goop/card';
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/goop/dropdown-menu';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';

function FileCard() {
  const rows = [
    { label: 'Open', icon: 'file' },
    { label: 'Duplicate', icon: 'copy' },
  ] as const;
  return (
    <ContextMenu>
      <ContextMenuTrigger asChild>
        <Card>
          <CardAction>
            <DropdownMenu>
              <DropdownMenuTrigger asChild>
                <IconButton variant="ghost" aria-label="Actions">
                  <IconButtonIcon icon="dots" />
                </IconButton>
              </DropdownMenuTrigger>
              <DropdownMenuContent aria-label="Actions">
                {rows.map((row) => (
                  <DropdownMenuItem key={row.label} icon={row.icon}>
                    {row.label}
                  </DropdownMenuItem>
                ))}
              </DropdownMenuContent>
            </DropdownMenu>
          </CardAction>
          <CardText>
            <CardTitle>Interview guide for Kvist Bikes</CardTitle>
          </CardText>
        </Card>
      </ContextMenuTrigger>
      <ContextMenuContent aria-label="Actions">
        {rows.map((row) => (
          <ContextMenuItem key={row.label} icon={row.icon}>
            {row.label}
          </ContextMenuItem>
        ))}
      </ContextMenuContent>
    </ContextMenu>
  );
}
```

- Fits: list, board: row.
- Also known as: Right-click menu, Long-press menu, Row actions menu.
- Never put an action in the context menu alone: a right-click, a long press and Shift+F10 are all hidden.
- More on where it goes: context-menu--options.md

## API reference

### Parts

- `ContextMenuTrigger` — The area that opens the menu
- `ContextMenuPortal` — The portal a menu's content goes through (`ContextMenuContent` writes its own)
- `ContextMenuContent` — The menu's panel (`role="menu"`, named by `aria-label`), its corner at the pointer; by the keys, below the row (above it when the room is short)
- `ContextMenuGroup` — A group of rows (`role="group"`), named by a `ContextMenuLabel` inside it
- `ContextMenuLabel` — A heading over a group of rows
- `ContextMenuShortcut` — A row's key hint
- `ContextMenuItem` — One row (`role="menuitem"`)
- `ContextMenuCheckboxItem` — A row that turns a setting on or off (`role="menuitemcheckbox"`)
- `ContextMenuRadioGroup` — A choice of one among its rows
- `ContextMenuRadioItem` — One row of a `ContextMenuRadioGroup` (`role="menuitemradio"`)
- `ContextMenuSeparator` — A line between groups of rows (`role="separator"`)
- `ContextMenuSub` — A sub menu's root
- `ContextMenuSubTrigger` — The row that opens a sub menu
- `ContextMenuSubContent` — A sub menu's panel (`role="menu"`), the menu's skin, beside its row, its first row level with it (the skin's lift, shared with the dropdown's sub menu)

### ContextMenuCheckboxItem

A row that turns a setting on or off (`role="menuitemcheckbox"`).

```tsx
import { ContextMenuCheckboxItem } from '@/components/ui/goop/context-menu';
```

### Options

- icon?: IconName — A pack icon's name, in the 16 px box before the row's words.

### ContextMenuContent

The menu's panel (`role="menu"`, named by `aria-label`), its corner at the pointer; by the keys, below the row (above it when the room is short).

```tsx
import { ContextMenuContent } from '@/components/ui/goop/context-menu';
```

### Options

- container?: HTMLElement | null — Where the layer is portalled; the end of `<body>` when left out.

### ContextMenuGroup

A group of rows (`role="group"`), named by a `ContextMenuLabel` inside it.

```tsx
import { ContextMenuGroup } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuItem

One row (`role="menuitem"`).

```tsx
import { ContextMenuItem } from '@/components/ui/goop/context-menu';
```

### Options

- icon?: IconName — A pack icon's name, in the 16 px box before the row's words.
- variant?: 'default' | 'destructive' = 'default' — `destructive`: the row that deletes or cannot be undone — its words, icon and wash in the theme's red.

### ContextMenuLabel

A heading over a group of rows.

```tsx
import { ContextMenuLabel } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenu: every option

```tsx
import { ContextMenu } from '@/components/ui/goop/context-menu';
```

### Compose

- Pair it with a visible more-actions IconButton (`dots`) opening a DropdownMenu of the same rows: one array mapped into both.

### Options

### ContextMenuPortal

The portal a menu's content goes through (`ContextMenuContent` writes its own).

```tsx
import { ContextMenuPortal } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuRadioGroup

A choice of one among its rows.

```tsx
import { ContextMenuRadioGroup } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuRadioItem

One row of a `ContextMenuRadioGroup` (`role="menuitemradio"`).

```tsx
import { ContextMenuRadioItem } from '@/components/ui/goop/context-menu';
```

### Options

- icon?: IconName — A pack icon's name, in the 16 px box before the row's words.

### ContextMenuSeparator

A line between groups of rows (`role="separator"`).

```tsx
import { ContextMenuSeparator } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuShortcut

A row's key hint.

```tsx
import { ContextMenuShortcut } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuSubContent

A sub menu's panel (`role="menu"`), the menu's skin, beside its row, its first row level with it (the skin's lift, shared with the dropdown's sub menu).

```tsx
import { ContextMenuSubContent } from '@/components/ui/goop/context-menu';
```

### Options

- container?: HTMLElement | null — Where the layer is portalled; the end of `<body>` when left out.

### ContextMenuSubTrigger

The row that opens a sub menu.

```tsx
import { ContextMenuSubTrigger } from '@/components/ui/goop/context-menu';
```

### Options

- icon?: IconName — A pack icon's name, in the 16 px box before the row's words.

### ContextMenuSub

A sub menu's root.

```tsx
import { ContextMenuSub } from '@/components/ui/goop/context-menu';
```

### Options

### ContextMenuTrigger

The area that opens the menu.

```tsx
import { ContextMenuTrigger } from '@/components/ui/goop/context-menu';
```

### Options

- Also takes: asChild?: boolean

## Keyboard

- Shift+F10 / ContextMenu: on the focused target: open the menu just below its row at its start edge (above the row where the room below is short), the first row active, the browser's own menu kept shut
- ArrowDown / ArrowUp: move the active row, skipping a disabled one
- Home / End: first or last row

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Shortened to fit: the data-slot values, what the part already sets; what else went is in agent/ship/manifest.json.

## Related

- [Dropdown menu](/themes/trail/components/dropdown-menu): A menu of actions.
- [Card](/themes/trail/components/card): A framed surface that holds one piece of content or a list of settings rows.
- [Icon button](/themes/trail/components/icon-button): A button whose only visible label is one icon, for toolbars, rows and headers.
- [Command](/themes/trail/components/command): A list of actions or options narrowed by typing.
