LedgerUI.Components.Tag (LedgerUI v0.2.0)

Copy Markdown View Source

Tags: clickable badges that represent an attribute, a filter or an action.

<.tag href="#">Default</.tag>
<.tag navigate={~p"/tags/elixir"} color="primary" shape="pill">Elixir</.tag>
<.tag color="info" variant="bordered" shape="pill" phx-click="filter">Info</.tag>
<.tag variant="soft" active={tag in @selected} phx-click="toggle" phx-value-tag={tag}>{tag}</.tag>

<.tag_group>
  <.tag color="neutral">Primary</.tag>
  <.tag color="primary">55</.tag>
</.tag_group>

With href, navigate or patch a tag is a link; otherwise a button. as="span" (or static) renders a non-interactive <span>. removable draws the x of a removable tag (give on_remove to make it act). With canvas the tag is the canvas lu-tag: an optional colour swatch and a remove button.

Summary

Functions

tag(assigns)

Attributes

  • color (:string) - Defaults to "neutral". Must be one of "neutral", "primary", "secondary", "info", "success", "warning", "error", or "light".
  • variant (:string) - Defaults to "solid". Must be one of "solid", "soft", "bordered", "outline", or "flat".
  • tint (:string) - A CSS colour of its own; overrides color. Defaults to nil.
  • active (:boolean) - Selected state of a filter chip. Defaults to false.
  • count (:integer) - A small pill with this number after the label. Defaults to nil.
  • shape (:string) - Defaults to "rounded". Must be one of "rounded", "pill", or "square".
  • as (:string) - Defaults to nil.Must be one of nil, or "span".
  • static (:boolean) - Defaults to false.
  • type (:string) - Defaults to "button".
  • removable (:boolean) - Draws the x of a removable tag. Defaults to false.
  • on_remove (:any) - An event name or JS command for the x. Defaults to nil.
  • remove_label (:string) - Defaults to "Remover".
  • canvas (:boolean) - The canvas lu-tag (swatch + remove button). Defaults to false.
  • swatch (:string) - A CSS colour for the canvas tag's square. Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "download", "name", "value", "disabled"].

Slots

  • inner_block (required)

tag_group(assigns)

Attributes

  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)