Avatar
Styled avatar component family built on zw-avatar primitives.
@zeus-web/avatarData Displayzweb add avatarGenerated
Playground
Source
Choose the framework entry that matches your application.
html
<script type="module">
import '@zeus-web/avatar/wc/auto'
</script>
<zw-avatar>
<zw-avatar-image src="/avatar.png" alt="Ada Lovelace"></zw-avatar-image>
<zw-avatar-fallback>AL</zw-avatar-fallback>
</zw-avatar>tsx
import { Avatar, AvatarFallback, AvatarImage } from '@zeus-web/avatar/react'
export function AvatarExample() {
return (
<Avatar>
<AvatarImage src="/avatar.png" alt="Ada Lovelace" />
<AvatarFallback>AL</AvatarFallback>
</Avatar>
)
}vue
<script setup lang="ts">
import { Avatar, AvatarFallback, AvatarImage } from '@zeus-web/avatar/vue'
</script>
<template>
<Avatar>
<AvatarImage src="/avatar.png" alt="Ada Lovelace" />
<AvatarFallback>AL</AvatarFallback>
</Avatar>
</template>Add
bash
zweb add avatarImports
Styled registry component:
tsx
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'Primitive React wrapper:
tsx
import { Avatar, AvatarFallback, AvatarImage } from '@zeus-web/avatar/react'Web Component entry:
ts
import '@zeus-web/avatar/wc/auto'Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | AvatarSizeValues: sm, md, lg | md | Avatar size. |
shape | AvatarShapeValues: circle, square | circle | Avatar shape. |
Events
| Event | React prop | Detail | Description |
|---|---|---|---|
image-load | onImageLoad | nativeEvent: Event | Emitted when avatar image loads. |
image-error | onImageError | nativeEvent: Event | Emitted when avatar image fails to load. |
Slots
| Slot | Description |
|---|---|
default | AvatarImage and AvatarFallback children. |
Styling
Uses Tailwind: yes
Theme tokens:
bg-muted
Internal selectors:
[data-slot=avatar-root][data-slot=avatar-image][data-slot=avatar-fallback]
Registry
Registry source: available.
Add command: zweb add avatar
Type: component
Dependencies:
@zeus-web/avatar
Registry dependencies:
cnglobals
Files:
templates/react/avatar.tsx→components/ui/avatar.tsxtemplates/vue/avatar.ts→components/ui/avatar.ts
AI usage rules
Do:
- Use AvatarImage with meaningful alt text.
- Always provide AvatarFallback.
Do not:
- Do not use Avatar for decorative icons.
- Do not omit fallback content.
Examples
React styled usage
tsx
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
export function Example() {
return (
<Avatar>
<AvatarImage src="/avatar.png" alt="User" />
<AvatarFallback>ZW</AvatarFallback>
</Avatar>
)
}