Dropdown
color (8) · toggle_icon dots/dots-vertical · shape rounded/pill/square · split · 12 placements · items neutral/primary/error · media
A dropdown menu of choices from a button.
A click opens the menu and the highlight moves
<div class="flex flex-wrap items-center gap-2.5"> <div class="relative h-[280px] w-[300px]"> <div class="absolute top-2.5 left-5"> <.dropdown id="dd1-a" label="Ações" demo="click" highlight class="w-[220px]"> <.dropdown_item style="--dl:0s"><:icon><.icon name="edit" /></:icon>Editar</.dropdown_item> <.dropdown_item style="--dl:1s"><:icon><.icon name="copy" /></:icon>Duplicar</.dropdown_item> <.dropdown_item style="--dl:2s"><:icon><.icon name="link" /></:icon>Compartilhar</.dropdown_item> <.dropdown_item style="--dl:3s"><:icon><.icon name="folder" /></:icon>Arquivar</.dropdown_item> <.dropdown_separator /> <.dropdown_item danger><:icon><.icon name="trash" /></:icon>Excluir</.dropdown_item> </.dropdown> </div> </div> <div class="relative h-[280px] w-[300px]"> <div class="absolute top-2.5 right-5"> <.dropdown id="dd1-b" toggle_icon="dots" toggle_label="Mais ações" placement="bottom-end" demo="click" highlight class="w-[220px]"> <.dropdown_item style="--dl:0s"><:icon><.icon name="edit" /></:icon>Editar</.dropdown_item> <.dropdown_item style="--dl:1s"><:icon><.icon name="copy" /></:icon>Duplicar</.dropdown_item> <.dropdown_item style="--dl:2s"><:icon><.icon name="link" /></:icon>Compartilhar</.dropdown_item> <.dropdown_item style="--dl:3s"><:icon><.icon name="folder" /></:icon>Arquivar</.dropdown_item> <.dropdown_separator /> <.dropdown_item danger><:icon><.icon name="trash" /></:icon>Excluir</.dropdown_item> </.dropdown> </div> </div> </div>
trigger color
<div class="flex flex-wrap items-center gap-2.5"> <.dropdown :for={c <- ~w(neutral primary secondary info success warning error mono)} id={"dd2-#{c}"} label="Período" color={c}> <.dropdown_item>Hoje</.dropdown_item> </.dropdown> </div>
toggle_icon · shape · split
<div class="flex flex-wrap items-center gap-2.5"> <.dropdown id="dd3-k1" toggle_icon="dots" toggle_label="Mais" hover><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-k2" toggle_icon="dots-vertical" toggle_label="Mais"><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-k3" label="rounded"><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-k4" label="pill" shape="pill"><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-k5"><:toggle :let={trig}><.button icon="settings" aria-label="Configurações" color="neutral" variant="outline" size="md" shape="square" {trig} /></:toggle><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-s1" color="mono" toggle_label="Mais"><:action>Emitir NF-e</:action><.dropdown_item>Editar</.dropdown_item></.dropdown> <.dropdown id="dd3-s2" color="primary" toggle_label="Mais"><:action>Salvar</:action><.dropdown_item>Editar</.dropdown_item></.dropdown> </div>
items: color neutral · primary · error · variant media
<.menu_panel width="w-[280px]"> <.dropdown_item><:icon><.icon name="external" /></:icon>Abrir pedido</.dropdown_item> <.dropdown_item color="primary"><:icon><.icon name="file" /></:icon>Emitir NF-e</.dropdown_item> <.dropdown_separator /> <.dropdown_item variant="media" description="Financeiro"><:icon><.avatar initials="AN" size="30" color="t1" /></:icon>Ana Nogueira</.dropdown_item> <.dropdown_item variant="media" description="Dev"><:icon><.avatar initials="CA" size="30" color="t3" /></:icon>Carlos André</.dropdown_item> <.dropdown_separator /> <.dropdown_item color="error"><:icon><.icon name="x-circle" /></:icon>Cancelar pedido</.dropdown_item> </.menu_panel>
placement (12)
<div class="overflow-x-auto"> <div class="min-w-[640px]"> <div class="grid grid-cols-3 gap-x-4 gap-y-2"> <div :for={p <- ~w(top-start top top-end bottom-start bottom bottom-end)} class="relative flex h-[110px] items-center justify-center"> <.tooltip id={"dd-#{p}"} color="light" placement={p} text="Pedido #2491 · Pago" open><.button color="neutral" variant="outline" size="sm" shape="rounded">{p}</.button></.tooltip> </div> </div> <div class="mt-2 grid grid-cols-2 gap-x-4 gap-y-1"> <%= for {l, r} <- [{"right-start", "left-start"}, {"right", "left"}, {"right-end", "left-end"}] do %> <div class="flex h-[84px] items-center justify-start pl-4"> <.tooltip id={"dd-#{l}"} color="light" placement={l} text="Pedido #2491 · Pago" open><.button color="neutral" variant="outline" size="sm" shape="rounded">{l}</.button></.tooltip> </div> <div class="flex h-[84px] items-center justify-end pr-4"> <.tooltip id={"dd-#{r}"} color="light" placement={r} text="Pedido #2491 · Pago" open><.button color="neutral" variant="outline" size="sm" shape="rounded">{r}</.button></.tooltip> </div> <% end %> </div> </div> </div>
API values that complete the parity
<div class="grid grid-cols-3 gap-3.5"> <div class="flex flex-col items-start gap-1.5"> <.menu_panel> <.dropdown_item><:icon><.icon name="edit" /></:icon>Editar</.dropdown_item> <.dropdown_item><:icon><.icon name="copy" /></:icon>Duplicar</.dropdown_item> </.menu_panel> <span class="font-mono text-[11px] text-muted">variant=default</span> </div> </div>
trigger_style="ghost" + row_mark: the row actions, with the highlight moving (formerly action_menu)
<.dropdown id="am1" label="Ações" demo="click" highlight trigger_style="ghost" row_mark part="action-menu" placement="bottom-end" class="w-[200px]"> <.dropdown_item style="--dl:0s"><:icon><.icon name="external" /></:icon>Abrir</.dropdown_item> <.dropdown_item style="--dl:1s"><:icon><.icon name="file" /></:icon>Emitir NF-e</.dropdown_item> <.dropdown_item style="--dl:2s"><:icon><.icon name="copy" /></:icon>Duplicar</.dropdown_item> <.dropdown_item style="--dl:3s"><:icon><.icon name="trash" /></:icon>Excluir</.dropdown_item> </.dropdown> <div class="h-[200px]"></div>
Try it: the ghost trigger opens the real row actions (row_mark)
<div class="flex items-center gap-3 rounded-lg border border-line bg-panel px-3.5 py-2.5 max-w-[560px]"> <span class="flex-1 text-[13.5px]">Pedido #2491 · Mercadinho Bom Preço</span> <.dropdown id="am-live" label="Ações do pedido" trigger_style="ghost" row_mark part="action-menu" placement="bottom-end"> <.dropdown_item><:icon><.icon name="external" /></:icon>Abrir</.dropdown_item> <.dropdown_item><:icon><.icon name="file" /></:icon>Emitir NF-e</.dropdown_item> <.dropdown_item><:icon><.icon name="copy" /></:icon>Duplicar</.dropdown_item> <.dropdown_item><:icon><.icon name="trash" /></:icon>Excluir</.dropdown_item> </.dropdown> </div> <div class="h-[200px]"></div>
Usage
<.dropdown id="period"><:trigger>Out 2026</:trigger><:item>…</:item></.dropdown>
Rules
- Popover 6px from the trigger, left-aligned; Esc closes and returns focus.
API reference
Todos os function components, atributos, valores e slots que este componente cobre.
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>
Styled only with Tailwind utilities; every element carries data-part (dropdown,
dropdown-menu, pop, pop-item, pop-separator, pop-label, pop-head, pop-search,
pop-foot, pop-end, pop-kbd, dropdown-split, dropdown-kebab...). The pop-* parts and the
helpers pop_classes/1, item_classes/1... are shared with LedgerUI.Components.ContextMenu. action_button/1, the direct button of an item with
a single action, lives here too.
Markup
The root is the anchor (relative inline-flex); the menu is a span (data-part="dropdown-menu",
data-lu-placement) holding the 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.demo("click"/"loop") - the animated demo: the menu is drawn open under the trigger (no top layer) and fades in and out;highlightwalks a highlight over the items (stagger them withstyle="--dl:1s").:overlayslot - extra content after the menu inside the anchor (a demo cursor).dropdown_itemacceptsdanger,selectedand a:trailingslot,kbd(one key cap, verbatim) andtwo_line(the taller height for adescription).- Row actions (the "⋯" menu of a row):
trigger_style="ghost"(a ghost "⋯" button named bylabel, or the:triggerslot), a:titleslot (muted heading line),row_mark(tints the table row while open),part(thedata-partprefix:"action-menu"givesaction-menu/action-menu-trigger/action-menu-panel) andhook(thephx-hookname).
<.dropdown>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
id (required) |
:string |
||
label |
:string |
nil |
|
color |
:string |
"neutral" |
neutral, primary, secondary, info, success, warning, error, mono |
toggle_icon |
:string |
nil |
nil, `,dots,dots-vertical` |
toggle_class |
:any |
nil |
|
toggle_label |
:string |
"Menu" |
|
shape |
:string |
nil |
nil, `,rounded,pill,square` |
control |
:boolean |
false |
|
open |
:boolean |
false |
|
hover |
:boolean |
false |
|
placement |
:string |
"bottom-start" |
bottom-start, bottom, bottom-end, top-start, top, top-end, left-start, left, left-end, right-start, right, right-end |
offset |
:integer |
4 |
|
close_on_select |
:boolean |
true |
|
keep_submenus |
:boolean |
false |
|
on_open |
:any |
nil |
|
on_close |
:any |
nil |
|
target |
:any |
nil |
|
demo |
:string |
nil |
nil, click, loop - The animated demo: the menu is drawn open (no top layer); click presses the trigger and drops the menu, loop fades it in and out. |
highlight |
:boolean |
false |
Walks a highlight over the items (set style="--dl:1s" on each for the stagger). |
class |
:any |
nil |
Merged into the menu box. |
menu_style |
:string |
nil |
|
anchor_class |
:any |
nil |
Extra classes of the root. |
part |
:string |
"dropdown" |
The data-part prefix. "dropdown" gives dropdown/dropdown-toggle/dropdown-menu; any other value gives <part>/<part>-trigger/<part>-panel ("action-menu" is the row-actions menu). |
trigger_style |
:string |
"default" |
default, ghost - ghost is the row-actions trigger: a ghost icon button (the "⋯" icon, or the :trigger slot) whose accessible name is label, with no chevron. |
row_mark |
:boolean |
false |
While open, the hook marks the nearest [data-am-row], tr or .ledger-ctable-row with data-am-open and tints it (data-row-mark on the root). |
hook |
:string |
"LedgerUI.Dropdown" |
The phx-hook name (the row_mark attribute turns the row marking on). |
Any other HTML/phx attribute goes to the root element.
Slots:
<:action>- attrs:href,navigate,patch,type,disabled,class,id,phx-click,phx-target,phx-value-id<:inner_block>(required)<:overlay><:title>- A muted heading line at the top of the menu (data-part="pop-label").<:toggle><:trigger>- The label of the button that opens the menu, as markup (instead oflabel).
<.dropdown_item>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
color |
:string |
"neutral" |
neutral, primary, error |
variant |
:string |
"default" |
default, media |
disabled |
:boolean |
false |
|
shortcut |
:string |
nil |
|
kbd |
:string |
nil |
One key cap shown verbatim at the end (shortcut splits on spaces into one cap per key). shortcut wins when both are given. |
two_line |
:boolean |
false |
The taller item height of variant="media" for a description, keeping the plain menuitem role. |
description |
:string |
nil |
A second, muted line under the label. With variant="media" the label is always wrapped in its two-line block. |
type |
:string |
"button" |
|
danger |
:boolean |
false |
|
selected |
:boolean |
false |
Check mark at the end. |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including href, navigate, patch, method, replace, download, target, rel, hreflang, referrerpolicy, form, name, value.
Slots:
<:icon><:inner_block>(required)<:trailing>
<.dropdown_separator>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
<.menu_panel>
The menu box on its own, always visible and in the flow of the page (no trigger, no top layer, no hook):
the same surface as the open menu of dropdown/1 and context_menu/1. For a menu shown
in the page (docs, previews, a static list of actions).
<.menu_panel width="w-[230px]">
<.dropdown_item><:icon><.icon name="edit" /></:icon>Rename</.dropdown_item>
<.dropdown_separator />
<.dropdown_item danger>Delete</.dropdown_item>
</.menu_panel>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
width |
:string |
nil |
A width utility of the box ("w-[230px]"); by default min-w-[220px]. |
highlight |
:boolean |
false |
Walks a highlight over the items (set style="--dl:1s" on each for the stagger). |
class |
:any |
nil |
Layout only (mt-4). |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required) -dropdown_items, separators and labels.
<.dropdown_label>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required)
<.dropdown_header>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
subtitle |
:string |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required)
<.dropdown_search>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
placeholder |
:string |
nil |
|
name |
:string |
nil |
|
value |
:string |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including phx-debounce, phx-throttle, autocomplete, form.
<.dropdown_checkbox>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
checked |
:boolean |
false |
|
name |
:string |
nil |
|
value |
:string |
"true" |
|
id |
:string |
nil |
|
count |
:any |
nil |
|
disabled |
:boolean |
false |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including form.
Slots:
<:inner_block>(required)
<.dropdown_radio>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
checked |
:boolean |
false |
|
name |
:string |
nil |
|
value |
:string |
"true" |
|
id |
:string |
nil |
|
count |
:any |
nil |
|
disabled |
:boolean |
false |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including form.
Slots:
<:inner_block>(required)
<.dropdown_submenu>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
id |
:string |
nil |
|
label (required) |
:string |
||
placement |
:string |
"right" |
right, left |
disabled |
:boolean |
false |
|
class |
:any |
nil |
|
trigger_class |
:any |
nil |
|
count |
:integer |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:icon><:inner_block>(required)
<.dropdown_footer>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
locale |
:string |
"en" |
en, pt_BR |
clear_label |
:string |
nil |
|
apply_label |
:string |
nil |
|
apply_count |
:integer |
nil |
|
on_clear |
:any |
nil |
|
on_apply |
:any |
nil |
|
close_on_apply |
:boolean |
true |
|
apply_color |
:string |
"primary" |
neutral, primary, secondary, info, success, warning, error, mono |
show_apply |
:boolean |
true |
|
target |
:any |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
<.action_button>
A button/1-looking icon button for an item with a single action (danger makes it the error
colour). data-part="action-button".
<.action_button label="Delete" icon="huge-delete-02" danger phx-click="delete" />
| Attr | Type | Default | Values / notes |
|---|---|---|---|
label (required) |
:string |
Accessible name (aria-label). |
|
icon |
:string |
nil |
|
danger |
:boolean |
false |
|
variant |
:string |
"outline" |
solid, glow, outline, soft, bordered, flat, glass, ghost, dim |
size |
:string |
"sm" |
xs, sm, md, lg, xl |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including href, navigate, patch, method, download, target, rel, form, name, value, disabled, type.
Slots:
<:inner_block>