--- title: Avatar description: An image element with a fallback for representing the user. links: doc: https://base-ui.com/react/components/avatar#api-reference --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/avatar ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" ``` ```tsx JD ``` Use `keepMounted` when the image relies on native lazy loading or an optimized image component. The fallback remains visible while the image loads or if it fails: ```tsx JD ``` ## API Reference ### Avatar Root component. Styled wrapper for `Avatar.Root` from Base UI with default size of 32px (8 units) and rounded-full styling. ### AvatarImage Image element for the avatar. Styled wrapper for `Avatar.Image` from Base UI with support for `keepMounted` images. ### AvatarFallback Fallback content displayed when the image fails to load. Styled wrapper for `Avatar.Fallback` from Base UI with muted background. ## Examples ### Fallback Only ### Different Sizes ### Different Radius ### Group Avatars