LineaUI.Components.MenuList (linea_ui v0.1.1)

Copy Markdown View Source

LineOne's menu lists: a vertical list of links with one active entry.

<.menu_list variant="solid">
  <:item navigate={~p"/start"} active>Getting start</:item>
  <:item navigate={~p"/shipping"}>Shipping</:item>
</.menu_list>

An icon is the first child of an item; LineOne's icon colors (muted, darker on hover, current color when active) come with it:

<:item href="#"><svg class="size-5">…</svg><span>Payments</span></:item>

A trailing count (a badge, a number) goes in the :count slot of a menu_item, or in the count attr of an :item; it is pushed to the end of the row:

<.menu_item navigate="/inbox" variant="solid">
  <:icon><svg class="size-5">…</svg></:icon>
  Inbox
  <:count><.badge size="sm" shape="pill">12</.badge></:count>
</.menu_item>

variant follows LineOne's examples: link (text only), solid (filled; color picks primary or neutral), pill (rounded-full with a tinted hover), gradient and bordered.

Items that are not links take on_select (an event name or %JS{}), pushed with %{"value" => item_value}:

<.menu_list on_select="pick">
  <:item value="shipping">Shipping</:item>
</.menu_list>

Streams render one menu_item per row:

<.menu_list id="pages" rows={@streams.pages}>
  <:row :let={{_id, page}}>
    <.menu_item navigate={page.path} active={page.id == @current}>{page.title}</.menu_item>
  </:row>
</.menu_list>

Summary

Functions

Renders one entry of a menu list as a link (href, navigate, patch) or, without one, a link-styled button that pushes on_select with %{"value" => value}. Used alone or in a menu_list :row.

Renders the list. Items come from :item slots (each takes href/navigate/patch, active, value, and any HTML attribute), or from rows with a :row slot.

Functions