Skip to content

Avatar

The Avatar component wraps Base UI Avatar: a root container with an optional image and fallback content (typically initials) when the image is missing or fails to load.

Import

tsx
import { Avatar } from "@tailor-platform/app-shell";

Basic usage

tsx
<Avatar.Root>
  <Avatar.Image src="/user.png" alt="Jane Doe" />
  <Avatar.Fallback>JD</Avatar.Fallback>
</Avatar.Root>

Parts

PartDescription
Avatar.RootOuter container; applies size and surface styles.
Avatar.Image<img> for the photo; hidden when not loaded or on error.
Avatar.FallbackShown when there is no image or the image failed to load.

Root props

PropTypeDefaultDescription
size"sm" | "default" | "lg""default"Circle size (28px default)
classNamestringExtra classes
childrenReact.ReactNodeImage + fallback

Avatar.Root forwards other stable props from Base UI (for example aria-hidden, style) and standard HTML attributes for the <span> root.

Sizes

tsx
<Avatar.Root size="sm">
  <Avatar.Fallback>AB</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="default">
  <Avatar.Fallback>CD</Avatar.Fallback>
</Avatar.Root>
<Avatar.Root size="lg">
  <Avatar.Fallback>EF</Avatar.Fallback>
</Avatar.Root>

Types

AvatarProps is the props type for Avatar.Root (includes size and Base UI root props). Import when wrapping or composing:

tsx
import { Avatar, type AvatarProps } from "@tailor-platform/app-shell";

avatarVariants

The same size styles used by Avatar.Root are exported as avatarVariants (for example if you need to mirror avatar dimensions in layout code). Prefer the size prop on Avatar.Root for normal use.