mrshanebarron/avatar
Composer 安装命令:
composer require mrshanebarron/avatar
包简介
Avatar component for Laravel - supports Livewire and Vue
README 文档
README
A user avatar component for Laravel applications. Displays profile images or generates initials fallbacks with optional status indicators. Works with Livewire and Vue 3.
Installation
composer require mrshanebarron/avatar
Livewire Usage
With Image
<livewire:sb-avatar src="/images/user.jpg" alt="John Doe" />
With Initials Fallback
<livewire:sb-avatar name="John Doe" /> <!-- Displays "JD" -->
Different Sizes
<livewire:sb-avatar name="User" size="xs" /> <livewire:sb-avatar name="User" size="sm" /> <livewire:sb-avatar name="User" size="md" /> <livewire:sb-avatar name="User" size="lg" /> <livewire:sb-avatar name="User" size="xl" />
With Status Indicator
<livewire:sb-avatar name="John" status="online" /> <livewire:sb-avatar name="Jane" status="offline" /> <livewire:sb-avatar name="Bob" status="busy" /> <livewire:sb-avatar name="Alice" status="away" />
Square Avatar
<livewire:sb-avatar name="John Doe" :rounded="false" />
Livewire Props
| Prop | Type | Default | Description |
|---|---|---|---|
src |
string | null |
Image URL |
alt |
string | null |
Alt text for image |
name |
string | null |
Name for initials fallback |
size |
string | 'md' |
Size: xs, sm, md, lg, xl |
rounded |
boolean | true |
Circular shape |
status |
string | null |
Status: online, offline, busy, away |
Vue 3 Usage
Setup
import { SbAvatar } from './vendor/sb-avatar'; app.component('SbAvatar', SbAvatar);
Basic Usage
<template> <!-- With image --> <SbAvatar src="/images/user.jpg" alt="John Doe" /> <!-- With initials fallback --> <SbAvatar name="John Doe" /> </template>
Sizes
<template> <SbAvatar name="User" size="xs" /> <!-- 24px --> <SbAvatar name="User" size="sm" /> <!-- 32px --> <SbAvatar name="User" size="md" /> <!-- 40px --> <SbAvatar name="User" size="lg" /> <!-- 48px --> <SbAvatar name="User" size="xl" /> <!-- 64px --> </template>
With Status
<template> <SbAvatar name="John" status="online" /> <!-- Green dot --> <SbAvatar name="Jane" status="offline" /> <!-- Gray dot --> <SbAvatar name="Bob" status="busy" /> <!-- Red dot --> <SbAvatar name="Alice" status="away" /> <!-- Yellow dot --> </template>
User List Example
<template> <div class="flex -space-x-2"> <SbAvatar v-for="user in users" :key="user.id" :src="user.avatar" :name="user.name" size="sm" class="ring-2 ring-white" /> </div> </template>
Vue Props
| Prop | Type | Default | Description |
|---|---|---|---|
src |
String | null |
Image source URL |
alt |
String | null |
Image alt text |
name |
String | null |
Name for generating initials |
size |
String | 'md' |
Size: xs, sm, md, lg, xl |
rounded |
Boolean | true |
Use circular shape |
status |
String | null |
Status indicator: online, offline, busy, away |
Sizes Reference
| Size | Dimensions | Font Size |
|---|---|---|
xs |
24x24px | text-xs |
sm |
32x32px | text-sm |
md |
40x40px | text-base |
lg |
48x48px | text-lg |
xl |
64x64px | text-xl |
Status Colors
| Status | Color |
|---|---|
online |
Green |
offline |
Gray |
busy |
Red |
away |
Yellow |
Features
- Image Support: Display user photos
- Initials Fallback: Auto-generates initials from name
- Status Indicator: Small dot showing user status
- Multiple Sizes: 5 preset sizes
- Shape Options: Circular or rounded square
Styling
Uses Tailwind CSS:
- Gray background for initials
- Object-cover for images
- Status dot positioned bottom-right
- White border on status indicator
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
License
MIT License
mrshanebarron/avatar 适用场景与选型建议
mrshanebarron/avatar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「laravel」 「profile」 「avatar」 「vue」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mrshanebarron/avatar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrshanebarron/avatar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mrshanebarron/avatar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A module for Pluf to manage user profiles and user accounts
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
The Flarum extension that allows users to private their profiles.
PhpPlaisio: Profile
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-14