# Dropdown: an accessible actions menu

> iVOLT dropdown: an actions menu built on details/summary, promoted to the ARIA menu button pattern with arrow-key navigation. Not for site navigation.

Source: https://ivolt.intervolutions.com/components/dropdown · iVOLT 1.1.2 · English

A small menu of actions attached to a button. Without JavaScript the native `<details>` opens and closes and the items are ordinary buttons and links. With it, the menu follows the ARIA menu button pattern. This is not a navigation menu: use links, a disclosure or the drawer for that.

**CSS:** `css/components/dropdown.css`. **JS:** `@intervolutions/ivolt/dropdown` or `auto.js`.

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/dropdown/basic.html?id=fx-dropdown-basic)

```html
<details class="iv-dropdown" data-iv-component="dropdown" data-iv-placement="bottom-start">
  <summary class="iv-button iv-button--secondary">Actions</summary>
  <div class="iv-dropdown__menu">
    <button class="iv-dropdown__item" type="button">Duplicate project</button>
    <button class="iv-dropdown__item" type="button">Export as CSV</button>
    <hr class="iv-dropdown__separator">
    <a class="iv-dropdown__item" href="#dropdown-note">Read the retention policy</a>
  </div>
</details>

<p id="dropdown-note">Exported files are kept for thirty days and then deleted from the storage bucket.</p>
```

```js
// data-iv-component="dropdown"
{
  placement: "bottom-start",
}
```

## Options

| Option | Attribute | Default |
| --- | --- | --- |
| `placement` | `data-iv-placement` | `bottom-start` (`bottom-end` aligns to the end edge) |
| `closeOnSelect` | `data-iv-close-on-select` | `true` |

## Keyboard

Enter, Space or Down on the button opens the menu and focuses the first item; Up/Down move with wrap-around, Home/End jump; Escape closes and returns focus; Tab closes without trapping.

## Events

`iv:open`/`iv:close` (cancelable) and `iv:opened`/`iv:closed`; `open()`, `close()`, `toggle()`, `isOpen`.

## Common mistakes

- Using `role="menu"` for a list of navigation links.
- Menus with more than about seven items; use a page instead.

## Without JavaScript

The served markup is a `<details>` whose `<summary>` is the trigger, so the menu opens and closes natively and every item is a working button or link. The script adds the menu-button roles, arrow keys, focus return and closing on outside clicks; `destroy()` puts the served HTML back.

## Customising

Locals: `--iv-dropdown-min-width` and `--iv-dropdown-offset` (the gap between trigger and menu). Use `iv-dropdown--end` or `data-iv-placement="bottom-end"` when the trigger sits at the end of a row, so the menu opens inwards.

```
.toolbar .iv-dropdown { --iv-dropdown-min-width: 14rem; }
```

## Dropdown, select or navigation?

A dropdown runs actions: rename, duplicate, delete. To choose a value use a native [select](https://ivolt.intervolutions.com/components/form), or the [picker](https://ivolt.intervolutions.com/components/picker) when there are many options; to list pages use links, a [disclosure](https://ivolt.intervolutions.com/components/disclosure) or the [drawer](https://ivolt.intervolutions.com/components/drawer). Screen readers announce a menu as an application widget, which is wrong for a list of links.

## Class index

Parts and modifiers of this family that the examples above do not show. The full list per stylesheet lives in the [reference](https://ivolt.intervolutions.com/reference).

| Class | What it does |
| --- | --- |
| `iv-dropdown--end` | Aligns the menu with the end edge of the trigger. |
