The example below loads live from Storybook; open it in Storybook for the controls.
Default
Section titled “Default”An Avatar loads the picture; without one, or when it fails to load, it shows the initials of the name. A person is a circle, a company a square with 8 px corners. name is required: the accessible name and the initials come from it.
import { Avatar } from '@bigbang/ui';
const picture = `data:image/svg+xml,${encodeURIComponent( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#3b6ea8"/><circle cx="32" cy="25" r="11" fill="#dbe7f5"/><path d="M10 64c2-14 12-22 22-22s20 8 22 22z" fill="#dbe7f5"/></svg>',)}`;
export default function Default() { return ( <div className="flex flex-wrap items-center gap-xl"> <Avatar name="User 1" src={picture} size="lg" /> <Avatar name="User 2" size="lg" /> <Avatar name="Sample Ltd" kind="company" size="lg" /> </div> );}There are five sizes: 24, 32 (default), 40, 48 and 64 px. Use sm or md in lists and xl in profile headers.
import { Avatar } from '@bigbang/ui';
export default function Sizes() { return ( <div className="flex flex-wrap items-end gap-xl"> <Avatar name="User 1" size="xs" /> <Avatar name="User 1" size="sm" /> <Avatar name="User 1" size="md" /> <Avatar name="User 1" size="lg" /> <Avatar name="User 1" size="xl" /> </div> );}Status
Section titled “Status”status adds a dot at the bottom inline end: online, offline or busy. A 2 px surface ring separates it from the picture. The state is also part of the accessible name: “User 1 (online)”. The offline dot is hollow, so the three states differ in shape as well as colour.
import { Avatar } from '@bigbang/ui';
export default function Status() { return ( <div className="flex flex-wrap items-center gap-xl"> <Avatar name="User 1" status="online" size="lg" /> <Avatar name="User 2" status="offline" size="lg" /> <Avatar name="User 4" status="busy" size="lg" /> <Avatar name="Sample Ltd" kind="company" status="online" size="lg" /> </div> );}Fallbacks
Section titled “Fallbacks”Without a picture the initials show. They are upper-cased with the casing rules of the Provider language: in Turkish “ilk işlem” becomes İİ. Without a name a person or company icon shows. A picture that fails to load also falls back to the initials. The fallback colour comes from the name; one name always gets one colour.
import { Avatar } from '@bigbang/ui';
export default function Fallbacks() { return ( <div className="flex flex-wrap items-center gap-xl"> <Avatar name="ilk işlem" size="lg" /> <Avatar name="User" size="lg" /> <Avatar name="" size="lg" /> <Avatar name="" kind="company" size="lg" /> <Avatar name="User 5" src="missing-picture.png" size="lg" /> </div> );}Avatar.Group overlaps avatars by 8 px and adds a “+N” count when max is exceeded. Give the group an aria-label: it becomes a named group.
import { Avatar } from '@bigbang/ui';
const people = ['User 1', 'User 2', 'User 4', 'User 5', 'User 6', 'User 3'];
export default function Group() { return ( <Avatar.Group max={4} aria-label="Team"> {people.map((name) => ( <Avatar key={name} name={name} /> ))} </Avatar.Group> );}Light and dark mode
Section titled “Light and dark mode”Fallback colours come from the status tone tokens and exceed 4.5:1 in both modes.
import { Avatar } from '@bigbang/ui';
export default function Fallbacks() { return ( <div className="flex flex-wrap items-center gap-xl"> <Avatar name="ilk işlem" size="lg" /> <Avatar name="User" size="lg" /> <Avatar name="" size="lg" /> <Avatar name="" kind="company" size="lg" /> <Avatar name="User 5" src="missing-picture.png" size="lg" /> </div> );}