Dropdown menu component using Phoenix LiveView's built-in JS commands.
Zero external JS dependency — uses Phoenix.LiveView.JS for show/hide,
with the Dropdown hook handling keyboard navigation and outside-click.
Examples
<%!-- Basic action menu --%>
<.dropdown id="actions-menu">
<:trigger>
<.button variant="secondary" size="sm">
Options
<.dropdown_chevron />
</.button>
</:trigger>
<.dropdown_item phx-click="edit">Edit</.dropdown_item>
<.dropdown_item phx-click="duplicate">Duplicate</.dropdown_item>
<.dropdown_separator />
<.dropdown_item variant="danger" phx-click="delete">Delete</.dropdown_item>
</.dropdown>
<%!-- With icons and labels --%>
<.dropdown id="user-menu" align="right">
<:trigger>
<.avatar initials="KN" size="sm" class="cursor-pointer" />
</:trigger>
<.dropdown_label>Khemmanat N.</.dropdown_label>
<.dropdown_separator />
<.dropdown_item>
<:icon>
<svg class="h-4 w-4" .../>
</:icon>
Profile settings
</.dropdown_item>
<.dropdown_item phx-click="logout">Sign out</.dropdown_item>
</.dropdown>
<%!-- Grouped with labels --%>
<.dropdown id="view-menu">
<:trigger><.button variant="ghost" size="sm">View</.button></:trigger>
<.dropdown_label>Layout</.dropdown_label>
<.dropdown_item><.dropdown_check checked={@view == "list"} /> List</.dropdown_item>
<.dropdown_item><.dropdown_check checked={@view == "grid"} /> Grid</.dropdown_item>
<.dropdown_separator />
<.dropdown_label>Sort</.dropdown_label>
<.dropdown_item phx-click="sort" phx-value-by="name">Name</.dropdown_item>
<.dropdown_item phx-click="sort" phx-value-by="date">Date</.dropdown_item>
</.dropdown>
Summary
Functions
Renders a dropdown menu with trigger and menu items.
Checkmark indicator for toggleable menu items.
Chevron icon for trigger buttons — auto-rotates when open.
Individual dropdown menu item.
Section label / group header inside a dropdown.
Visual separator line between groups.
Functions
Renders a dropdown menu with trigger and menu items.
Attributes
id(:string) (required)align(:string) - Defaults to"left". Must be one of"left", or"right".class(:string) - Defaults tonil.
Slots
trigger(required)inner_block(required)
Checkmark indicator for toggleable menu items.
Attributes
checked(:boolean) - Defaults tofalse.
Chevron icon for trigger buttons — auto-rotates when open.
Attributes
class(:string) - Defaults tonil.
Individual dropdown menu item.
Attributes
variant(:string) - Defaults to"default". Must be one of"default", or"danger".disabled(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["phx-click", "phx-value", "phx-target", "href"].
Slots
iconinner_block(required)
Section label / group header inside a dropdown.
Attributes
class(:string) - Defaults tonil.
Slots
inner_block(required)
Visual separator line between groups.
Attributes
class(:string) - Defaults tonil.