-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Avatar] Allow the customization of how the "+x" is calculated #29649
Comments
@Berhart it's a sensible request. Would you be willing to work on this feature? |
@michaldudak Sure! Whenever possible I'll try to come up with a solution. |
@Berhart do you mind if I work on this? Or have you already started? |
@eduardomcv I don't! I haven't started yet so tyvm for your time and effort! |
I doubt that the new prop https://codesandbox.io/s/mui-issue-latest-forked-rg5zw?file=/src/Demo.tsx As you mentioned, the use case is the data from the server so I assume that you have to write export default function GroupAvatars({ data }) {
const total = 5;
return (
<AvatarGroup max={4}>
{data.people.slice(0, total).map(src => {
return <Avatar key={src} alt="Remy Sharp" src={src} />
})}
</AvatarGroup>
);
} https://codesandbox.io/s/mui-issue-latest-forked-rg5zw?file=/src/Demo.tsx |
No, the use case isn't just limiting the avatars. Let's say there is a list of 100+ users (or any kind of paginated list). Currently, the
Both could be avoided by providing the developer with an option to override the internal |
Got it, now it makes sense. The server can send 2 users and the |
Yep, exactly! |
Duplicates
Latest version
Summary 💡
At the moment
AvatarGroup
solely relies on the amount ofAvatar
children to internally calculate how manyAvatar
s are left so that it is displayed on the "+X"Avatar
.The
AvatarGroup
component should expose an API that allows to "override" said calculation by ignoring the amount of children and, instead, consider a providedtotal
amount.Examples 🌈
Current implementation (docs example):
Suggested implementation:
Motivation 🔦
Use case:
AvatarGroup
but only the first 3 should be shown and the remaining ones should be displayed as "+N-3"Problem:
AvatarGroup
since it needs NAvatar
s as children to calculate the "+x"The text was updated successfully, but these errors were encountered: