apps/eclipse/content/design-system/components/avatar.mdx
import { Avatar } from "@prisma/eclipse";
Basic Avatar with Initials
import { Avatar } from "@prisma/eclipse";
export function UserProfile() {
return <Avatar format="initials">JD</Avatar>;
}
Live Example:
<div className="flex items-center gap-4 my-4 not-prose"> <Avatar format="initials" size="lg">SM</Avatar> <Avatar format="initials" size="xl">MD</Avatar> <Avatar format="initials" size="2xl">LG</Avatar> <Avatar format="initials" size="3xl">XL</Avatar> </div>Avatar with Image
import { Avatar } from "@prisma/eclipse";
export function UserProfileImage() {
return (
<Avatar
format="image"
src="/avatar.jpg"
alt="John Doe"
size="lg"
/>
);
}
Live Example:
<div className="flex items-center gap-4 my-4 not-prose"> <Avatar format="image" src="/img/logo.svg" alt="Prisma" size="lg" /> <Avatar format="image" src="/img/logo.svg" alt="Prisma" size="xl" /> <Avatar format="image" src="/img/logo.svg" alt="Prisma" size="2xl" /> <Avatar format="image" src="/img/logo.svg" alt="Prisma" size="3xl" /> </div>Avatar with Icon
import { Avatar } from "@prisma/eclipse";
export function IconAvatar() {
return (
<Avatar format="icon" size="2xl">
<UserIcon />
</Avatar>
);
}
Live Example:
<div className="flex items-center gap-4 my-4 not-prose"> <Avatar format="icon" size="lg"> <svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0.34 -0.059977834648891726 33.11668247084116 39.96397783464889" width="20" height="20"><path d="M32.908 30.475L19.151 1.26a2.208 2.208 0 0 0-1.88-1.257 2.183 2.183 0 0 0-2.01 1.042L.34 25.212a2.26 2.26 0 0 0 .025 2.426L7.66 38.935a2.346 2.346 0 0 0 2.635.969l21.17-6.262a2.32 2.32 0 0 0 1.457-1.258 2.27 2.27 0 0 0-.013-1.91zm-3.08 1.253L11.864 37.04c-.548.163-1.074-.312-.96-.865l6.418-30.731c.12-.575.914-.666 1.165-.134l11.881 25.23a.858.858 0 0 1-.541 1.188z" clipRule="evenodd" fillRule="evenodd"/></svg> </Avatar> <Avatar format="icon" size="xl"> <svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0.34 -0.059977834648891726 33.11668247084116 39.96397783464889" width="24" height="24"><path d="M32.908 30.475L19.151 1.26a2.208 2.208 0 0 0-1.88-1.257 2.183 2.183 0 0 0-2.01 1.042L.34 25.212a2.26 2.26 0 0 0 .025 2.426L7.66 38.935a2.346 2.346 0 0 0 2.635.969l21.17-6.262a2.32 2.32 0 0 0 1.457-1.258 2.27 2.27 0 0 0-.013-1.91zm-3.08 1.253L11.864 37.04c-.548.163-1.074-.312-.96-.865l6.418-30.731c.12-.575.914-.666 1.165-.134l11.881 25.23a.858.858 0 0 1-.541 1.188z" clipRule="evenodd" fillRule="evenodd"/></svg> </Avatar> <Avatar format="icon" size="2xl"> <svg xmlns="http://www.w3.org/2000/svg" fill="white" viewBox="0.34 -0.059977834648891726 33.11668247084116 39.96397783464889" width="28" height="28"><path d="M32.908 30.475L19.151 1.26a2.208 2.208 0 0 0-1.88-1.257 2.183 2.183 0 0 0-2.01 1.042L.34 25.212a2.26 2.26 0 0 0 .025 2.426L7.66 38.935a2.346 2.346 0 0 0 2.635.969l21.17-6.262a2.32 2.32 0 0 0 1.457-1.258 2.27 2.27 0 0 0-.013-1.91zm-3.08 1.253L11.864 37.04c-.548.163-1.074-.312-.96-.865l6.418-30.731c.12-.575.914-.666 1.165-.134l11.881 25.23a.858.858 0 0 1-.541 1.188z" clipRule="evenodd" fillRule="evenodd"/></svg> </Avatar> </div>Disabled State
import { Avatar } from "@prisma/eclipse";
export function DisabledAvatar() {
return (
<Avatar
format="image"
src="/avatar.jpg"
alt="Disabled user"
size="lg"
disabled
/>
);
}
format - The type of avatar content: "image", "icon", or "initials" (required)size - Avatar size: "lg" (28x28, default), "xl" (32x32), "2xl" (36x36), "3xl" (40x40)disabled - Whether the avatar is disabled: true or false (default: false)src - Image source URL (required when format is "image")alt - Alt text for image (optional, recommended for accessibility)children - Content for icon or initials formatclassName - Additional CSS classes (optional)Display a user photo or image:
<Avatar
format="image"
src="/user-photo.jpg"
alt="User Name"
size="xl"
/>
Display user initials (typically 1-2 characters):
<Avatar format="initials" size="xl">
JD
</Avatar>
Display an icon or SVG:
<Avatar format="icon" size="2xl">
<UserIcon />
</Avatar>
The Avatar component supports four sizes:
lg - 28x28 pixels (default)xl - 32x32 pixels2xl - 36x36 pixels3xl - 40x40 pixels<div className="flex items-center gap-4">
<Avatar format="initials" size="lg">SM</Avatar>
<Avatar format="initials" size="xl">MD</Avatar>
<Avatar format="initials" size="2xl">LG</Avatar>
<Avatar format="initials" size="3xl">XL</Avatar>
</div>
image format when you have a user photo availableinitials format for personalization without photosicon format for generic user representations or system avatarsalt text when using the image format for accessibilitydisabled state to indicate inactive or unavailable usersformat="image", always provide an alt attribute