Tag
color (8) × variant solid/soft/bordered/outline/flat · shape rounded/pill/square · removable
A category marker, optionally removable and with a series color.
Adding and removing
<div class="flex flex-wrap items-center gap-2"><.tag as="span" color="primary" variant="soft" removable class="animate-[mo-stg_6s_cubic-bezier(.2,.8,.2,1)_infinite]">Atacado</.tag><.tag as="span" color="info" variant="soft" removable class="animate-[mo-stg_6s_cubic-bezier(.2,.8,.2,1)_infinite] [animation-delay:.4s]">Varejo</.tag><.tag as="span" color="secondary" variant="soft" removable class="animate-[mo-stg_6s_cubic-bezier(.2,.8,.2,1)_infinite] [animation-delay:.8s]">VIP</.tag><.tag as="span" color="error" variant="soft" removable class="animate-[mo-stg_6s_cubic-bezier(.2,.8,.2,1)_infinite] [animation-delay:1.2s]">Inadimplente</.tag></div>
color (8) × variant
<div style="display:grid;grid-template-columns:80px repeat(5, minmax(0,1fr));gap:10px 12px;align-items:center"><span></span><span :for={v <- ~w(solid soft bordered outline flat)} class="text-center font-mono text-xs text-muted">{v}</span><%= for c <- ~w(neutral primary secondary info success warning error light) do %><span class="font-mono text-xs text-muted">{c}</span><div :for={v <- ~w(solid soft bordered outline flat)} style="display:flex;justify-content:center;min-width:0"><.tag as="span" color={c} variant={v}>{String.capitalize(c)}</.tag></div><% end %></div>
shape rounded · pill · square · removable
<div class="flex flex-wrap items-center gap-2.5"><.tag as="span" color="primary" variant="soft">rounded</.tag><.tag as="span" color="primary" variant="soft" shape="pill">pill</.tag><.tag as="span" color="primary" variant="soft" shape="square">square</.tag><.tag as="span" variant="bordered" removable>Removível</.tag></div>
Usage
<.tag color="chart-1" removable>Pro</.tag>
Rules
- An 8px square swatch in the chart series color.
API reference
Todos os function components, atributos, valores e slots que este componente cobre.
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 tag: an optional
colour swatch and a remove button. Styled only with Tailwind utilities (the colour enters as
--c/--c-on/--c-soft/--c-ink, see LedgerUI.Color).
<.tag>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
color |
:string |
"neutral" |
neutral, primary, secondary, info, success, warning, error, light |
variant |
:string |
"solid" |
solid, soft, bordered, outline, flat |
tint |
:string |
nil |
A CSS colour of its own; overrides color. |
active |
:boolean |
false |
Selected state of a filter chip. |
count |
:integer |
nil |
A small pill with this number after the label. |
shape |
:string |
"rounded" |
rounded, pill, square |
as |
:string |
nil |
nil, span |
static |
:boolean |
false |
|
type |
:string |
"button" |
|
removable |
:boolean |
false |
Draws the x of a removable tag. |
on_remove |
:any |
nil |
An event name or JS command for the x. |
remove_label |
:string |
"Remover" |
|
canvas |
:boolean |
false |
The canvas lu-tag (swatch + remove button). |
swatch |
:string |
nil |
A CSS colour for the canvas tag's square. |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including href, navigate, patch, method, download, name, value, disabled.
Slots:
<:inner_block>(required)
<.tag_group>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required)