# Menu

> A button-triggered list of actions, with groups, submenus and filtering.

```tsx title="hero.tsx"
import { Button } from '@langgenius/dify-ui/button'
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@langgenius/dify-ui/menu'

const actions = [
  { label: 'Edit info', icon: 'i-ri-edit-line' },
  { label: 'Duplicate', icon: 'i-ri-file-copy-line' },
  { label: 'Export DSL', icon: 'i-ri-download-2-line' },
] as const

export function MenuHeroDemo() {
  return (
    <Menu>
      <MenuTrigger
        render={
          <Button className="data-popup-open:bg-components-button-secondary-bg-hover data-popup-open:inset-ring-components-button-secondary-border-hover" />
        }
      >
        App actions
        <span aria-hidden="true" className="i-ri-arrow-down-s-line size-4 text-text-tertiary" />
      </MenuTrigger>
      <MenuContent align="start" className="w-44">
        {actions.map((action) => (
          <MenuItem key={action.label}>
            <span
              aria-hidden="true"
              className={`${action.icon} size-4 shrink-0 text-text-tertiary`}
            />
            {action.label}
          </MenuItem>
        ))}
        <MenuSeparator />
        <MenuItem variant="destructive">
          <span aria-hidden="true" className="i-ri-delete-bin-line size-4 shrink-0" />
          Delete
        </MenuItem>
      </MenuContent>
    </Menu>
  )
}
```

## Usage guidelines

- Use `Menu` for a list of commands that a button opens. Use `ContextMenu` for the same actions on right-click, and `Select` or `Combobox` when the user picks a value for a form or a filter.
- Open the menu with a `MenuTrigger` under its `Menu`. An icon-only trigger needs its own `aria-label`; a tooltip on it is not its name. Add the target to the name, such as "More actions for Customer support bot", when a list repeats the same trigger.
- Keep a dialog that a menu item opens as a sibling of the `Menu`, not inside `MenuContent`. The item opens it through the dialog's handle: `open(null)` when the dialog already knows its target, `openWithPayload` when the item supplies it. Do not keep an open flag in state for this.
- Use `variant="destructive"` for an item that deletes or removes, and set it apart with a `MenuSeparator`.
- Use `MenuCheckboxItem` and `MenuRadioGroup` for view settings that apply as soon as they change, such as sorting a list. Keep the selection visible with the item indicators.
- Wrap a long action list in `MenuFilterProvider` and give the `MenuInput` a name. Put the items in `MenuList`, and place the separator between groups at the start of the later `MenuGroup` so it hides with the groups that filtering removes.

## Anatomy

```tsx
import {
  Menu,
  MenuCheckboxItem,
  MenuCheckboxItemIndicator,
  MenuContent,
  MenuGroup,
  MenuGroupLabel,
  MenuItem,
  MenuLinkItem,
  MenuRadioGroup,
  MenuRadioItem,
  MenuRadioItemIndicator,
  MenuSeparator,
  MenuSubmenu,
  MenuSubmenuTrigger,
  MenuTrigger,
} from '@langgenius/dify-ui/menu'
```

```tsx
<Menu>
  <MenuTrigger />
  <MenuContent>
    <MenuItem />
    <MenuLinkItem />
    <MenuSeparator />
    <MenuGroup>
      <MenuGroupLabel />
      <MenuRadioGroup>
        <MenuRadioItem>
          <MenuRadioItemIndicator />
        </MenuRadioItem>
      </MenuRadioGroup>
    </MenuGroup>
    <MenuCheckboxItem>
      <MenuCheckboxItemIndicator />
    </MenuCheckboxItem>
    <MenuSubmenu>
      <MenuSubmenuTrigger />
      <MenuContent />
    </MenuSubmenu>
  </MenuContent>
</Menu>
```

A filterable menu wraps the root in `MenuFilterProvider` and fills `MenuContent` with `MenuInputGroup` (holding `MenuInput` and `MenuClear`), `MenuEmpty` and `MenuList`.

`MenuContent` bundles the portal, positioner and styled popup. Compose `MenuPortal`, `MenuPositioner` and `MenuPopup` only when the positioner needs props that `MenuContent` does not take.

## Examples

### Opening a dialog from an item

Each row has its own menu, and one `AlertDialog` serves the whole list. The Clear logs item calls `openWithPayload` on the dialog's handle with its app, and the dialog reads the payload of the session.

```tsx title="open-dialog.tsx"
import {
  AlertDialog,
  AlertDialogCancelButton,
  AlertDialogConfirmButton,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  createAlertDialogHandle,
} from '@langgenius/dify-ui/alert-dialog'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@langgenius/dify-ui/menu'
import * as React from 'react'

type App = {
  id: string
  name: string
  mode: string
}

const apps: App[] = [
  { id: 'support-bot', name: 'Customer support bot', mode: 'Chatflow' },
  { id: 'release-notes', name: 'Release notes writer', mode: 'Workflow' },
  { id: 'contract-review', name: 'Contract reviewer', mode: 'Workflow' },
]

export function MenuOpenDialogDemo() {
  const [confirmDialog] = React.useState(() => createAlertDialogHandle<App>())

  return (
    <React.Fragment>
      <ul className="flex w-full max-w-sm flex-col divide-y divide-divider-subtle">
        {apps.map((app) => (
          <li key={app.id} className="flex items-center gap-3 py-2.5">
            <div className="min-w-0 flex-1">
              <p className="truncate system-sm-medium text-text-primary">{app.name}</p>
              <p className="truncate system-xs-regular text-text-tertiary">{app.mode}</p>
            </div>
            <Menu>
              <MenuTrigger
                render={
                  <IconButton
                    aria-label={`More actions for ${app.name}`}
                    className="shrink-0 active:bg-state-base-active data-popup-open:bg-state-base-hover data-popup-open:text-text-secondary"
                  >
                    <span aria-hidden="true" className="i-ri-more-fill size-4" />
                  </IconButton>
                }
              />
              <MenuContent align="end" className="w-40">
                <MenuItem>Duplicate</MenuItem>
                <MenuItem>Export DSL</MenuItem>
                <MenuSeparator />
                <MenuItem variant="destructive" onClick={() => confirmDialog.openWithPayload(app)}>
                  Clear logs
                </MenuItem>
              </MenuContent>
            </Menu>
          </li>
        ))}
      </ul>
      <AlertDialog<App> handle={confirmDialog}>
        {({ payload }) => (
          <AlertDialogContent>
            <AlertDialogHeader>
              <AlertDialogTitle>Clear logs for {payload?.name}?</AlertDialogTitle>
              <AlertDialogDescription>
                All run logs for this app are permanently removed. This cannot be undone.
              </AlertDialogDescription>
            </AlertDialogHeader>
            <AlertDialogFooter>
              <AlertDialogCancelButton>Cancel</AlertDialogCancelButton>
              <AlertDialogConfirmButton onClick={() => confirmDialog.close()}>
                Clear logs
              </AlertDialogConfirmButton>
            </AlertDialogFooter>
          </AlertDialogContent>
        )}
      </AlertDialog>
    </React.Fragment>
  )
}
```

### Checkbox and radio items

Radio items choose one option of a group and checkbox items toggle a setting. Both keep the menu open after a change, and controlling their state preserves the selection when the popup unmounts on close.

