Avatar

Avatars are used to represent users or entities in a system.

import { Avatar } from '@cerberus/react'

Usage

Protector Cerberus

Preview Playground

import { Avatar, type AvatarProps } from '@cerberus/react' export function MyAvatar(props: AvatarProps) { return ( <Avatar {...props} ariaLabel="Protector Cerberus" gradient="charon-light" size="xs" src="https://cerberus.digitalu.design/logo.svg" /> ) }

As Prop

You can use the as prop to render the Avatar component as a different element.

Protector Cerberus

Style Customization

You can customize the avatar by utilizing the cx function.

Default Icon Customization

You can customize the default icon that shows by adding the avatar property to the defineIcons function at the root level of your app.

app/layout.tsx
import { defineIcons } from '@cerberus/react'
import { CircleUser } from 'lucide-react'
defineIcons({
avatar: CircleUser,
})

API

export type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> & {
ariaLabel: string
as?: never
icon?: ReactNode
src: string
width?: number
height?: number
}
export type AvatarAsProps = {
as: ReactNode
ariaLabel?: never
icon?: ReactNode
src?: never
width?: never
height?: never
}
export type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &
AvatarVariantProps) &
(AvatarImageProps | AvatarAsProps)
define function Avatar(props: AvatarProps): ReactNode

Props

The Avatar component accepts the following props:

NameDefaultDescription
ariaLabelThe name of the avatar entity.
srcThe source of the image.
asA differnet element to render as the avatar.
heightThe height of the avatar.
iconA custom icon to render as fallback.
widthThe width of the avatar.