Avatar
Profile image with an initials fallback, and overlapping groups.
Example
import { Avatar, AvatarGroup } from "@porcelana/ui";
export default function Example() {
return (
<AvatarGroup aria-label="Shared with">
<Avatar name="Pierre Jochem" color="#f6c519" style={{ color: "#3a2d00" }} />
<Avatar name="Ana Maria" color="#b8066f" />
<Avatar name="Lena Kraus" color="#1d7a64" />
</AvatarGroup>
);
}Import
import { Avatar } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
namerequired | string | – | Person's name: used for alt text and to derive initials. |
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
color | string | – | Background color of the initials fallback. |
id | string | – | Element id. Generated automatically when omitted. |
size | number | 44 | Diameter in px. |
src | string | – | Image URL. Initials show while it loads or if it fails. |
Accessibility
- The image's alt text and the fallback's label both use name.
- AvatarGroup is a group; give it an aria-label.