```tsx title="checkbox-radio.tsx"
import { Button } from '@langgenius/dify-ui/button'
import {
  Menu,
  MenuCheckboxItem,
  MenuCheckboxItemIndicator,
  MenuContent,
  MenuGroup,
  MenuGroupLabel,
  MenuRadioGroup,
  MenuRadioItem,
  MenuRadioItemIndicator,
  MenuSeparator,
  MenuTrigger,
} from '@langgenius/dify-ui/menu'
import * as React from 'react'

type SortOrder = 'updated' | 'created' | 'name'

export function MenuCheckboxRadioDemo() {
  const [sortOrder, setSortOrder] = React.useState<SortOrder>('updated')
  const [showArchived, setShowArchived] = React.useState(false)

  return (
    <Menu>
      <MenuTrigger
        render={
          <Button className="data-popup-open:bg-components-button-secondary-bg-hover data-popup-open:inset-ring-components-button-secondary-border-hover" />
        }
      >
        <span aria-hidden="true" className="i-ri-equalizer-line size-4" />
        View
        <span aria-hidden="true" className="i-ri-arrow-down-s-line size-4 text-text-tertiary" />
      </MenuTrigger>
      <MenuContent className="w-52">
        <MenuGroup>
          <MenuGroupLabel>Sort by</MenuGroupLabel>
          <MenuRadioGroup<SortOrder> value={sortOrder} onValueChange={setSortOrder}>
            <MenuRadioItem<SortOrder> value="updated">
              Last edited
              <MenuRadioItemIndicator />
            </MenuRadioItem>
            <MenuRadioItem<SortOrder> value="created">
              Date created
              <MenuRadioItemIndicator />
            </MenuRadioItem>
            <MenuRadioItem<SortOrder> value="name">
              Name
              <MenuRadioItemIndicator />
            </MenuRadioItem>
          </MenuRadioGroup>
        </MenuGroup>
        <MenuSeparator />
        <MenuCheckboxItem checked={showArchived} onCheckedChange={setShowArchived}>
          Show archived apps
          <MenuCheckboxItemIndicator />
        </MenuCheckboxItem>
      </MenuContent>
    </Menu>
  )
}
```

### Submenu

`MenuSubmenu` nests a second `MenuContent` behind a `MenuSubmenuTrigger`, which shows the trailing arrow.

```tsx title="submenu.tsx"
import { Button } from '@langgenius/dify-ui/button'
import {
  Menu,
  MenuContent,
  MenuItem,
  MenuSeparator,
  MenuSubmenu,
  MenuSubmenuTrigger,
  MenuTrigger,
} from '@langgenius/dify-ui/menu'

const folders = ['Product docs', 'Support tickets', 'Release notes']

export function MenuSubmenuDemo() {
  return (
    <Menu>
      <MenuTrigger
        render={
          <Button className="data-popup-open:bg-components-button-secondary-bg-hover data-popup-open:inset-ring-components-button-secondary-border-hover" />
        }
      >
        Document actions
        <span aria-hidden="true" className="i-ri-arrow-down-s-line size-4 text-text-tertiary" />
      </MenuTrigger>
      <MenuContent className="w-48">
        <MenuItem>Rename</MenuItem>
        <MenuItem>Download</MenuItem>
        <MenuSubmenu>
          <MenuSubmenuTrigger>Move to</MenuSubmenuTrigger>
          <MenuContent className="w-44">
            {folders.map((folder) => (
              <MenuItem key={folder}>{folder}</MenuItem>
            ))}
          </MenuContent>
        </MenuSubmenu>
        <MenuSeparator />
        <MenuItem disabled>Re-index</MenuItem>
        <MenuItem variant="destructive">Delete</MenuItem>
      </MenuContent>
    </Menu>
  )
}
```

### Filtering a long list

The input takes focus when the menu opens. Typing filters the items and hides groups without a match, and the arrow keys move the highlight while focus stays in the input.

