LedgerUI.Components.Chip (LedgerUI v0.2.0)

Copy Markdown View Source

The chip (lu-chip): a small tag for a quick filter, an applied filter or a selected person.

<.chip>Hoje</.chip>
<.chip selected={@pro?} phx-click="toggle" value="pro">Pro</.chip>
<.chip selected={false} count={12}>Atrasados</.chip>
<.chip dashed icon="plus">Filtro</.chip>
<.chip label="Situação: Aprovação" on_remove={JS.hide(to: "#c1")} id="c1" />
<.chip avatar="Marina Costa" on_remove="remove_person" id="p-1">Marina Costa</.chip>
<.chip patch={~p"/extract?account=1"} label="Conta 1" />
<.chip label="Aberta" remove_patch={~p"/tasks"} />
  • a plain chip is a <span>; with selected (true/false) it is a toggle button (aria-pressed, the on state is the inverse colour) that flips in the browser unless you give it a phx-click; dashed and phx-click make it a button too;
  • with href, navigate or patch it is a link and has no x;
  • on_remove (an event name, pushed with %{"id" => id} to target, or a JS command) adds the x button; remove_patch makes the x a patch link instead.

Summary

Functions

chip(assigns)

Attributes

  • label (:string) - Defaults to nil.
  • selected (:boolean) - true/false makes the chip a toggle. Defaults to nil.
  • dashed (:boolean) - Defaults to false.
  • tone (:string) - Defaults to nil.Must be one of nil, "default", or "acc".
  • icon (:string) - Defaults to nil.
  • count (:any) - Defaults to nil.
  • avatar (:string) - Defaults to nil.
  • avatar_color (:string) - Defaults to nil.
  • avatar_src (:string) - Defaults to nil.
  • on_remove (:any) - Defaults to nil.
  • remove_patch (:string) - Defaults to nil.
  • id (:string) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • remove_label (:string) - Defaults to "Remove".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "download", "value", "disabled"].

Slots

  • inner_block