The User Avatar component displays a user’s profile picture with an optional name. Commonly used in Filament tables and user-related interfaces.
Preview
John Doe
Usage
<x-shopper::user-avatar :user="$customer" />
Props
The user model instance. Must have picture and full_name attributes.
Whether to display the user’s name next to the avatar.
Examples
With Name
John Doe
<x-shopper::user-avatar :user="$user" />
Avatar Only
<x-shopper::user-avatar :user="$user" :showName="false" />
In a Filament Table
Tables\Columns\ViewColumn::make('customer')
->view('shopper::components.user-avatar')
->label(__('Customer')),
User Model Requirements
The user model must implement:
// Profile picture URL
public function getPictureAttribute(): string;
// Full name display
public function getFullNameAttribute(): string;
Blade Component Source
@props([
'user',
'showName' => true,
])
<div class="flex items-center gap-2">
<img
class="size-8 rounded-full"
src="{{ $user->picture }}"
alt="{{ $user->full_name }}"
/>
@if ($showName)
<span class="text-sm font-medium text-gray-700 dark:text-gray-300">
{{ $user->full_name }}
</span>
@endif
</div>