import { Avatar } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack direction="horizontal" space="space-150">
<Avatar name="Amara Okafor" src="/avatars/01.webp" />
{/* No photo: the initials, on a color picked from the name. */}
<Avatar name="Lena Fischer" />
<Avatar name="Marco Bellini" src="/avatars/03.webp" presence="online" />
</Stack>
);
}import { Avatar, AvatarGroup } from "@senvenli/react/display";Examples
Sizes
Small in dense rows, medium by default, large on a profile.import { Avatar } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack direction="horizontal" space="space-150" align="center">
<Avatar name="Daniel Reyes" src="/avatars/04.webp" size="small" />
<Avatar name="Daniel Reyes" src="/avatars/04.webp" size="medium" />
<Avatar name="Daniel Reyes" src="/avatars/04.webp" size="large" />
</Stack>
);
}A company
Squares are for companies and logos; circles are for people.import { Avatar } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
// A flat placeholder logo drawn in the file, so the example needs no network.
const LOGO = `data:image/svg+xml,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96"><rect width="96" height="96" fill="hsl(150 30% 90%)"/><path d="M24 68 48 24l24 44Z" fill="hsl(150 30% 30%)"/></svg>`,
)}`;
export default function Example() {
return (
<Stack direction="horizontal" space="space-150">
<Avatar name="Northwind Traders" shape="square" />
<Avatar name="Summit Supply" shape="square" src={LOGO} />
</Stack>
);
}A group
Past `max`, the rest fold into a count.import { Avatar, AvatarGroup } from "@senvenli/react/display";
export default function Example() {
return (
<AvatarGroup aria-label="Project members" max={3}>
<Avatar name="Amara Okafor" src="/avatars/01.webp" />
<Avatar name="Marco Bellini" src="/avatars/03.webp" />
<Avatar name="Claire Dubois" src="/avatars/07.webp" />
<Avatar name="Omar Haddad" src="/avatars/06.webp" />
<Avatar name="Sofia Marin" src="/avatars/05.webp" />
</AvatarGroup>
);
}Guidelines
When to use it
- Identifying who did something or who belongs to something.
Use something else when
- The object is not a person or a company. Icon
Do and avoid
- Use circles for people and squares for companies.
Accessibility
Built in
- Named by
name; presence is announced as online. - AvatarGroup announces how many more people are hidden.
You provide
- An
aria-labelon AvatarGroup that names the group.
API reference
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
nameRequired | string | – | The person's or company's name: the initials and the accessible name. |
src | string | – | Photo or company logo; initials (or the icon) show until it loads and if it fails. |
size | AvatarSize | – | |
shape | AvatarShape | "circle" |
|
presence | "online" | – | Shows the 10px online dot and says "online" in the name. |
nameRequiredstringThe person's or company's name: the initials and the accessible name.
srcstringPhoto or company logo; initials (or the icon) show until it loads and if it fails.
sizeAvatarSizeshapeAvatarShapeDefault"circle"circlefor people,squarefor companies and logos (contained, never stretched).presence"online"Shows the 10px online dot and says "online" in the name.
AvatarGroup
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | React.ReactNode | – | Avatars; past |
max | number | 4 | How many show before the "+N"; default 4. |
size | AvatarSize | "medium" | |
aria-label | string | – | Names the group ("Team members"). |
childrenRequiredReact.ReactNodeAvatars; past
maxthey fold into a "+N" avatar.maxnumberDefault4How many show before the "+N"; default 4.
sizeAvatarSizeDefault"medium"aria-labelstringNames the group ("Team members").