Better implementation of Avatar Group (remove z-index)
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Summary 💡
Avatar Group should be implemented without z-index to reduce interference with other components that uses z-index
Current Implementation:
<div className={clsx(classes.root, className)} ref={ref} {...other}>
{children.slice(0, children.length - extraAvatars).map((child, index) => {
return React.cloneElement(child, {
className: clsx(child.props.className, classes.avatar),
style: {
zIndex: children.length - index,
marginLeft: index === 0 ? undefined : marginLeft,
...child.props.style,
},
});
})}
{extraAvatars ? (
<Avatar
className={classes.avatar}
style={{
zIndex: 0,
marginLeft,
}}
>
+{extraAvatars}
</Avatar>
) : null}
</div>
Personally, I believe that this should be implemented with the innate HTML order priority. We can achieve this buy simply applying row-reverse to root and reversing the order of children.
P.S. I think we should also have a stackingDirection property that lets change change if we want it to stack RTL or LTR
I will be happen to open a PR if my suggestion is accepted
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Better implementation of Avatar Group (remove z-index) #21562
Summary. Avatar Group should be implemented without z-index to reduce interference with other components that uses z-index. Current ...
Read more >How to set the zIndex on the drawer component - Stack Overflow
I am trying to acheive the clipped under the app bar style temporary drawer. But I can't seem to be able to set...
Read more >Better z-index management with Sass | by ventrebleu - Medium
The principle of this approach is to surface the layers used in an application by expressively naming them in a Sass map and...
Read more >z-index - CSS-Tricks
The z-index property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is...
Read more >What No One Told You About Z-Index : r/programming - Reddit
There is a very good reason. If you have a negative Z-index on an element that's not in a local stacking context, it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nvdai2401 The author of the issue might be working on it.
However, our policy is to wait 7 days before giving an issue to somebody else. If we don’t hear back in two days, I think that it’s safe to work on 😃
Sure 😃