• Docs
  • Blog
    • 0.24.0

    • Switch to dark mode
    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Feature FlagsForLocal StoragePortalShowsplitPropsTheme

    Avatar

    The Avatar component is used to represent a user or entity, displaying a profile picture, initials, or a generic icon.

    • npm
    • source
    • recipe
    • Ark
    import { Avatar } from '@cerberus/react'

    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.

    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.

    xs
    sm
    md
    lg
    xl
    2x
    3x
    4x

    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.

    Note

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

    Protector Cerberus

    Primitives

    You can utilize the primitive components or the css prop to customize the avatar.

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

    API

    Props

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

    NameDefaultDescription
    gradientnoneThe gradient theme to display
    sizemdThis size of the avatar.
    altThe alt of the avatar.
    srcThe src of the avatar.
    fallbackThe fallback content to display for 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

    • Edit this page on Github
    Cerberus Design System | Docs