```tsx title="filter.tsx"
import { Button } from '@langgenius/dify-ui/button'
import {
  Menu,
  MenuClear,
  MenuContent,
  MenuEmpty,
  MenuFilterProvider,
  MenuGroup,
  MenuGroupLabel,
  MenuInput,
  MenuInputGroup,
  MenuItem,
  MenuList,
  MenuSeparator,
  MenuTrigger,
} from '@langgenius/dify-ui/menu'

const blockGroups = [
  { label: 'Logic', blocks: ['If/Else', 'Iteration', 'Loop', 'Question classifier'] },
  {
    label: 'Transform',
    blocks: ['Code', 'Template', 'Variable aggregator', 'Parameter extractor'],
  },
  { label: 'Knowledge', blocks: ['Knowledge retrieval', 'Document extractor'] },
  { label: 'Output', blocks: ['Answer', 'End', 'HTTP request'] },
]

export function MenuFilterDemo() {
  return (
    <MenuFilterProvider>
      <Menu>
        <MenuTrigger
          render={
            <Button
              variant="secondary-accent"
              className="data-popup-open:bg-components-button-secondary-bg-hover data-popup-open:inset-ring-components-button-secondary-border-hover"
            />
          }
        >
          <span aria-hidden className="i-ri-add-line size-4" />
          Add block
        </MenuTrigger>
        <MenuContent className="w-60">
          <MenuInputGroup>
            <span
              aria-hidden
              className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
            />
            <MenuInput aria-label="Search blocks" placeholder="e.g. Knowledge retrieval" />
            <MenuClear />
          </MenuInputGroup>
          <MenuEmpty>No blocks match</MenuEmpty>
          <MenuList>
            {blockGroups.map((group, index) => (
              <MenuGroup key={group.label}>
                {index > 0 && <MenuSeparator />}
                <MenuGroupLabel>{group.label}</MenuGroupLabel>
                {group.blocks.map((block) => (
                  <MenuItem key={block}>{block}</MenuItem>
                ))}
              </MenuGroup>
            ))}
          </MenuList>
        </MenuContent>
      </Menu>
    </MenuFilterProvider>
  )
}
```

## Keyboard

| Key                           | Action                                                                                                                |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `Enter`, `Space`, `ArrowDown` | Opens the menu from a focused trigger and focuses the first item.                                                     |
| `ArrowUp`                     | Opens the menu from a focused trigger and focuses the last item.                                                      |
| `ArrowDown`, `ArrowUp`        | Moves focus between items, including disabled ones, and wraps at the ends.                                            |
| `Home`, `End`                 | Focuses the first or last item.                                                                                       |
| Printable characters          | Focuses the next item whose label starts with the typed text. In a filterable menu, they type into the input instead. |
| `Enter`, `Space`              | Activates the focused item and closes the menu. Checkbox and radio items toggle and keep the menu open.               |
| `Enter`, `ArrowRight`         | Opens the submenu of a focused submenu trigger and focuses its first item.                                            |
| `ArrowLeft`                   | Closes the submenu and returns focus to its trigger.                                                                  |
| `Escape`                      | Closes the innermost open menu. Closing the top menu returns focus to the trigger.                                    |
| `Tab`                         | Closes the menu and moves focus to the control after the trigger.                                                     |

In a right-to-left layout, `ArrowLeft` opens a submenu and `ArrowRight` closes it. In a filterable menu, focus stays in the input while `ArrowDown` and `ArrowUp` move the highlight, and `Enter` activates the highlighted item.

## API reference

### Menu

Groups all parts of a dropdown menu supporting items, submenus, checkboxes, radios, and filtering. Doesn't render its own HTML element.

