Search documentation of phoenix_kit

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

View Source

Provides user information display components.

These components handle user-related data display including roles, statistics, and user counts. All components are designed to work with PhoenixKit's user and role system.

# Summary

## Functions

primary_role(assigns)

Displays user's primary role name.

users_count(assigns)

Displays users count for a specific role.

# Functions

# primary_role(assigns)

Displays user's primary role name.

The primary role is determined as the first role in the user's roles list. If the user has no roles, displays "No role".

## Attributes

- `user` - User struct with preloaded roles
- `class` - CSS classes

## Examples

    <.primary_role user={user} />
    <.primary_role user={user} class="font-semibold" />

## Attributes

- `user` (`:map`) (required)
- `class` (`:string`) - Defaults to `""`.

# users_count(assigns)

Displays users count for a specific role.

Retrieves the count from role statistics map and displays it. If no count is found for the role, displays 0.

## Attributes

- `role` - Role struct with id
- `stats` - Map with role statistics (role_id => count)

## Examples

    <.users_count role={role} stats={@role_stats} />
    <.users_count role={role} stats={@role_stats} />

## Attributes

- `role` (`:map`) (required)
- `stats` (`:map`) (required)