php artisan aura:add avatar
Copies the component source into resources/views/components/aura/. Run php artisan aura:init first if you haven't already. See the CLI guide for all options.
composer require bluestarsystem/aura-ui
php artisan aura:install
Full installation instructions in the Installation guide.
Overview
The Avatar component displays a user's profile image, auto-generated initials, or a fallback icon. It supports multiple sizes, rounded styles, a status indicator (online, offline, busy, away), and automatic color assignment based on the user's name.
Use avatars for:
- User profile pictures
- Comment/message author indicators
- Team member lists
- Navigation bars and sidebars
Basic Usage
<x-aura::avatar src="/images/avatars/alice.jpg" alt="Jane Doe" /><x-aura::avatar src="/images/avatars/alice.jpg" alt="Jane Doe" />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src |
string|null |
null |
Image URL. When set, renders an <img> tag |
name |
string|null |
null |
Full name for auto-generating initials and color |
initials |
string|null |
null |
Explicit initials (overrides auto-generation from name) |
alt |
string |
'' |
Alt text for the image |
size |
string |
'md' |
Size: xs, sm, md, lg, xl |
color |
string|null |
null |
Background color for initials avatar. Auto-assigned from name when null |
status |
string|null |
null |
online, offline, busy, away. An unrecognised value falls back to offline rather than rendering an invisible dot. |
rounded |
string |
'full' |
Border radius: full (circle), lg, md, sm, none |
Available auto-colors: primary, success, warning, danger, info, purple, pink, teal, orange, indigo.
Variants/Examples
Image Avatar with Status
<x-aura::avatar
src="/images/avatars/jane.jpg"
alt="Jane Doe"
size="lg"
status="online"
/><x-aura::avatar
src="/images/avatars/jane.jpg"
alt="Jane Doe"
size="lg"
status="online"
/>
Initials from Name
The component auto-generates initials from the name prop. For two-word names it takes the first letter of each word; for single names it takes the first two letters.
<x-aura::avatar name="Jane Doe" size="md" /><x-aura::avatar name="Jane Doe" size="md" />
{{-- Renders "JD" with a consistent background color --}}
Explicit Initials and Color
<x-aura::avatar initials="AB" color="purple" size="lg" /><x-aura::avatar initials="AB" color="purple" size="lg" />
Fallback Icon (No Image or Name)
When neither src nor name/initials is provided, a generic user icon is displayed.
<x-aura::avatar size="md" /><x-aura::avatar size="md" />
Different Sizes
<x-aura::avatar name="Alice" size="xs" />
<x-aura::avatar name="Alice" size="sm" />
<x-aura::avatar name="Alice" size="md" />
<x-aura::avatar name="Alice" size="lg" />
<x-aura::avatar name="Alice" size="xl" /><x-aura::avatar name="Alice" size="xs" />
<x-aura::avatar name="Alice" size="sm" />
<x-aura::avatar name="Alice" size="md" />
<x-aura::avatar name="Alice" size="lg" />
<x-aura::avatar name="Alice" size="xl" />
Rounded Variants
<x-aura::avatar name="Bob" rounded="full" />
<x-aura::avatar name="Bob" rounded="lg" />
<x-aura::avatar name="Bob" rounded="none" /><x-aura::avatar name="Bob" rounded="full" /> {{-- Circle (default) --}}
<x-aura::avatar name="Bob" rounded="lg" /> {{-- Large border radius --}}
<x-aura::avatar name="Bob" rounded="none" /> {{-- Square --}}
Sub-components
Avatar Group
Use <x-aura::avatar.group> to stack multiple avatars with overlapping layout.
<x-aura::avatar.group>
<x-aura::avatar name="Alice Smith" size="md" />
<x-aura::avatar name="Bob Jones" size="md" />
<x-aura::avatar name="Carol White" size="md" />
<x-aura::avatar initials="+5" size="md" color="info" />
</x-aura::avatar.group><x-aura::avatar.group>
<x-aura::avatar name="Alice Smith" size="md" />
<x-aura::avatar name="Bob Jones" size="md" />
<x-aura::avatar name="Carol White" size="md" />
<x-aura::avatar initials="+5" size="md" color="info" />
</x-aura::avatar.group>
Slots
The Avatar component does not use named slots. All content is driven by props.
Accessibility
- When
srcis set, the<img>tag includesalttext (falls back tonameifaltis empty). - Initials are rendered as a
<span>which is visible to screen readers. - The status dot carries its own
role="img"and a translatedaria-label, so the state is not conveyed by colour alone. You do not need to add one.
<x-aura::avatar name="Jane" status="online" aria-label="Jane Doe (online)" /><x-aura::avatar name="Jane" status="online" aria-label="Jane Doe (online)" />
- Color assignments are deterministic per name, providing a consistent visual identity.