# `LedgerUI.Components.Dropdown`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/dropdown.ex#L1)

Dropdown menu: a button (or any trigger) that opens a floating menu of links and actions.

    <.dropdown id="actions" label="Ações">
      <.dropdown_item phx-click="edit"><:icon><.icon name="edit" /></:icon>Editar</.dropdown_item>
      <.dropdown_separator />
      <.dropdown_item danger phx-click="delete">Excluir</.dropdown_item>
    </.dropdown>

    <.dropdown id="row" toggle_icon="dots" toggle_label="Mais ações" placement="bottom-end">
      <.dropdown_item href="#">Abrir</.dropdown_item>
    </.dropdown>

## Markup

The root is the `lu-anc` anchor; the menu is `span.fl.p-<placement>` holding the `lu-pop`
box. Everything dynamic (open state, ARIA, positioning, keys, click outside, scroll
following, flipping) is done by the hook `LedgerUI.Dropdown`
(`priv/static/ledger_ui/hooks/dropdown.js`), which puts the menu in the top layer
(`popover="manual"`, `position: fixed`) under the trigger. The server renders the ARIA and the
initial state: `popover="manual"` on the menu, `role="menu"` on the box, `role="menuitem"`
(`menuitemcheckbox`/`menuitemradio`, `separator`) on the parts and, on the built-in triggers,
`aria-haspopup="menu"`, `aria-expanded` and `aria-controls`; the hook only flips
`aria-expanded` and the open state. A custom `:toggle` slot receives those trigger attributes
as its argument (`<:toggle :let={t}><button {t}>...</button></:toggle>`); when it does not
spread them the hook falls back to setting `aria-haspopup`/`aria-controls` on that trigger.
Options that differ from the defaults reach the hook as `data-*`
attributes on the root (`data-offset`, `data-hover`, `data-keep-submenus`,
`data-close-on-select`, `data-on-open`, `data-on-close`).

`LedgerUI.open/close/toggle` work with the dropdown `id`.

## Additions to the design README

  * `menu_style` - inline style of the menu box (`width:220px`); `anchor_class` - extra
    classes of the root.
  * `:overlay` slot - extra content after the menu inside the anchor (a demo cursor).
  * `dropdown_item` accepts `danger`, `selected` and a `:trailing` slot.

# `dropdown`

## Attributes

* `id` (`:string`) (required)
* `label` (`:string`) - Defaults to `nil`.
* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, `"error"`, or `"mono"`.
* `toggle_icon` (`:string`) - Defaults to `nil`.Must be one of `nil`, `""`, `"dots"`, or `"dots-vertical"`.
* `toggle_class` (`:any`) - Defaults to `nil`.
* `toggle_label` (`:string`) - Defaults to `"Menu"`.
* `shape` (`:string`) - Defaults to `nil`.Must be one of `nil`, `""`, `"rounded"`, `"pill"`, or `"square"`.
* `control` (`:boolean`) - Defaults to `false`.
* `open` (`:boolean`) - Defaults to `false`.
* `hover` (`:boolean`) - Defaults to `false`.
* `placement` (`:string`) - Defaults to `"bottom-start"`. Must be one of `"bottom-start"`, `"bottom"`, `"bottom-end"`, `"top-start"`, `"top"`, `"top-end"`, `"left-start"`, `"left"`, `"left-end"`, `"right-start"`, `"right"`, or `"right-end"`.
* `offset` (`:integer`) - Defaults to `4`.
* `close_on_select` (`:boolean`) - Defaults to `true`.
* `keep_submenus` (`:boolean`) - Defaults to `false`.
* `on_open` (`:any`) - Defaults to `nil`.
* `on_close` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Merged into the menu box. Defaults to `nil`.
* `menu_style` (`:string`) - Defaults to `nil`.
* `anchor_class` (`:any`) - Extra classes of the `lu-anc` root. Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `action` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `type` (`:string`)
  * `disabled` (`:boolean`)
  * `class` (`:any`)
  * `id` (`:string`)
  * `phx-click` (`:any`)
  * `phx-target` (`:any`)
  * `phx-value-id` (`:any`)
* `inner_block` (required)
* `toggle`
* `trigger` - The label of the button that opens the menu, as markup (instead of `label`).
* `overlay`

# `dropdown_checkbox`

## Attributes

* `checked` (`:boolean`) - Defaults to `false`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:string`) - Defaults to `"true"`.
* `id` (`:string`) - Defaults to `nil`.
* `count` (`:any`) - Defaults to `nil`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form"]`.
## Slots

* `inner_block` (required)

# `dropdown_footer`

## Attributes

* `locale` (`:string`) - Defaults to `"en"`. Must be one of `"en"`, or `"pt_BR"`.
* `clear_label` (`:string`) - Defaults to `nil`.
* `apply_label` (`:string`) - Defaults to `nil`.
* `apply_count` (`:integer`) - Defaults to `nil`.
* `on_clear` (`:any`) - Defaults to `nil`.
* `on_apply` (`:any`) - Defaults to `nil`.
* `close_on_apply` (`:boolean`) - Defaults to `true`.
* `apply_color` (`:string`) - Defaults to `"primary"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, `"error"`, or `"mono"`.
* `show_apply` (`:boolean`) - Defaults to `true`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `dropdown_header`

## Attributes

* `subtitle` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `dropdown_item`

## Attributes

* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, or `"error"`.
* `variant` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, or `"media"`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `shortcut` (`:string`) - Defaults to `nil`.
* `type` (`:string`) - Defaults to `"button"`.
* `danger` (`:boolean`) - Defaults to `false`.
* `selected` (`:boolean`) - Check mark at the end. Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace", "download", "target", "rel", "hreflang", "referrerpolicy", "form", "name", "value"]`.
## Slots

* `icon`
* `trailing`
* `inner_block` (required)

# `dropdown_label`

## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `dropdown_radio`

## Attributes

* `checked` (`:boolean`) - Defaults to `false`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:string`) - Defaults to `"true"`.
* `id` (`:string`) - Defaults to `nil`.
* `count` (`:any`) - Defaults to `nil`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form"]`.
## Slots

* `inner_block` (required)

# `dropdown_search`

## Attributes

* `placeholder` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["phx-debounce", "phx-throttle", "autocomplete", "form"]`.

# `dropdown_separator`

## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `dropdown_submenu`

## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `label` (`:string`) (required)
* `placement` (`:string`) - Defaults to `"right"`. Must be one of `"right"`, or `"left"`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* `trigger_class` (`:any`) - Defaults to `nil`.
* `count` (`:integer`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `icon`
* `inner_block` (required)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
