Nusa UINusa UI

An image element with a fallback for representing the user.

CN
registry/examples/avatar-demo.tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/registry/ui/avatar"

export default function AvatarDemo() {

Installation

pnpmnpmyarnbun
pnpm dlx shadcn@latest add https://nusa-ui.vercel.app/r/avatar.json

Usage

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
<Avatar>
  <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
  <AvatarFallback>CN</AvatarFallback>
</Avatar>

Examples

With Fallback

JD
registry/examples/avatar-fallback.tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/registry/ui/avatar"

export default function AvatarFallbackDemo() {

Different Sizes

registry/examples/avatar-sizes.tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/registry/ui/avatar"

export default function AvatarSizes() {

API Reference

Avatar

ComponentDescription
AvatarThe root container
AvatarImageThe image element
AvatarFallbackFallback when image fails to load

AvatarImage Props

PropTypeDefaultDescription
srcstring-The image source URL
altstring-Alt text for the image

AvatarFallback Props

PropTypeDefaultDescription
delayMsnumber-Delay before showing fallback