DOCS
v0.4

Components / Avatar

Avatar

User avatar with image, initials fallback, five sizes, circle/square shape, status indicator dot, and optional typed ring (user/agent/system) for AI-app shells.

data-displayv0.9.0

Playground

Examples

With image
<cg-avatar src="https://i.pravatar.cc/80" name="Ada Lovelace" size="lg" status="online"></cg-avatar>
Initials fallback
<cg-avatar name="Grace Hopper" size="md"></cg-avatar>
Square shape
<cg-avatar name="Alan Turing" size="lg" shape="square" status="away"></cg-avatar>
Typed rings (AI app)
<cg-stack direction="row" gap="md"><cg-avatar name="Alice" type="user" status="online"></cg-avatar><cg-avatar name="Claude" type="agent" status="online"></cg-avatar><cg-avatar name="Sys" type="system"></cg-avatar></cg-stack>

Import

import { CgAvatar } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-avatar';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
srcstring""Image source URL
altstring""Image alt text
namestring""User name for initials fallback
size"xs" | "sm" | "md" | "lg" | "xl""md"Avatar size
shape"circle" | "square""circle"Avatar shape
status"online" | "offline" | "away" | "busy" | nullnullStatus indicator dot
type"user" | "agent" | "system" | nullnullAdds a colored ring around the avatar (lime for `agent`, info for `user`, muted for `system`)
fallback-iconstring""Custom fallback icon