CNL2
Installation
npx logic2b@next add avatarUsage
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>AM
API reference
Generated from the public TypeScript exports in src/ui/avatar.tsx.
Avatar
ComponentProps: React.ComponentProps<typeof AvatarPrimitive.Root>AvatarImage
ComponentProps: React.ComponentProps<typeof AvatarPrimitive.Image>AvatarFallback
ComponentProps: React.ComponentProps<typeof AvatarPrimitive.Fallback>Accessibility contract
Machine-readable behavior and consumer responsibilities for avatar.
- 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.