DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerContainer QueryDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTA ModalDate PickerDialogFieldFieldsetFile UploaderIconButtonInputLoading StatesMarqueeMenuNotificationsNumber InputPaginationPin InputPopoverProgress IndicatorsPrompt ModalRadioRatingSelectSliderSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFormat Relative TimeFrameHighlightJSON Tree ViewLocalePortalPresenceShowSwapsplitPropsTheme

Avatar

The Avatar component is used to represent user profile picture or initials.

  • npm
  • source
  • recipe
  • Ark
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page

Import

import { Avatar } from '@cerberus/react'

Usage

The Avatar component is used to represent a user or entity. It can be used to display a user's profile picture, initials, or a generic icon.

Note

The avatar uses a smart hierarchy method. If a source is provided and loads successfully - it will be shown. In all other cases, the fallback will be shown.

Loading example...

Sizes

You can change the size of an Avatar with the size prop.

Loading example...

Gradients

Use the gradient prop to use any gradient for the background color.

Loading example...

Group

Use the Group component to stack Avatars together.

Loading example...

Badge

Use the Float component to show badges.

Loading example...

asChild Prop

You can use the asChild prop to render the Avatar component as a different element. Cerberus will pass all the props onto your child.

This is great for when you need to link the avatar to a profile page.

Loading example...

Customization

You can customize the Avatar any way you like with style props and data-selectors.

Loading example...

Primitives

The layers of the Avatar which can be used to create a fully custom solution.

ComponentDescription
AvatarRootThe context provider for the Avatar parts
AvatarImageThe img of the avatar
AvatarFallbackThe fallback content to display for the avatar

Data Attributes

The primitives additionally use the following data attributes for custom styling:

NameValueDescription
data-scopeavatarThe scope of the components.
data-partrootThe root layer of the scope.
data-partfallbackThe fallback layer of the scope.
data-partimageThe image layer of the scope.

API

Props

The Avatar component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
fallbackThe fallback content to display for the avatar.
srcThe src of the avatar.
altThe alt of the avatar. Required if using src.
gradientnoneThe gradient theme to display
sizemdThis size of the avatar.

The Avatar component also accepts all the props of the AvatarRoot primitive props

Parts

The AvatarParts API is an Object containing the full family of components.

Note

It is best to only use the AvatarParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

NameDescription
RootThe AvatarRoot component which is the Provider for the family.
ImageThe AvatarImage component which displays the image.
FallbackThe AvatarFallback component which is the content to show when there is no image (or it fails to load).

On this page

  • Import
  • Usage
  • Sizes
  • Gradients
  • Group
  • Badge
  • asChild Prop
  • Customization
  • Primitives
    • Data Attributes
  • API
    • Props
    • Parts
Edit this page on Github
md
mdUser Avatar
xs
sm
md
lg
xl
2xl
3xl
4xl

charon-light

charon-dark

nyx-light

nyx-dark

amphiaraus-light

amphiaraus-dark

styx-light

styx-dark

thanatos-light

thanatos-dark

hades-light

hades-dark

asphodel-light

asphodel-dark

md
mdUser Avatar
Protector Cerberus
Cu