Data

Avatar

User avatar with image, fallback initials, and status badge.

Preview
01 Installation

Install

Pull Avatar from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Avatar } from "@brika/clay";
tsxGranular1 line
import { Avatar } from "@brika/clay/components/avatar";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxAvatar.tsx14 lines
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from '@brika/clay/components/avatar';
/** Default avatar with a remote image and initials fallback. */
export default function AvatarDefaultDemo() {
  return (
    <Avatar>
      <AvatarImage src="https://api.dicebear.com/9.x/initials/svg?seed=Alicia" alt="Alicia Reyes" />
      <AvatarFallback>AR</AvatarFallback>
    </Avatar>
  );
}
03 Examples

Avatar, every way

Badge

AvatarBadge overlays a status indicator in the bottom-right corner.

Fallback

When the image URL fails or is omitted, initials render in the fallback slot.

Group

Stacked AvatarGroup with a count bubble for the remaining members.

Sizes

Three preset sizes, `sm` (24px), `default` (32px), and `lg` (40px).

04 Accessibility

Accessibility

  • AvatarImage requires an alt attribute; use the user's name, or alt="" for decorative use.
  • AvatarFallback is visible only when the image fails or is missing; AT reads the fallback text.
  • Status badge text should be wrapped in an aria-label when it conveys meaning (e.g. "Online").
05 Tokens 8 theme-overridable

Theme tokens

Every CSS variable Avatar reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Avatar without touching component code.

Avatar tokens

8 tokens
ColorFill, border, and text colors.5
  • --avatar-fallback-containercolorvar(--muted)
    components.avatar.fallbackContainer

    Background of the avatar fallback (and the `<AvatarGroupCount>` chip).

  • --avatar-fallback-labelcolorvar(--muted-foreground)
    components.avatar.fallbackLabel

    Text color (initials) of the avatar fallback.

  • --avatar-badge-containercolorvar(--primary)
    components.avatar.badgeContainer

    Background of the small `<AvatarBadge>` indicator pinned to the bottom-right corner.

  • --avatar-badge-labelcolorvar(--primary-foreground)
    components.avatar.badgeLabel

    Foreground (icon / count) color of the `<AvatarBadge>` indicator.

  • --avatar-ring-colorcolorvar(--background)
    components.avatar.ringColor

    Color of the 2px ring drawn around the avatar badge and around grouped avatars to separate them from the surrounding surface.

GeometrySizes, lengths, and corner radii.3
  • --avatar-sizesize2rem
    components.avatar.size

    Avatar diameter at the default size.

  • --avatar-group-spacingsize0.5rem
    components.avatar.groupSpacing

    Negative inline overlap between adjacent avatars inside an `<AvatarGroup>`. Larger values pull stacked avatars further apart.

  • --avatar-radiusradius9999px
    components.avatar.radius

    Avatar corner radius. Default is fully circular.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.avatar, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "avatar": {
      "radius": "9999px"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-avatar-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Avatar. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<Avatar />

1 prop
  • sizedefault 'default'
    'default' | 'sm' | 'lg'
    Preset diameter.

<AvatarBadge />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<AvatarFallback />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<AvatarGroup />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<AvatarGroupCount />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<AvatarImage />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.