# Dropdown Menu

> A keyboard-navigable dropdown menu with icons, shortcuts, and danger items.

- Tier: free, MIT
- Category: Actions
- Docs: https://ui.mlola.com/docs/components/dropdown-menu

## Install

```bash
npx mlola-ui add dropdown-menu
```

```tsx
import { DropdownMenu } from "@/components/ui/dropdown-menu";
```

## Props with fixed values

| Component | Prop | Values | Default | Description |
| --- | --- | --- | --- | --- |
| DropdownMenu | `align` | `start`, `end` | `start` |  |
| DropdownMenu | `variant` | `button`, `icon` | `button` | `button` shows the trigger with a chevron; `icon` is a small icon-only trigger, such as a card's or a column's "…" menu. |

## Example

```tsx
import { DropdownMenu } from "@/components/ui/dropdown-menu";

export default function Example() {
  return (
    <DropdownMenu
      trigger="File"
      label="File"
      items={[
        { label: "New", shortcut: "⌘N" },
        { label: "Duplicate" },
        { label: "Delete", danger: true, separatorBefore: true },
      ]}
    />
  );
}
```

## The same markup without React

```html
<div class="ml-dropdown" data-ml="dropdown-menu">
  <button class="ml-dropdown-trigger" type="button" aria-haspopup="menu" aria-expanded="false">
    <span class="ml-dropdown-trigger-label">File</span>
    <svg class="mlola-glyph" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m6 9 6 6 6-6"/></svg>
  </button>
  <div class="ml-dropdown-menu" role="menu" aria-label="File" data-align="start" hidden>
    <button class="ml-dropdown-item" type="button" role="menuitem">New</button>
    <button class="ml-dropdown-item" type="button" role="menuitem">Open</button>
    <button class="ml-dropdown-item" type="button" role="menuitem" data-danger>Delete</button>
  </div>
</div>
```

Load `@mlola-ui/behavior` and call `observe()` to give this markup its keyboard and state handling.
