Badge, Label, CompositeBadge, and BadgeGroup components for Pure Admin.
Summary
Functions
Renders a badge with Pure Admin BEM classes.
Renders a container for multiple badges with optional expand/collapse.
Renders a three-part composite badge (icon + label + button/count).
Renders a lightweight label indicator.
Functions
Renders a badge with Pure Admin BEM classes.
Examples
<.badge variant="success">Active</.badge>
<.badge variant="warning" size="sm" is_pill>Pending</.badge>Attributes
variant(:string) - Color variant. Defaults to"primary". Must be one of"primary","secondary","success","warning","danger","info","light", or"dark".size(:string) - Defaults tonil.Must be one ofnil,"xs","sm","lg", or"xl".max_width(:string) - Max width in rem units (e.g. '5', '10', '15') - adds maxwr-N text-truncate. Defaults tonil.is_pill(:boolean) - Rounded pill shape. Defaults tofalse.is_ellipsis_start(:boolean) - Truncate from the left side. Defaults tofalse.theme_color(:string) - Theme color 1-9. Defaults tonil. Must be one ofnil,"1","2","3","4","5","6","7","8", or"9".class(:string) - Defaults tonil.- Global attributes are accepted.
Slots
icon- Icon content inside pa-badge__icon.inner_block(required)
Renders a container for multiple badges with optional expand/collapse.
Modes
- No limit — all badges visible (default)
- Client-side — set
limitandtotal, JS toggles visibility without server round-trip - Server-side — set
limit,total,is_expanded, andon_toggleevent name; server loads additional data on expand
Examples
<%!-- Simple group, no limit --%>
<.badge_group>
<.badge variant="primary">Elixir</.badge>
<.badge variant="info">Phoenix</.badge>
</.badge_group>
<%!-- Client-side expand/collapse --%>
<.badge_group limit={5} total={15}>
<.badge :for={tag <- @tags} variant={tag.variant}><%= tag.label %></.badge>
</.badge_group>
<%!-- Server-side expand (fires phx event to load more) --%>
<.badge_group limit={5} total={@total} is_expanded={@expanded} on_toggle="expand_tags">
<.badge :for={tag <- @tags} variant={tag.variant}><%= tag.label %></.badge>
</.badge_group>Attributes
limit(:integer) - Max visible badges before showing 'N more' (nil = no limit). Defaults tonil.total(:integer) - Total badge count (for 'N more' calculation when server hasn't sent all). Defaults tonil.is_expanded(:boolean) - Current expand state (server-side mode). Defaults tofalse.on_toggle(:string) - LiveView event name for expand/collapse (server-side mode). When nil, uses client-side JS. Defaults tonil.is_show_all(:boolean) - Show all badges (CSS class, no limit logic). Defaults tofalse.more_text(:string) - Text for 'show more' badge. {count} is replaced with hidden count. Defaults to"» {count} more".collapse_text(:string) - Text for 'collapse' badge. Defaults to"« Collapse".class(:string) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)
Renders a three-part composite badge (icon + label + button/count).
Examples
<.composite_badge variant="primary" icon="🔔" label="Notifications" count="5" />
<.composite_badge variant="info" label="Task #1234" button_text="×" is_interactive>
<:icon_content>📋</:icon_content>
</.composite_badge>
<.composite_badge variant="primary" label_variant="secondary" button_variant="danger"
label="Project" button_text="×" is_interactive />Attributes
variant(:string) - Base color variant (icon section). Defaults to"primary". Must be one of"primary","secondary","success","warning","danger","info","light", or"dark".label_variant(:string) - Label section color (overrides variant). Defaults tonil. Must be one ofnil,"primary","secondary","success","warning","danger","info","light", or"dark".button_variant(:string) - Button section color (overrides variant). Defaults tonil. Must be one ofnil,"primary","secondary","success","warning","danger","info","light", or"dark".icon(:string) - Icon text or emoji. Defaults tonil.label(:string) (required) - Label text.count(:string) - Count/button text (legacy alias for button_text). Defaults tonil.button_text(:string) - Button section text. Defaults tonil.is_interactive(:boolean) - Enable hover/click styles. Defaults tofalse.on_label_click(:string) - LiveView event fired when label is clicked. Defaults tonil.on_button_click(:string) - LiveView event fired when button is clicked. Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["phx-click", "phx-value-id", "phx-value-label", "phx-value-action"].
Slots
icon_content- Rich icon content (alternative to icon attr).
Renders a lightweight label indicator.
Examples
<.label variant="success">Active</.label>Attributes
variant(:string) - Color variant. Defaults tonil. Must be one ofnil,"primary","secondary","success","warning","danger","info","light", or"dark".size(:string) - Defaults tonil.Must be one ofnil,"xs","sm","lg", or"xl".is_outline(:boolean) - Outline style. Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)