---
title: DropdownMenu
description: Open a compact action menu from a visible trigger.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# DropdownMenu

> Open a compact action menu from a visible trigger.

## Anatomy

```text
DropdownMenu [component; no DOM]
├── DropdownMenu.Trigger [part; slot=trigger]
├── overlay [slot]
└── positioner [internal]
    └── DropdownMenu.Content [part; slot=content]
        ├── group [slot]
        │   ├── groupLabel [slot]
        │   └── item [slot]
        ├── item [slot]
        │   ├── itemLeading [slot]
        │   ├── itemWrapper [slot]
        │   │   ├── itemLabel [slot]
        │   │   └── itemDescription [slot]
        │   └── itemTrailing [slot]
        │       ├── itemKbds [slot]
        │       ├── itemIndicator [slot]
        │       └── itemSubIndicator [slot]
        └── separator [slot]
```

Content is portaled; grouped items use the same item subtree as ungrouped items.

## Usage

Use DropdownMenu for a compact set of actions from a visible trigger. Use [Select](https://moraine.subf.dev/components/select.md)
for choosing a form value. Use [ContextMenu](https://moraine.subf.dev/components/context-menu.md) for actions at a pointer
location. Use [Popover](https://moraine.subf.dev/components/popover.md) when the content is not a list of commands. Use
[Dialog](https://moraine.subf.dev/components/dialog.md) when the user must complete a modal task.

```tsx
import { Button, DropdownMenu } from 'moraine'

export function Example() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button}>Actions</DropdownMenu.Trigger>
      <DropdownMenu.Content items={[{ label: 'Copy' }]} />
    </DropdownMenu>
  )
}
```

### Trigger and items

`DropdownMenu.Trigger` adds click, keyboard, and ARIA behavior to the element it renders. It renders
a `button`; pass `as` to render another component such as `Button`, and `disabled` to prevent
opening. Describe each action in `items`. An entry that is an array of items forms its own group, and
the menu draws a separator between groups. An item accepts `icon`, `description`, `kbds`, `disabled`,
and `variant: 'danger'`, and runs `onSelect` before the menu closes.

```tsx
<DropdownMenu>
  <DropdownMenu.Trigger as={Button} trailing="i-lucide:chevron-down">
    Account options
  </DropdownMenu.Trigger>
  <DropdownMenu.Content
    items={[
      { label: 'Edit profile', icon: 'i-lucide:user' },
      { label: 'Billing details', icon: 'i-lucide:credit-card' },
    ]}
  />
</DropdownMenu>
```

### Stateful and nested items

Control a checkbox item with `checked` and `onCheckedChange`, or omit `checked` and set
`defaultChecked` for uncontrolled state. A `radio-group` item owns the selected value for its radio
items: pass `value` and `onValueChange` (or `defaultValue` for uncontrolled state) once on the group,
and give each radio item only its `value`. Selecting a checkbox or radio item keeps the menu open.
Nested `children` create submenus. Disabled items stay visible but cannot be activated.

A parent item with `children` can take `open` and `onOpenChange` to control its submenu.
`onOpenChange` reports every open or close request from pointer, keyboard, or click interaction. With
a controlled `open`, the submenu stays at the prop value until you update it.

```tsx
<DropdownMenu.Content
  items={[
    {
      type: 'checkbox',
      label: 'Show bookmarks bar',
      checked: showBookmarks(),
      onCheckedChange: setShowBookmarks,
    },
    {
      label: 'Theme',
      children: [
        {
          type: 'radio-group',
          value: theme(),
          onValueChange: setTheme,
          items: [{ type: 'radio', label: 'System', value: 'system' }],
        },
      ],
    },
  ]}
/>
```

### Dismissal and positioning

Escape and outside interaction close the menu by default. Set `closeOnEscape={false}` or
`closeOnOutsideClick={false}` to keep it open and receive `onClosePrevented` for each blocked
attempt. `modal` hides the rest of the page from assistive technology and prevents the native action
of outside pointer presses while the menu is open. By default the menu also locks body scroll and
renders an overlay behind the content; set `preventScroll={false}` to keep the page scrollable.
`placement` (default `'bottom'`), `align`, `gutter`, `shift`, `flip`, and `slide` tune where the
content opens.

```tsx
<DropdownMenu closeOnOutsideClick={false} onClosePrevented={() => setHint(true)} flip={false}>
  {/* Trigger and Content */}
</DropdownMenu>
```

### Keyboard interaction

| Key                                                        | Description                                                               |
| ---------------------------------------------------------- | ------------------------------------------------------------------------- |
| <kbd>Enter</kbd> / <kbd>Space</kbd> / <kbd>ArrowDown</kbd> | Opens the menu from the trigger and focuses the first item.               |
| <kbd>ArrowUp</kbd>                                         | Opens the menu from the trigger and focuses the last item.                |
| <kbd>ArrowDown</kbd> / <kbd>ArrowUp</kbd>                  | Moves focus to the next or previous item.                                 |
| <kbd>Home</kbd> / <kbd>End</kbd>                           | Moves focus to the first or last item.                                    |
| Printable characters                                       | Moves focus to the next item whose text starts with the typed characters. |
| <kbd>ArrowRight</kbd>                                      | Opens the submenu of the focused item.                                    |
| <kbd>ArrowLeft</kbd>                                       | Closes the current submenu and returns to its parent item.                |
| <kbd>Enter</kbd> / <kbd>Space</kbd>                        | Activates the focused item, or opens its submenu.                         |
| <kbd>Escape</kbd>                                          | Closes the current menu layer and restores focus.                         |
| <kbd>Tab</kbd>                                             | Closes the menu.                                                          |

## Examples

### Open account actions

Compose a visible trigger with profile, billing, and shortcut items.

```tsx
import { Button, DropdownMenu } from 'moraine'
import type { DropdownMenuT } from 'moraine'

const ACTIONS = [
  { label: 'Edit profile', icon: 'i-lucide:user' },
  { label: 'Billing details', icon: 'i-lucide:credit-card' },
  { label: 'Keyboard shortcuts', icon: 'i-lucide:keyboard' },
] satisfies DropdownMenuT.Item[]

export function TriggerItems() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button} variant="outline" trailing="i-lucide:chevron-down">
        Account options
      </DropdownMenu.Trigger>
      <DropdownMenu.Content items={ACTIONS} />
    </DropdownMenu>
  )
}
```

### Toggle bookmarks and choose a theme

Keep checkbox and radio values in application state. Nested children open a theme submenu.

```tsx
import { Button, DropdownMenu } from 'moraine'
import type { DropdownMenuT } from 'moraine'
import { createMemo, createSignal } from 'solid-js'

export function StatefulItems() {
  const [showBookmarks, setShowBookmarks] = createSignal(true)
  const [theme, setTheme] = createSignal('system')

  const items = createMemo<DropdownMenuT.Item[]>(() => [
    {
      type: 'checkbox',
      label: 'Show bookmarks bar',
      checked: showBookmarks(),
      onCheckedChange: setShowBookmarks,
    },
    { type: 'separator' },
    {
      label: 'Theme',
      children: [
        {
          type: 'radio-group',
          value: theme(),
          onValueChange: setTheme,
          items: [
            { type: 'radio', label: 'Light', value: 'light' },
            { type: 'radio', label: 'Dark', value: 'dark' },
            { type: 'radio', label: 'System', value: 'system' },
          ],
        },
      ],
    },
  ])

  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button} variant="outline">
        View preferences
      </DropdownMenu.Trigger>
      <DropdownMenu.Content items={items()} />
    </DropdownMenu>
  )
}
```

### Customize a workspace project view

Toggle visible fields, include archived projects, and choose a sort order. The list updates from
application-owned state; saving a shared view stays disabled for viewers.

```tsx
import { Button, DropdownMenu } from 'moraine'
import type { DropdownMenuT } from 'moraine'
import { createMemo, createSignal, For, Show } from 'solid-js'

const PROJECTS = [
  { name: 'Design system', owner: 'Alex', updated: 3, archived: false },
  { name: 'Customer portal', owner: 'Sam', updated: 2, archived: false },
  { name: 'Website v1', owner: 'Jordan', updated: 1, archived: true },
]

export function WorkspaceView() {
  const [showArchived, setShowArchived] = createSignal(false)
  const [showOwner, setShowOwner] = createSignal(true)
  const [sort, setSort] = createSignal('updated')
  const projects = createMemo(() => {
    const includeArchived = showArchived()
    const byName = sort() === 'name'
    return PROJECTS.filter((project) => includeArchived || !project.archived).sort((a, b) =>
      byName ? a.name.localeCompare(b.name) : b.updated - a.updated,
    )
  })
  const items = createMemo<DropdownMenuT.Item[]>(() => [
    {
      type: 'group',
      label: 'Visible fields',
      items: [
        {
          type: 'checkbox',
          label: 'Project owner',
          checked: showOwner(),
          onCheckedChange: setShowOwner,
        },
        {
          type: 'checkbox',
          label: 'Archived projects',
          checked: showArchived(),
          onCheckedChange: setShowArchived,
        },
      ],
    },
    { type: 'separator' },
    {
      label: 'Sort projects',
      icon: 'i-lucide:arrow-down-wide-narrow',
      children: [
        {
          type: 'radio-group',
          value: sort(),
          onValueChange: setSort,
          items: [
            { type: 'radio', label: 'Recently updated', value: 'updated' },
            { type: 'radio', label: 'Name', value: 'name' },
          ],
        },
      ],
    },
    { type: 'separator' },
    {
      label: 'Reset view',
      icon: 'i-lucide:rotate-ccw',
      onSelect: () => {
        setShowArchived(false)
        setShowOwner(true)
        setSort('updated')
      },
    },
    {
      label: 'Save for everyone',
      description: 'Workspace administrator permission required',
      disabled: true,
      icon: 'i-lucide:lock',
    },
  ])

  return (
    <section
      class="p-4 border border-border rounded-lg bg-card max-w-lg w-full space-y-4"
      aria-label="Workspace projects"
    >
      <div class="flex flex-wrap gap-3 items-center justify-between">
        <div>
          <h4 class="text-sm font-semibold">Workspace projects</h4>
          <p class="text-xs text-muted-foreground">
            Customize this view without changing project data.
          </p>
        </div>
        <DropdownMenu>
          <DropdownMenu.Trigger as={Button} variant="outline" leading="i-lucide:sliders-horizontal">
            View
          </DropdownMenu.Trigger>
          <DropdownMenu.Content items={items()} />
        </DropdownMenu>
      </div>
      <ul class="divide-border divide-y">
        <For each={projects()}>
          {(project) => (
            <li class="text-sm py-3 flex gap-3 items-center justify-between">
              <span>
                {project.name}
                <Show when={project.archived}>
                  <span class="text-xs text-muted-foreground ms-2">Archived</span>
                </Show>
              </span>
              <Show when={showOwner()}>
                <span class="text-xs text-muted-foreground">{project.owner}</span>
              </Show>
            </li>
          )}
        </For>
      </ul>
      <p role="status" class="text-xs text-muted-foreground">
        {projects().length} projects · Sorted by {sort() === 'name' ? 'name' : 'recently updated'}
      </p>
    </section>
  )
}
```

### Switch layout and show archived

Checkbox and radio items update a live status line next to the trigger.

```tsx
import { Button, DropdownMenu } from 'moraine'
import type { DropdownMenuT } from 'moraine'
import { createMemo, createSignal } from 'solid-js'

export function CheckboxRadio() {
  const [showArchived, setShowArchived] = createSignal(false)
  const [layout, setLayout] = createSignal('grid')
  const items = createMemo<DropdownMenuT.Item[]>(() => [
    {
      type: 'checkbox',
      label: 'Show archived',
      checked: showArchived(),
      onCheckedChange: setShowArchived,
    },
    { type: 'separator' },
    {
      type: 'radio-group',
      value: layout(),
      onValueChange: setLayout,
      items: [
        { type: 'radio', label: 'Grid', value: 'grid' },
        { type: 'radio', label: 'List', value: 'list' },
      ],
    },
  ])

  return (
    <div class="flex gap-3 items-center">
      <DropdownMenu>
        <DropdownMenu.Trigger as={Button} variant="outline">
          View options
        </DropdownMenu.Trigger>
        <DropdownMenu.Content items={items()} />
      </DropdownMenu>
      <p class="text-sm text-muted-foreground">
        {layout()} layout, archived: {String(showArchived())}
      </p>
    </div>
  )
}
```

### Move a file into a folder

Nested children open a folder submenu. Download stays on the root menu.

```tsx
import { Button, DropdownMenu } from 'moraine'

export function Submenus() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button} variant="outline">
        File
      </DropdownMenu.Trigger>
      <DropdownMenu.Content
        items={[
          {
            label: 'Move to…',
            icon: 'i-lucide:folder-input',
            children: [
              {
                type: 'group',
                label: 'Folders',
                items: [
                  { label: 'Inbox', icon: 'i-lucide:inbox' },
                  { label: 'Archive', icon: 'i-lucide:archive' },
                ],
              },
            ],
          },
          { label: 'Download', icon: 'i-lucide:download' },
        ]}
      />
    </DropdownMenu>
  )
}
```

### Share with a disabled export

`kbds` displays shortcut notation. A disabled Export item stays visible but cannot be activated.

```tsx
import { Button, DropdownMenu } from 'moraine'

export function ShortcutsDisabled() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button} variant="outline">
        Share
      </DropdownMenu.Trigger>
      <DropdownMenu.Content
        items={[
          { label: 'Copy link', icon: 'i-lucide:link', kbds: ['⌘', 'C'] },
          { label: 'Export', icon: 'i-lucide:download', kbds: ['⌘', 'E'], disabled: true },
        ]}
      />
    </DropdownMenu>
  )
}
```

### Header and footer slots

Use `headerRender` and `footerRender` on `DropdownMenu.Content` to pin a user identity
banner, search input, or status bar above and below the scrollable menu items.

```tsx
import { Button, DropdownMenu } from 'moraine'

export function ContentHeaderFooter() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger as={Button} variant="outline">
        Workspace
      </DropdownMenu.Trigger>
      <DropdownMenu.Content
        headerRender={
          <div class="text-xs px-2 py-1.5 border-b border-border">
            <p class="font-medium">Acme Corp</p>
            <p class="text-muted-foreground">acme@example.com</p>
          </div>
        }
        footerRender={
          <div class="text-[11px] text-muted-foreground px-2 py-1 border-t border-border flex justify-between">
            <span>Moraine UI</span>
            <span>Free Plan</span>
          </div>
        }
        items={[
          { label: 'Settings', icon: 'i-lucide:settings' },
          { label: 'Team members', icon: 'i-lucide:users' },
          { type: 'separator' },
          { label: 'Log out', icon: 'i-lucide:log-out' },
        ]}
      />
    </DropdownMenu>
  )
}
```

## API Reference

### Attributes

| Attributes | Slot | Description |
| --- | --- | --- |
| `data-closed` | `dropdown-menu-trigger`, `dropdown-menu-content` | Present when disclosure or transition content is closed. |
| `data-disabled` | `dropdown-menu-trigger`, `dropdown-menu-item` | Present when the component, slot, or item is disabled. |
| `data-expanded` | `dropdown-menu-trigger`, `dropdown-menu-content`, `dropdown-menu-item` | Present when the panel, accordion, or menu is expanded. |
| `data-align` | `dropdown-menu-content` | Stores the resolved alignment of positioned content. |
| `data-side` | `dropdown-menu-content` | Stores the resolved floating or drawer content side. |
| `data-danger` | `dropdown-menu-item` | Present when the action has danger semantics. |
| `data-highlighted` | `dropdown-menu-item` | Present when the item is highlighted by pointer or keyboard navigation. |
| `data-selected` | `dropdown-menu-item` | Present when the item or tab is selected. |

### Props

#### DropdownMenu

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| align | 'start' \| 'center' \| 'end' \| undefined | 'start' | Alignment of the content along the cross axis relative to the anchor: `'start'`, `'center'` or `'end'`. |
| closeOnEscape | boolean \| undefined | true | Whether pressing Escape closes the menu. When `false`, Escape is ignored and `onClosePrevented`<br>is called. |
| closeOnOutsideClick | boolean \| undefined | true | Whether a pointer press or focus move outside the menu closes it. When `false`, the attempt<br>is ignored and `onClosePrevented` is called. |
| defaultOpen | boolean \| undefined | false | Initial open state when uncontrolled. Ignored when `open` is set. |
| disabled | boolean \| undefined | false | Disables the trigger so the menu cannot be opened, and closes the menu if it is open. |
| flip | boolean \| string \| undefined | true | Whether the content moves to the opposite side when the preferred `placement` does not fit.<br>A space-delimited string such as `'top left'` is an ordered list of fallback placements<br>(`top`, `bottom`, `left` or `right`, each optionally followed by `-start` or `-end`); an<br>invalid entry throws. |
| gutter | number \| undefined | 4 | Distance in pixels between the anchor and the content along the placement axis. |
| id | string \| undefined | — | Base for the generated trigger and content ids; the content id is `<id>-content`. Generated<br>when omitted. |
| modal | boolean \| undefined | false | Whether the menu is modal: while it is open, content outside it is hidden from assistive<br>technology and the native default action of outside pointer presses is prevented. Outside<br>presses still dismiss the menu unless `closeOnOutsideClick` is `false`. |
| onClosePrevented | (() => void) \| undefined | — | Called when Escape or an outside interaction tries to close the menu but `closeOnEscape` or<br>`closeOnOutsideClick` is `false`. |
| onOpenChange | ((open: boolean) => void) \| undefined | — | Called with the next open state when the user opens or closes the menu, and when `disabled`<br>becomes `true` while it is open. It fires in controlled and uncontrolled mode alike, so a<br>controlled menu must write the value back to `open`. |
| open | boolean \| undefined | — | Controlled open state. While `undefined` the menu is uncontrolled and follows `defaultOpen`;<br>update it from `onOpenChange`. |
| overflowPadding | number \| undefined | 4 | Minimum distance in pixels kept between the content and the viewport edge when `flip` and<br>`slide` position it. |
| placement | 'top' \| 'right' \| 'bottom' \| 'left' \| undefined | 'bottom' | Preferred side of the trigger the content opens on (`'top'`, `'right'`, `'bottom'` or `'left'`).<br>The content may move to another side when `flip` is enabled and the preferred side lacks space. |
| preventScroll | boolean \| undefined | true | Locks body scroll while the menu is open and renders the `overlay` slot element behind the<br>content. Set `false` to keep the page scrollable. |
| shift | number \| undefined | 0 | Offset in pixels along the cross axis, applied on top of `align`. |
| size | 'sm' \| 'md' \| 'lg' \| undefined | 'md' | Visual size of menu items. |
| slide | boolean \| undefined | true | Whether the content may slide along the edge of the anchor so it stays inside the viewport<br>instead of being clipped. |
| children | JSX.Element \| undefined | — | Composed trigger and content primitives. |
| classes | Classes \| undefined | — | Family slot class defaults for this instance. |
| styles | Styles \| undefined | — | Family slot style defaults for this instance. |

#### DropdownMenu.Trigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| disabled | boolean \| undefined | — | Whether this trigger is disabled. |
| as | T \| undefined | 'button' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Trigger label and visual content. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### DropdownMenu.Content

Props for the DropdownMenu content component.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| checkedIcon | IconT.Name \| undefined | 'icon-check' | Icon shown on checked checkbox and radio items. |
| expandIcon | IconT.Name \| undefined | 'icon-chevron-right' | Icon shown at the end of items that open a submenu. |
| footerRender | JSX.Element \| Component<FooterRenderProps> \| undefined | — | Content rendered below the item groups, in the root menu and in every submenu. A function is<br>mounted as a component and receives `{ sub }`, which is `true` inside a submenu. |
| headerRender | JSX.Element \| Component<HeaderRenderProps> \| undefined | — | Content rendered above the item groups, in the root menu and in every submenu. A function is<br>mounted as a component and receives `{ sub }`, which is `true` inside a submenu. |
| itemRender | Component<ItemRenderProps> \| undefined | — | Replaces the inner content of every item row (icon, label, description, shortcut keys, submenu<br>indicator and checkmark); the row keeps its role, keyboard handling and selection. It is<br>mounted as a component and receives `item`, `depth` (`0` in the root menu, `1` and up in<br>submenus) and `hasChildren`. Read `item.type` to tell checkbox and radio items apart. |
| items | ({<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type?: 'item';<br>  /** Controlled open state of the submenu. Only applies to items with `children`; leave it<br>`undefined` to let the item manage its own state (see `defaultOpen`). */<br>  open?: boolean;<br>  /** Initial open state of the submenu when `open` is not set. */<br>  defaultOpen?: boolean;<br>  /** Called with the next open state when the submenu opens (pointer hover delay, click or arrow<br>key) or closes. Not called when `open` is changed from outside. */<br>  onOpenChange?: (open: boolean) => void;<br>  /** Items of the submenu, in the same shape as the menu `items` (flat items and `group` objects).<br>A non-empty list makes the item open a submenu instead of calling `onSelect`, and shows the<br>menu's `expandIcon` in place of `kbds`. */<br>  children?: OverlayMenuItem[];<br>  /** Called when the item is activated by click, Enter or Space, before the whole menu closes and<br>focus returns to the trigger. Not called for disabled items or items that open a submenu. */<br>  onSelect?: () => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'checkbox';<br>  /** Controlled checked state. Leave it `undefined` to let the item manage its own state (see<br>`defaultChecked`); when set, update it from `onCheckedChange`. */<br>  checked?: boolean;<br>  /** Initial checked state when `checked` is not set. */<br>  defaultChecked?: boolean;<br>  /** Called with the next checked state each time the user toggles the item. The menu stays open. */<br>  onCheckedChange?: (checked: boolean) => void;<br>  /** Called after `onCheckedChange` each time the item is toggled. The menu stays open. */<br>  onSelect?: () => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'radio-group';<br>  /** Radio items in this group. Selecting one unchecks the others. The group's `label`, when set,<br>is rendered as its heading. */<br>  items?: OverlayMenuRadioItem[];<br>  /** Controlled selected value, matched against each radio item's `value`. Leave it `undefined`<br>to let the group manage its own state (see `defaultValue`). */<br>  value?: string;<br>  /** Initial selected value when `value` is not set. */<br>  defaultValue?: string;<br>  /** Called with the `value` of the radio item the user chose. The menu stays open. */<br>  onValueChange?: (value: string) => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'group';<br>  /** Child items in this group. The group's `label`, when set, is rendered as a non-interactive<br>heading above the items. */<br>  items?: OverlayMenuItem[];<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'separator';<br>} \| ({<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type?: 'item';<br>  /** Controlled open state of the submenu. Only applies to items with `children`; leave it<br>`undefined` to let the item manage its own state (see `defaultOpen`). */<br>  open?: boolean;<br>  /** Initial open state of the submenu when `open` is not set. */<br>  defaultOpen?: boolean;<br>  /** Called with the next open state when the submenu opens (pointer hover delay, click or arrow<br>key) or closes. Not called when `open` is changed from outside. */<br>  onOpenChange?: (open: boolean) => void;<br>  /** Items of the submenu, in the same shape as the menu `items` (flat items and `group` objects).<br>A non-empty list makes the item open a submenu instead of calling `onSelect`, and shows the<br>menu's `expandIcon` in place of `kbds`. */<br>  children?: OverlayMenuItem[];<br>  /** Called when the item is activated by click, Enter or Space, before the whole menu closes and<br>focus returns to the trigger. Not called for disabled items or items that open a submenu. */<br>  onSelect?: () => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'checkbox';<br>  /** Controlled checked state. Leave it `undefined` to let the item manage its own state (see<br>`defaultChecked`); when set, update it from `onCheckedChange`. */<br>  checked?: boolean;<br>  /** Initial checked state when `checked` is not set. */<br>  defaultChecked?: boolean;<br>  /** Called with the next checked state each time the user toggles the item. The menu stays open. */<br>  onCheckedChange?: (checked: boolean) => void;<br>  /** Called after `onCheckedChange` each time the item is toggled. The menu stays open. */<br>  onSelect?: () => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'radio-group';<br>  /** Radio items in this group. Selecting one unchecks the others. The group's `label`, when set,<br>is rendered as its heading. */<br>  items?: OverlayMenuRadioItem[];<br>  /** Controlled selected value, matched against each radio item's `value`. Leave it `undefined`<br>to let the group manage its own state (see `defaultValue`). */<br>  value?: string;<br>  /** Initial selected value when `value` is not set. */<br>  defaultValue?: string;<br>  /** Called with the `value` of the radio item the user chose. The menu stays open. */<br>  onValueChange?: (value: string) => void;<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'group';<br>  /** Child items in this group. The group's `label`, when set, is rendered as a non-interactive<br>heading above the items. */<br>  items?: OverlayMenuItem[];<br>} \| {<br>  /** Text or element shown as the item's primary text. A string `label` is also what typeahead<br>matches; otherwise the item's rendered text is used. When the menu content has an `itemRender`,<br>it replaces the default rendering of `label`, `description`, `icon` and `kbds`. */<br>  label?: JSX.Element;<br>  /** Secondary text shown below the label. */<br>  description?: JSX.Element;<br>  /** Name of the icon shown at the start of the item. */<br>  icon?: IconT.Name;<br>  /** Keys shown as keycaps at the end of the item, for example `['Ctrl', 'S']`. Display only: it<br>does not register a keyboard shortcut. Not shown on items that open a submenu. */<br>  kbds?: string[];<br>  /** Custom CSS class applied to the item element. */<br>  class?: ClassValue;<br>  /** Custom inline styles applied to the item element. */<br>  style?: JSX.CSSProperties;<br>  /** Visual treatment of the menu item. `'danger'` uses the danger text color for destructive<br>actions and sets `data-danger` on the item. */<br>  variant?: 'default' \| 'danger';<br>  /** Whether the item is non-interactive: it ignores activation (no `onSelect`, no closing) and<br>exposes `aria-disabled`. */<br>  disabled?: boolean;<br>  type: 'separator';<br>})[])[] \| undefined | — | Items rendered in the menu body. Each entry is an item object or an array of items; consecutive<br>plain entries form one group, and every array starts a new group, with a separator drawn<br>between groups. An item's `type` is `'item'` (the default), `'checkbox'`, `'radio-group'`<br>(with radio `items`), `'group'` (with a `label` and child `items`) or `'separator'`. An `'item'`<br>with `children` opens a submenu, and `onSelect` runs when an item is activated. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

**`headerRender` example**

```tsx
import { DropdownMenu } from 'moraine'

<DropdownMenu>
  <DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
  <DropdownMenu.Content
    items={[{ label: 'Rename' }]}
    headerRender={(props) => <div>{props.sub ? 'More actions' : 'Actions'}</div>}
  />
</DropdownMenu>
```

**`itemRender` example**

```tsx
import { DropdownMenu } from 'moraine'

<DropdownMenu>
  <DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
  <DropdownMenu.Content
    items={[{ label: 'Rename' }, { label: 'Share', children: [{ label: 'Copy link' }] }]}
    itemRender={(props) => (
      <span>
        {props.item.label}
        {props.hasChildren ? ' ›' : ''}
      </span>
    )}
  />
</DropdownMenu>
```

**`items` example**

```tsx
import { createSignal } from 'solid-js'
import { DropdownMenu } from 'moraine'

const [showHidden, setShowHidden] = createSignal(false)

<DropdownMenu>
  <DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
  <DropdownMenu.Content
    items={[
      [{ label: 'Rename', onSelect: () => console.log('rename') }, { label: 'Delete', variant: 'danger' }],
      [{ type: 'checkbox', label: 'Show hidden', checked: showHidden(), onCheckedChange: setShowHidden }],
      { label: 'Share', children: [{ label: 'Copy link' }] },
    ]}
  />
</DropdownMenu>
```
