Avatar Group
To display a group of avatars together, wrap avatars in an <AvatarGroup>.
import { AvatarGroup } from "stylus-ui/AvatarGroup";import { Avatar } from "stylus-ui/Avatar";
const myUsers = [ { name: "Alejandro", userId: "1" }, { name: "James", userId: "2" }, { name: "Roberta", userId: "3" },];
export default () => ( <AvatarGroup> {myUsers.map((user) => ( <Avatar uuid={user.userId}>{user.name}</Avatar> ))} </AvatarGroup>);Sizing
Section titled “Sizing”You can adjust the size of all avatars in a group by setting the size.
import { AvatarGroup } from "stylus-ui/AvatarGroup";import { Avatar } from "stylus-ui/Avatar";
const myUsers = [ { name: "Alejandro", userId: "1" }, { name: "James", userId: "2" }, { name: "Roberta", userId: "3" },];
export default () => ( <AvatarGroup size="lg"> {myUsers.map((user) => ( <Avatar uuid={user.userId}>{user.name}</Avatar> ))} </AvatarGroup>);Visible count
Section titled “Visible count”By default, only three avatars will display. If you have more users you want to show, increment the total count.
import { AvatarGroup } from "stylus-ui/AvatarGroup";import { Avatar } from "stylus-ui/Avatar";
const myUsers = [ // The first three avatars display by default. { name: "Alejandro", userId: "1" }, { name: "James", userId: "2" }, { name: "Roberta", userId: "3" },
// Setting total={5} will show Thalía and Daniela... { name: "Thalía", userId: "4" }, { name: "Daniela", userId: "5" },
// ...but no others. { name: "Cara", userId: "6" }, { name: "Roan", userId: "7" },];
export default () => ( <AvatarGroup total={5}> {myUsers.map((user) => ( <Avatar uuid={user.userId}>{user.name}</Avatar> ))} </AvatarGroup>);Overflow count
Section titled “Overflow count”If there are more avatars than can be displayed, set hasOverflow to true. It will calculate and show a count of the avatars hidden from view.
import { AvatarGroup } from "stylus-ui/AvatarGroup";import { Avatar } from "stylus-ui/Avatar";
const myUsers = [ // Although 5 avatars are visible... { name: "Alejandro", userId: "1" }, { name: "James", userId: "2" }, { name: "Roberta", userId: "3" }, { name: "Thalía", userId: "4" }, { name: "Daniela", userId: "5" },
// ...hasOverflow calculates and shows there are +2 more { name: "Cara", userId: "6" }, { name: "Roan", userId: "7" },];
export default () => ( <AvatarGroup total={5} hasOverflow> {myUsers.map((user) => ( <Avatar uuid={user.userId}>{user.name}</Avatar> ))} </AvatarGroup>);If you want to directly specify a count instead of passing in children, use totalEntityCount.
import { AvatarGroup } from "stylus-ui/AvatarGroup";import { Avatar } from "stylus-ui/Avatar";
const myUsers = [ { name: "Alejandro", userId: "1" }, { name: "James", userId: "2" }, { name: "Roberta", userId: "3" }, { name: "Thalía", userId: "4" }, { name: "Daniela", userId: "5" },];
export default () => ( <AvatarGroup total={5} totalEntityCount={100} hasOverflow> {myUsers.map((user) => ( <Avatar uuid={user.userId}>{user.name}</Avatar> ))} </AvatarGroup>);API Reference
Section titled “API Reference”AvatarGroup
Section titled “AvatarGroup”Renders a group of avatars.
hasOverflow
Will show overflow indicator of extra avatars.
size
Sets size of avatars. Used to generate height/width of group.
theme
Changes avatar colors based on background AvatarGroup is on. dark will show light avatars and vise versa.
total
Total number of avatars shown. Used for calculating the number of extra avatars.
totalEntityCount
Total number of entities even if not passed in as Avatars. Necessary if the full list of entities is not passed in as children.