Skip to Content
NarakUI

Avatar

Display user profile images, initials or fallback icons.

Sizes

size is in pixels. The default is 40.

Types

The avatar shows the image from src. Without one, or when it fails to load, it shows up to two initials from fallbackText on a gradient. showInitials={false} keeps only the gradient, and fallback replaces it with your own node.

Maya Chen

User avatar

UserAvatar is the avatar for a person: round, 20 px by default, with a user icon when there is no image. alt is both the accessible label and the fallback text.

Jane Cooper
Jane Cooper

Installation

pnpm dlx shadcn@latest add @narakui/avatar

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/avatar.json.

Usage

import { Avatar } from '@/components/ui/avatar';

<Avatar fallbackText="John Doe" />

Avatar Properties

PropTypeDefaultDescription
classNamestring—Additional CSS classes to apply to the avatar container
srcstring | { src: string }—URL or static-import object of the image to display
fallbackTextstringRequiredAccessible label for the avatar, and the source of the initials shown when there is no image or it fails to load
showInitialsbooleantrueShow letter initials in the fallback
fallbackReactNode—Custom node rendered when the image is missing or fails
imageAltstring'Avatar'Alt text for the avatar image
imageRole'presentation' | 'none'—ARIA role applied to the avatar image
sizenumber40Size of the avatar in pixels
isLoadingbooleanfalseShow loading skeleton state
textSize'small' | 'large''large'Size of the fallback text
imagePrioritybooleanfalseLoad the image eagerly with high fetch priority

UserAvatar Properties

PropTypeDefaultDescription
altstringRequiredAccessible label and fallback text
srcstring | { src: string }—URL or static-import object of the profile image
sizenumber20Size of the avatar in pixels
classNamestring—Additional CSS classes to apply to the avatar