Skip to content

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 avatar

Imports ​

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 ​

PropTypeDefaultDescription
sizeAvatarSize
Values: sm, md, lg
mdAvatar size.
shapeAvatarShape
Values: circle, square
circleAvatar shape.

Events ​

EventReact propDetailDescription
image-loadonImageLoadnativeEvent: EventEmitted when avatar image loads.
image-erroronImageErrornativeEvent: EventEmitted when avatar image fails to load.

Slots ​

SlotDescription
defaultAvatarImage 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:

  • cn
  • globals

Files:

  • templates/react/avatar.tsx → components/ui/avatar.tsx
  • templates/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>
  )
}

Released under the MIT License.