Inherits `defaultOpen`, `loopFocus`, `highlightItemOnHover`, `modal`, `onOpenChange`, `onOpenChangeComplete`, `onItemHighlighted`, `open`, `orientation`, `disabled`, `closeParentOnEsc`, `actionsRef`, `triggerId`, `defaultTriggerId`, `handle`, `children` from [Base UI Menu.Root](https://base-ui.com/react/components/menu#root).

### MenuCheckboxItem

A menu item that toggles a setting on or off. Renders a `<div>` element.

Inherits `className`, `render`, `style`, `checked`, `defaultChecked`, `onCheckedChange`, `disabled`, `label`, `id`, `closeOnClick`, `nativeButton` from [Base UI Menu.CheckboxItem](https://base-ui.com/react/components/menu#checkboxitem).

**Data attributes**

| Attribute          | Description                                         |
| ------------------ | --------------------------------------------------- |
| `data-checked`     | Present when the menu checkbox item is checked.     |
| `data-unchecked`   | Present when the menu checkbox item is not checked. |
| `data-disabled`    | Present when the menu checkbox item is disabled.    |
| `data-highlighted` | Present when the menu checkbox item is highlighted. |

### MenuCheckboxItemIndicator

Indicates whether the checkbox item is ticked. Renders a `<span>` element.

Inherits `className`, `render`, `style`, `keepMounted` from [Base UI Menu.CheckboxItemIndicator](https://base-ui.com/react/components/menu#checkboxitemindicator).

**Data attributes**

| Attribute             | Description                                         |
| --------------------- | --------------------------------------------------- |
| `data-checked`        | Present when the menu checkbox item is checked.     |
| `data-unchecked`      | Present when the menu checkbox item is not checked. |
| `data-disabled`       | Present when the menu checkbox item is disabled.    |
| `data-starting-style` | Present when the indicator begins animating in.     |
| `data-ending-style`   | Present when the indicator is animating out.        |

### MenuClear

A button that clears the input text. Requires the menu to be wrapped in `Menu.FilterProvider`. Renders a `<button>` element when the input has text.

Inherits `className`, `render`, `style`, `nativeButton`, `disabled` from [Base UI Menu.Clear](https://base-ui.com/react/components/menu#clear).

**Data attributes**

| Attribute       | Description                          |
| --------------- | ------------------------------------ |
| `data-disabled` | Present when the button is disabled. |

### MenuContent

A styled menu popup bundled with a portal and positioner. Renders a `<div>` element.

**Props**

| Prop          | Type                       | Default | Description                                                                                             |
| ------------- | -------------------------- | ------- | ------------------------------------------------------------------------------------------------------- |
| `sideOffset?` | `number \| OffsetFunction` | `4`     | Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance. |
| `children`    | `React.ReactNode`          | —       | The menu items, rendered inside the popup.                                                              |

Inherits `className`, `render`, `style`, `id`, `finalFocus`, `alignOffset`, `align`, `side` from [Base UI Menu.Popup](https://base-ui.com/react/components/menu#popup).

**Data attributes**

| Attribute             | Description                                                          |
| --------------------- | -------------------------------------------------------------------- |
| `data-open`           | Present when the menu is open.                                       |
| `data-closed`         | Present when the menu is closed.                                     |
| `data-starting-style` | Present when the menu begins animating in.                           |
| `data-ending-style`   | Present when the menu is animating out.                              |
| `data-side`           | Indicates which side the popup is positioned relative to the anchor. |
| `data-align`          | Indicates how the popup is aligned relative to specified side.       |
| `data-instant`        | Present if animations should be instant.                             |

**CSS variables**

| Variable              | Type     | Description                                                                                                                |
| --------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `--available-width`   | `number` | The available width between the anchor and the edge of the viewport.                                                       |
| `--available-height`  | `number` | The available height between the anchor and the edge of the viewport.                                                      |
| `--anchor-width`      | `number` | The anchor's width.                                                                                                        |
| `--anchor-height`     | `number` | The anchor's height.                                                                                                       |
| `--transform-origin`  | `string` | The coordinates that this element is anchored to. Used for animations and transitions.                                     |
| `--positioner-width`  | `number` | The width of the menu's positioner. It is important to set `width` to this value when using CSS to animate size changes.   |
| `--positioner-height` | `number` | The height of the menu's positioner. It is important to set `height` to this value when using CSS to animate size changes. |

### MenuEmpty

A message shown when the menu has no matching items. Requires the menu to be wrapped in `Menu.FilterProvider`. Renders a `<div>` element.

Inherits `className`, `render`, `style` from [Base UI Menu.Empty](https://base-ui.com/react/components/menu#empty).

### MenuFilterProvider

Enables filtering for the menu or submenu it wraps. Add `Menu.Input` to the popup and place its items in `Menu.List`. Wrap each searchable submenu in its own provider. Doesn't render its own HTML element.

Inherits `children`, `filter`, `autoHighlight`, `locale`, `defaultValue`, `value`, `onValueChange` from [Base UI Menu.FilterProvider](https://base-ui.com/react/components/menu#filterprovider).

### MenuGroup

Groups related menu items with the corresponding label. Renders a `<div>` element.

Inherits `children`, `className`, `render`, `style` from [Base UI Menu.Group](https://base-ui.com/react/components/menu#group).

### MenuGroupLabel

An accessible label that is automatically associated with its parent group. Renders a `<div>` element.

Inherits `className`, `render`, `style` from [Base UI Menu.GroupLabel](https://base-ui.com/react/components/menu#grouplabel).

### MenuInput

A search field that filters the menu items. Requires the menu to be wrapped in `Menu.FilterProvider`. Renders an `<input>` element.

Inherits `className`, `render`, `style` from [Base UI Menu.Input](https://base-ui.com/react/components/menu#input).

**Data attributes**

| Attribute          | Description                                                                                        |
| ------------------ | -------------------------------------------------------------------------------------------------- |
| `data-highlighted` | Present while the input shows its focus ring. Cleared when keyboard navigation highlights an item. |

### MenuInputGroup

Wraps `MenuInput` and `MenuClear` on an `InputGroup` surface for filterable menus inside `MenuFilterProvider`. Renders a `<div>` element.

Accepts the props of the element it renders.

### MenuItem

An individual interactive item in the menu. Renders a `<div>` element.

**Props**

| Prop       | Type                         | Default     | Description                                       |
| ---------- | ---------------------------- | ----------- | ------------------------------------------------- |
| `variant?` | `'default' \| 'destructive'` | `'default'` | Whether the item represents a destructive action. |

Inherits `disabled`, `label`, `id`, `closeOnClick`, `className`, `render`, `style`, `nativeButton` from [Base UI Menu.Item](https://base-ui.com/react/components/menu#item).

**Data attributes**

| Attribute          | Description                                  |
| ------------------ | -------------------------------------------- |
| `data-variant`     | The item variant, set by the `variant` prop. |
| `data-highlighted` | Present when the menu item is highlighted.   |
| `data-disabled`    | Present when the menu item is disabled.      |

### MenuLinkItem

A link in the menu that can be used to navigate to a different page or section. Renders an `<a>` element.

**Props**

| Prop            | Type                         | Default     | Description                                         |
| --------------- | ---------------------------- | ----------- | --------------------------------------------------- |
| `variant?`      | `'default' \| 'destructive'` | `'default'` | Whether the item represents a destructive action.   |
| `closeOnClick?` | `boolean`                    | `true`      | Whether to close the menu when the item is clicked. |

Inherits `className`, `render`, `style`, `label`, `id` from [Base UI Menu.LinkItem](https://base-ui.com/react/components/menu#linkitem).

**Data attributes**

| Attribute          | Description                                  |
| ------------------ | -------------------------------------------- |
| `data-variant`     | The item variant, set by the `variant` prop. |
| `data-highlighted` | Present when the link is highlighted.        |

### MenuList

Groups menu items so other content, such as a filter input, can share the popup. Renders a `<div>` element.

Inherits `className`, `render`, `style` from [Base UI Menu.List](https://base-ui.com/react/components/menu#list).

### MenuPopup

A container for the menu items. Renders a `<div>` element.

Inherits `children`, `id`, `finalFocus`, `className`, `render`, `style` from [Base UI Menu.Popup](https://base-ui.com/react/components/menu#popup).

**Data attributes**

| Attribute             | Description                                                          |
| --------------------- | -------------------------------------------------------------------- |
| `data-open`           | Present when the menu is open.                                       |
| `data-closed`         | Present when the menu is closed.                                     |
| `data-starting-style` | Present when the menu begins animating in.                           |
| `data-ending-style`   | Present when the menu is animating out.                              |
| `data-side`           | Indicates which side the popup is positioned relative to the anchor. |
| `data-align`          | Indicates how the popup is aligned relative to specified side.       |
| `data-instant`        | Present if animations should be instant.                             |

### MenuPortal

A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to `<body>`. Renders a `<div>` element.

Inherits `keepMounted`, `container`, `className`, `render`, `style` from [Base UI Menu.Portal](https://base-ui.com/react/components/menu#portal).

### MenuPositioner

Positions the menu popup against the trigger. Renders a `<div>` element.

Inherits `className`, `align`, `side`, `render`, `style`, `anchor`, `positionMethod`, `sideOffset`, `alignOffset`, `collisionBoundary`, `collisionPadding`, `sticky`, `arrowPadding`, `disableAnchorTracking`, `collisionAvoidance` from [Base UI Menu.Positioner](https://base-ui.com/react/components/menu#positioner).

**Data attributes**

| Attribute            | Description                                                          |
| -------------------- | -------------------------------------------------------------------- |
| `data-open`          | Present when the menu popup is open.                                 |
| `data-closed`        | Present when the menu popup is closed.                               |
| `data-anchor-hidden` | Present when the anchor is hidden.                                   |
| `data-side`          | Indicates which side the popup is positioned relative to the anchor. |
| `data-align`         | Indicates how the popup is aligned relative to the specified side.   |

**CSS variables**

| Variable              | Type     | Description                                                                                                                |
| --------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `--available-width`   | `number` | The available width between the anchor and the edge of the viewport.                                                       |
| `--available-height`  | `number` | The available height between the anchor and the edge of the viewport.                                                      |
| `--anchor-width`      | `number` | The anchor's width.                                                                                                        |
| `--anchor-height`     | `number` | The anchor's height.                                                                                                       |
| `--transform-origin`  | `string` | The coordinates that this element is anchored to. Used for animations and transitions.                                     |
| `--positioner-width`  | `number` | The width of the menu's positioner. It is important to set `width` to this value when using CSS to animate size changes.   |
| `--positioner-height` | `number` | The height of the menu's positioner. It is important to set `height` to this value when using CSS to animate size changes. |

### MenuRadioGroup

Groups related radio items. Renders a `<div>` element.

**Props**

| Prop             | Type                                                                       | Default | Description                                                                                                                                           |
| ---------------- | -------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defaultValue?`  | `Value`                                                                    | —       | The uncontrolled value of the radio item that should be initially selected. To render a controlled radio group, use the `value` prop instead.         |
| `onValueChange?` | `((value: Value, eventDetails: MenuRadioGroupChangeEventDetails) => void)` | —       | Callback fired when the selected value changes.                                                                                                       |
| `value?`         | `Value`                                                                    | —       | The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead. |

Inherits `className`, `render`, `style`, `children`, `disabled` from [Base UI Menu.RadioGroup](https://base-ui.com/react/components/menu#radiogroup).

**Data attributes**

| Attribute       | Description                        |
| --------------- | ---------------------------------- |
| `data-disabled` | Whether the component is disabled. |

### MenuRadioItem

A menu item that works like a radio button in a given group. Renders a `<div>` element.

**Props**

| Prop    | Type    | Default | Description                                                              |
| ------- | ------- | ------- | ------------------------------------------------------------------------ |
| `value` | `Value` | —       | The value set on the surrounding radio group when this item is selected. |

Inherits `className`, `render`, `style`, `nativeButton`, `disabled`, `label`, `id`, `closeOnClick` from [Base UI Menu.RadioItem](https://base-ui.com/react/components/menu#radioitem).

**Data attributes**

| Attribute          | Description                                       |
| ------------------ | ------------------------------------------------- |
| `data-checked`     | Present when the menu radio item is selected.     |
| `data-unchecked`   | Present when the menu radio item is not selected. |
| `data-disabled`    | Present when the menu radio item is disabled.     |
| `data-highlighted` | Present when the menu radio item is highlighted.  |

### MenuRadioItemIndicator

Indicates whether the radio item is selected. Renders a `<span>` element.

Inherits `className`, `render`, `style`, `keepMounted` from [Base UI Menu.RadioItemIndicator](https://base-ui.com/react/components/menu#radioitemindicator).

**Data attributes**

| Attribute             | Description                                           |
| --------------------- | ----------------------------------------------------- |
| `data-checked`        | Present when the menu radio item is selected.         |
| `data-unchecked`      | Present when the menu radio item is not selected.     |
| `data-disabled`       | Present when the menu radio item is disabled.         |
| `data-starting-style` | Present when the radio indicator begins animating in. |
| `data-ending-style`   | Present when the radio indicator is animating out.    |

### MenuSeparator

A separator element accessible to screen readers. Renders a `<div>` element.

Inherits `orientation`, `className`, `render`, `style` from [Base UI Separator](https://base-ui.com/react/components/separator).

**Data attributes**

| Attribute          | Description                                 |
| ------------------ | ------------------------------------------- |
| `data-orientation` | Indicates the orientation of the separator. |

### MenuSubmenu

Groups all parts of a submenu. Doesn't render its own HTML element.

Inherits `onOpenChange`, `closeParentOnEsc`, `children`, `defaultOpen`, `loopFocus`, `highlightItemOnHover`, `onOpenChangeComplete`, `onItemHighlighted`, `open`, `orientation`, `disabled`, `actionsRef` from [Base UI Menu.SubmenuRoot](https://base-ui.com/react/components/menu#submenuroot).

### MenuSubmenuTrigger

A menu item that opens a submenu. Renders a `<div>` element.

**Props**

| Prop       | Type                         | Default     | Description                                       |
| ---------- | ---------------------------- | ----------- | ------------------------------------------------- |
| `variant?` | `'default' \| 'destructive'` | `'default'` | Whether the item represents a destructive action. |

Inherits `className`, `label`, `id`, `disabled`, `delay`, `closeDelay`, `openOnHover`, `render`, `style`, `nativeButton` from [Base UI Menu.SubmenuTrigger](https://base-ui.com/react/components/menu#submenutrigger).

**Data attributes**

| Attribute          | Description                                      |
| ------------------ | ------------------------------------------------ |
| `data-variant`     | The item variant, set by the `variant` prop.     |
| `data-popup-open`  | Present when the corresponding submenu is open.  |
| `data-highlighted` | Present when the submenu trigger is highlighted. |
| `data-disabled`    | Present when the submenu trigger is disabled.    |

### MenuTrigger

A button that opens the menu. Renders a `<button>` element.

Inherits `className`, `children`, `disabled`, `handle`, `payload`, `delay`, `closeDelay`, `openOnHover`, `render`, `style`, `nativeButton` from [Base UI Menu.Trigger](https://base-ui.com/react/components/menu#trigger).

**Data attributes**

| Attribute         | Description                                  |
| ----------------- | -------------------------------------------- |
| `data-popup-open` | Present when the corresponding menu is open. |
| `data-pressed`    | Present when the trigger is pressed.         |
| `data-disabled`   | Present when the trigger is disabled.        |

### createMenuHandle

Creates a new handle to connect a Menu.Root with detached Menu.Trigger components.

```ts
createMenuHandle<Payload>(): BaseMenu.Handle<Payload>
```

**Returns:** `BaseMenu.Handle<Payload>`

**Return properties**

| Member   | Type                          | Description                                                                                                                                                     |
| -------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `open`   | `(triggerId: string) => void` | Opens the menu and associates it with the trigger with the given id. This method should only be called in an event handler or an effect (not during rendering). |
| `close`  | `() => void`                  | Closes the menu. This method should only be called in an event handler or an effect (not during rendering).                                                     |
| `isOpen` | `boolean`                     | Whether the menu is currently open. Returns `false` while no root is attached to the handle.                                                                    |

### useMenuFilter

```ts
useMenuFilter(options?: GetFilterParameters): Filter
```

**Parameters**

| Parameter  | Type                  | Description |
| ---------- | --------------------- | ----------- |
| `options?` | `GetFilterParameters` | —           |

**Returns:** `Filter`

**Return properties**

| Member       | Type                                                                                  | Description                                          |
| ------------ | ------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `contains`   | `<Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean` | Returns whether the item matches the query anywhere. |
| `startsWith` | `<Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean` | Returns whether the item starts with the query.      |
| `endsWith`   | `<Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean` | Returns whether the item ends with the query.        |
