LineaUI.Components.Dropdown (linea_ui v0.1.1)

Copy Markdown View Source

LineOne's dropdown menu: a white box under its button with links and actions, groups split by separators, icons, a header, a search field, people.

<.dropdown id="actions" label="Dropdown">
  <.dropdown_item href="#">Action</.dropdown_item>
  <.dropdown_item phx-click="archive">Archive</.dropdown_item>
  <.dropdown_separator />
  <.dropdown_item color="error" phx-click="delete">
    <:icon><svg>…</svg></:icon>
    Delete item
  </.dropdown_item>
</.dropdown>

toggle_icon draws LineOne's flat round icon button with the three dots (the menu of a card):

<.dropdown id="card-menu" toggle_icon="dots" placement="bottom-end">
  <.dropdown_item href="#">Action</.dropdown_item>
</.dropdown>

label draws LineOne's button with its turning chevron (color and shape style it); any other trigger goes in the :toggle slot:

<.dropdown id="more">
  <:toggle><.button icon variant="flat" shape="pill" aria-label="More">⋮</.button></:toggle>
  …
</.dropdown>

The keyboard works as in a menu (↑ ↓ Home End, letters, Esc, Tab). It opens and closes from the browser (LineaUI.toggle("actions")), from the server (LineaUI.close(socket, "actions")) or from open; on_open / on_close run whoever opened or closed it.

Summary

Functions

Renders a dropdown menu.

A title over the items, as in LineOne's "HTML Content" dropdown.

An item of the menu: a link with href, navigate or patch, a button otherwise (phx-click, type="submit"...).

The search field across the menu, with LineOne's magnifier. Typing in it is not taken by the menu's keys; phx-change, phx-debounce and name pass through.

The line between two groups of items.

Functions