Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Avatar

An image element with a fallback for representing the user.

CNL2

Installation

npx logic2b@next add avatar

Usage

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"

<Avatar>
  <AvatarImage src="https://github.com/vercel.png" alt="@logic2b" />
  <AvatarFallback>CN</AvatarFallback>
</Avatar>

Usage notes

Avatar, AvatarImage, and AvatarFallback also forward standard element props. Size the avatar with a className (e.g. size-12).

Examples

Group

Overlap several avatars to represent a set of users.

VCABCD+3

Fallback

When the image is missing or fails to load, the fallback is shown.

L2UI

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<Avatar
  className="size-12"
>
  <AvatarFallback>AM</AvatarFallback>
</Avatar>

API reference

Generated from the public TypeScript exports in src/ui/avatar.tsx.

View JSON

Avatar

Component
Props: React.ComponentProps<typeof AvatarPrimitive.Root>

AvatarImage

Component
Props: React.ComponentProps<typeof AvatarPrimitive.Image>

AvatarFallback

Component
Props: React.ComponentProps<typeof AvatarPrimitive.Fallback>

Accessibility contract

Machine-readable behavior and consumer responsibilities for avatar.

View JSON
Support
Primitive-managed
Pattern
image with fallback
Radix Avatar

Built-in semantics

  • The image forwards its accessible name; the fallback text remains available when the image cannot load.

Consumer responsibilities

  • Provide useful alt text for informative avatars and empty alt text when the nearby name is redundant.