Search documentation of phoenix_kit

# PhoenixKitWeb.Components.Core.Badge (phoenix_kit v1.6.19)

View Source

Provides badge UI components for status, roles, and labels.

Supports different variants for system roles, user statuses, and custom labels. All badge components follow daisyUI badge styling conventions.

# Summary

## Functions

category_badge(assigns)

Renders a category badge for email templates.

code_status_badge(assigns)

Renders a code status badge for referral codes.

role_badge(assigns)

Renders a role badge with appropriate styling based on role type.

template_status_badge(assigns)

Renders a status badge for email templates.

user_status_badge(assigns)

Renders a user status badge (active/inactive/unconfirmed).

# Functions

# category_badge(assigns)

Renders a category badge for email templates.

## Attributes

- `category` - Template category: "system", "marketing", "transactional"
- `size` - Badge size (default: :sm)
- `class` - Additional CSS classes

## Examples

    <.category_badge category="system" />
    <.category_badge category="marketing" size={:md} />

## Attributes

- `category` (`:string`) (required)
- `size` (`:atom`) - Defaults to `:sm`. Must be one of `:xs`, `:sm`, `:md`, or `:lg`.
- `class` (`:string`) - Defaults to `""`.

# code_status_badge(assigns)

Renders a code status badge for referral codes.

## Attributes

- `code` - Code struct with uses_count, max_uses, and expiration_date fields
- `size` - Badge size (default: :md)

## Examples

    <.code_status_badge code={referral_code} />
    <.code_status_badge code={code} size={:sm} />

## Attributes

- `code` (`:map`) (required)
- `size` (`:atom`) - Defaults to `:md`. Must be one of `:xs`, `:sm`, `:md`, or `:lg`.

# role_badge(assigns)

Renders a role badge with appropriate styling based on role type.

## Attributes

- `role` - Role struct with name and is_system_role fields
- `size` - Badge size: :xs, :sm, :md, :lg (default: :md)
- `class` - Additional CSS classes

## Examples

    <.role_badge role={user.role} />
    <.role_badge role={role} size={:sm} />
    <.role_badge role={custom_role} class="ml-2" />

## Attributes

- `role` (`:map`) (required)
- `size` (`:atom`) - Defaults to `:md`. Must be one of `:xs`, `:sm`, `:md`, or `:lg`.
- `class` (`:string`) - Defaults to `""`.

# template_status_badge(assigns)

Renders a status badge for email templates.

## Attributes

- `status` - Template status: "active", "draft", "archived"
- `size` - Badge size (default: :sm)
- `class` - Additional CSS classes

## Examples

    <.template_status_badge status="active" />
    <.template_status_badge status="draft" size={:md} />

## Attributes

- `status` (`:string`) (required)
- `size` (`:atom`) - Defaults to `:sm`. Must be one of `:xs`, `:sm`, `:md`, or `:lg`.
- `class` (`:string`) - Defaults to `""`.

# user_status_badge(assigns)

Renders a user status badge (active/inactive/unconfirmed).

## Attributes

- `is_active` - Boolean user active status
- `confirmed_at` - DateTime of email confirmation or nil
- `size` - Badge size (default: :md)

## Examples

    <.user_status_badge is_active={user.is_active} confirmed_at={user.confirmed_at} />
    <.user_status_badge is_active={false} confirmed_at={nil} size={:sm} />

## Attributes

- `is_active` (`:boolean`) (required)
- `confirmed_at` (`:any`) - Defaults to `nil`.
- `size` (`:atom`) - Defaults to `:md`. Must be one of `:xs`, `:sm`, `:md`, or `:lg`.