# Dropdown Menu

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/dropdown-menu
- **Markdown:** https://refast.fastapicloud.dev/docs/components/dropdown-menu.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/buttons/dropdown_menu.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

A floating menu triggered by a button click. Supports labels, separators, icons,
keyboard shortcuts, checkbox items, radio groups, and nested submenus.

```python
from refast.components.shadcn.overlay import (
    DropdownMenu, DropdownMenuTrigger, DropdownMenuContent,
    DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator,
)
from refast.components import Button

DropdownMenu(
    children=[
        DropdownMenuTrigger(Button("Options")),
        DropdownMenuContent(
            DropdownMenuLabel("Actions"),
            DropdownMenuSeparator(),
            DropdownMenuItem("Edit", icon="edit", on_select=ctx.callback(handle_edit)),
            DropdownMenuItem("Delete", icon="trash", on_select=ctx.callback(handle_delete)),
        ),
    ]
)
```

```python
DropdownMenu(
    children=[
        DropdownMenuTrigger(Button("Open Menu")),
        DropdownMenuContent(
            DropdownMenuLabel("My Account"),
            DropdownMenuSeparator(),
            DropdownMenuItem("Profile", icon="user", shortcut="⇧⌘P",
                            on_select=ctx.callback(handle_select)),
            ...
        ),
    ]
)
```

## Component Reference

### DropdownMenu

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `open` | `bool \| None` | `None` | Controlled open state |
| `default_open` | `bool` | `False` | Initial open state (uncontrolled) |
| `on_open_change` | `Callback \| None` | `None` | Called when open state changes |
| `children` | `list` | *(required)* | Must contain `DropdownMenuTrigger` and `DropdownMenuContent` |

### DropdownMenuContent

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Which side to open toward |
| `side_offset` | `int` | `4` | Pixel gap from the trigger |
| `align` | `"start" \| "center" \| "end"` | `"start"` | Alignment relative to trigger |

### DropdownMenuItem

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `label` | `str` | *(required)* | Item text |
| `icon` | `str \| None` | `None` | Lucide icon name |
| `shortcut` | `str \| None` | `None` | Keyboard shortcut hint (display only) |
| `disabled` | `bool` | `False` | Greys out and prevents selection |
| `on_select` | `Callback \| None` | `None` | Called when item is selected |

### DropdownMenuLabel

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `label` | `str` | *(required)* | Section header text |
| `inset` | `bool` | `False` | Indent to align with items that have icons |

### DropdownMenuCheckboxItem

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `label` | `str` | *(required)* | Item text |
| `checked` | `bool` | `False` | Whether the checkbox is checked |
| `disabled` | `bool` | `False` | Prevents interaction |
| `on_checked_change` | `Callback \| None` | `None` | Called with new `bool` value |

### DropdownMenuRadioGroup + DropdownMenuRadioItem

```python
DropdownMenuRadioGroup(
    value="bottom",
    on_value_change=ctx.callback(handle_position),
    children=[
        DropdownMenuRadioItem("Top", value="top"),
        DropdownMenuRadioItem("Bottom", value="bottom"),
        DropdownMenuRadioItem("Right", value="right"),
    ],
)
```

| Prop (RadioGroup) | Type | Default | Description |
|---|---|---|---|
| `value` | `str` | `""` | Currently selected value |
| `on_value_change` | `Callback \| None` | `None` | Called with new selected value |

| Prop (RadioItem) | Type | Default | Description |
|---|---|---|---|
| `label` | `str` | *(required)* | Item text |
| `value` | `str` | `""` | Value emitted when selected |

### DropdownMenuSub (Submenu)

```python
DropdownMenuSub(
    children=[
        DropdownMenuSubTrigger("Share", icon="share"),
        DropdownMenuSubContent(
            children=[
                DropdownMenuItem("Email", icon="mail", on_select=ctx.callback(share_email)),
                DropdownMenuItem("Link", icon="link", on_select=ctx.callback(share_link)),
            ]
        ),
    ]
)
```

| Prop (SubTrigger) | Type | Default | Description |
|---|---|---|---|
| `label` | `str` | *(required)* | Trigger label |
| `icon` | `str \| None` | `None` | Lucide icon |
| `inset` | `bool` | `False` | Align with icon-bearing items |

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
