Skip to main content

Avatar

An Avatar component. Includes a fallback or holo background option.

Usage

import { Avatar } from "@fedibtc/ui"

function MyComponent() {
return (
<div>
{/* Avatar with valid image */}
<Avatar id="one" src="image1.png" name="John Doe" />

{/* Avatar with invalid image. Falls back to a colored background and initial */}
<Avatar
id="two"
src="invalid-image.png"
name="John"
size="md"
shape="square"
/>

{/* An avatar with an icon and holo background */}
<Avatar id="two" name="IconUser" icon="IconSocial" holo />
</div>
)
}

Props

NameTypeDescription
idstringA unique identifier from which is determined the fallback background color.
srcstringAn image source URL.
namestringA name to generate the first initial for the fallback.
iconIconAn icon to use as a fallback.
sizestringThe size of the avatar. Must be one of "xs", "sm", "md", or "lg". Defaults to "md"
shapestringThe shape of the avatar. Must be one of "circle" or "square". Defaults to "circle"
holobooleanWhether to use the Fedi holo background as a fallback color.
classNamestringAdditional class names to apply to the root element.