LedgerUI.Components.Badge (LedgerUI v0.2.0)

Copy Markdown View Source

Badges: filled, glowing, soft, outlined or bare text, with a dot, an icon or a remove button.

<.badge>Default</.badge>
<.badge color="success" shape="pill">Paid</.badge>
<.badge color="primary" variant="soft" dot>Online</.badge>
<.badge color="error" variant="outline" shape="pill">Error</.badge>
<.badge on_remove={JS.hide()}>Filter</.badge>

With canvas the badge is the compact canvas lu-badge (tinted by color: primary, success, error, warning, info, lime; variant solid/outline; size sm/lg), which is what tables and KPI rows use.

shape defaults to nil, the rounded look of the theme; "rounded" adds the explicit class. The root style is rendered (empty) unless style={false}.

Summary

Functions

badge(assigns)

Attributes

  • color (:string) - Defaults to "neutral". Must be one of "neutral", "primary", "secondary", "info", "success", "warning", "error", "dark", "light", "white", or "lime".
  • variant (:string) - Defaults to "soft". Must be one of "solid", "glow", "soft", "outline", or "flat".
  • size (:string) - Defaults to nil.Must be one of nil, "xs", "sm", "md", "lg", or "xl".
  • shape (:string) - Defaults to nil.Must be one of nil, "rounded", "pill", or "square".
  • dot (:any) - A dot before the content; "live" pulses. Defaults to false.
  • canvas (:boolean) - The compact canvas lu-badge. Defaults to false.
  • on_remove (:any) - An event name or a JS command: adds a remove button after the content. Defaults to nil.
  • id (:string) - Defaults to nil.
  • target (:any) - The phx-target of on_remove when it is an event. Defaults to nil.
  • remove_label (:string) - Defaults to "Remove".
  • style (:any) - Inline style (false omits the attribute). Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)