Avatar
An image element with a fallback for representing the user.
Preview
Installation
npx sigma-ui@latest add avatarUsage
vue
<script setup lang="ts">
import { Avatar } from '@/components/ui/avatar';
</script>
<template>
<Avatar
src="/avatars/avatar.png"
alt="User avatar"
/>
</template>sizesets the dimensions:xs,sm,base(default), orlg.shapeiscircle(default) orrounded.- If the image fails to load and you don't provide a
#fallbackslot, a default profile icon is rendered.
Examples
Basic
An avatar with just the src prop.
Glow
The glow prop adds a glowing effect to the image.
Custom fallback
Use the #fallback slot to provide custom content to show when the image fails to load.
API Reference
Avatar
Props
| Prop | Type | Default |
|---|---|---|
srcURL of the avatar image. | string | - |
altAlternative text for the image. | string | - |
glowRenders a blurred, saturated copy of the image behind it as a glow. | boolean | - |
sizeSize of the avatar. | "base" | "xs" | "sm" | "lg" | "base" |
shapeCorner style of the avatar: circle or rounded. | "circle" | "rounded" | null | "circle" |
Slots
| Slot | Scope |
|---|---|
fallbackContent shown when there is no image or it fails to load; defaults to a user icon. | - |
Accessibility
Renders an img element, so pass a meaningful alt text (it defaults to "image"). It has no keyboard interactions of its own.
| Key | Description |
|---|---|
| None | The avatar is not focusable. |
Sponsors
Support this project