Overview
Avatar (DsAvatar) represents a person, contact, account, or user profile in compact UI. It renders in one of three modes, chosen automatically from the props you provide:
- Image when imageSrc is set.
- Initials when initials resolves to a non-empty value (no imageSrc). Initials are trimmed, uppercased, and truncated to the first two characters.
- Identicon (fallback) when neither imageSrc nor usable initials is provided. A generated, decorative icon keeps the layout stable without requiring the consuming app to supply placeholder artwork.
Basic usage
Importing the component
import { DsAvatar } from "@coloplast/design-system";
import "@coloplast/design-system/dist/components/avatar/ds-avatar.css";
Example usage
<DsAvatar initials="CH" size="md" />
Component playground and props
Accessibility
Always pair an avatar with a visible name or other accessible text supplied by the surrounding UI (e.g. a name label next to the avatar in a list item, or an aria-label on a parent interactive element such as a button/link that wraps the avatar). Provide imageAlt whenever the image itself conveys information beyond "there's a photo here" (e.g. in a context where the image is the only identifying content).
Internationalisation
Tested in right to left contexts, supports local labels for alternative text.