LedgerUI.Components.Button (LedgerUI v0.2.0)

Copy Markdown View Source

Buttons: button/1 (filled, outlined, soft, ghost, glass, in every theme colour), button_group/1 (segmented joins), icon_button/1 (square icon-only buttons, the top bar buttons and the round "go" button) and insight_button/1 (the top bar AI insights pill).

<.button>Export report</.button>
<.button color="primary" variant="soft" size="sm">Save</.button>
<.button color="error" variant="outline" shape="pill">Delete</.button>
<.button icon color="primary" variant="soft" aria-label="IA"><.icon name="sparkles" /></.button>
<.button navigate={~p"/orders"} variant="ghost">Orders</.button>
<.button color="primary" loading={@saving}>Saving</.button>
<.button icon variant="outline" pip aria-label="Notifications"><.icon name="bell" /></.button>

<.button_group shape="pill">
  <.button variant="outline" size="sm">Day</.button>
  <.button variant="outline" size="sm">Week</.button>
</.button_group>

<.icon_button icon="plus" label="Adicionar" variant="primary" />
<.icon_button icon="notification-03" label="Notificações" variant="topbar" dot />

The default color="neutral" variant="solid" is the black button of the system. The classes are lu-b c-<color> v-<variant> s-<size> sh-<shape> (color="current" has no colour class: it takes the parent's text colour). With href, navigate or patch a link is rendered that looks the same.

canvas draws the compact lu-btn of the canvas toolbars (<.button canvas size="sm">).

loading blocks the button (no double submit) with disabled (links: aria-disabled) plus aria-busy, hides the label keeping the width and shows a spinner on top. It is not inert, so the spinner's role="status" is announced. The design's loading button has no disabled attribute: that is a documented parity exception. pip puts the notification dot on the corner of the button.

Summary

Functions

Joins buttons side by side into one segmented control.

A button that holds only an icon. Always labelled with aria-label.

The top bar pill with a count badge (New AI insights).

Functions

button(assigns)

Attributes

  • color (:string) - Defaults to "neutral". Must be one of "current", "error", "info", "mono", "neutral", "primary", "secondary", "success", "warning", or "white".
  • variant (:string) - Defaults to "solid". Must be one of "bordered", "dim", "flat", "ghost", "glass", "glow", "outline", "soft", or "solid".
  • size (:string) - Defaults to "md". Must be one of "lg", "md", "sm", "xl", or "xs".
  • shape (:string) - Defaults to "rounded". Must be one of "pill", "rounded", or "square".
  • icon (:any) - true: a square button holding only an icon (the slot; pass aria-label). An icon name ("plus", "huge-plus"): that icon before the label. Defaults to false.
  • control (:boolean) - Kept for compatibility; buttons and fields of a size share one height. Defaults to false.
  • canvas (:boolean) - The compact canvas toolbar button (lu-btn, sm/lg from size): color, variant and shape do not apply. Defaults to false.
  • type (:string) - Defaults to "button".
  • disabled (:boolean) - Defaults to false.
  • loading (:boolean) - Disables the button (no clicks), marks it aria-busy, shows a spinner (announced: not inert). Defaults to false.
  • pip (:boolean) - The notification dot on the corner. Defaults to false.
  • loading_label (:string) - Read by screen readers for the spinner. Defaults to "Loading".
  • class (:any) - Defaults to nil.
  • style (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "download", "target", "rel", "replace", "form", "name", "value"].

Slots

  • inner_block (required)

button_group(assigns)

Joins buttons side by side into one segmented control.

Attributes

  • shape (:string) - Defaults to "rounded". Must be one of "rounded", or "pill".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

icon_button(assigns)

A button that holds only an icon. Always labelled with aria-label.

<.icon_button icon="download" label="Baixar" />
<.icon_button icon="trash" label="Excluir" variant="danger-soft" size="sm" />
<.icon_button icon="bell" label="Notificações" variant="topbar" dot />

Attributes

  • icon (:string) (required) - Icon name.
  • label (:string) (required) - The aria-label (and the only text of the button).
  • variant (:string) - topbar is the 40x40 top bar button (lu-tbtn), go the round teal arrow button; solid, glow, outline, bordered, flat, glass, dim (and soft, ghost) with a color are the variants of button/1. Defaults to "default". Must be one of "accent", "danger-soft", "default", "ghost", "primary", "soft", "topbar", "go", "solid", "glow", "outline", "soft", "bordered", "flat", "glass", "ghost", or "dim".
  • color (:string) - Given (or with shape, a button/1 variant or size xs/xl), the button is button/1's, icon only. Defaults to nil. Must be one of nil, "current", "error", "info", "mono", "neutral", "primary", "secondary", "success", "warning", or "white".
  • shape (:string) - rounded, pill or square (the default of the button/1 form). Defaults to nil. Must be one of nil, "pill", "rounded", or "square".
  • size (:string) - Square buttons only; xs and xl are those of button/1. Defaults to "md". Must be one of "xs", "sm", "md", "lg", or "xl".
  • dot (:boolean) - A red dot for something new (topbar only). Defaults to false.
  • type (:string) - Defaults to "button".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

insight_button(assigns)

The top bar pill with a count badge (New AI insights).

Attributes

  • count (:any) - The number in the square badge. Defaults to nil.
  • type (:string) - Defaults to "button".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)