question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Avatar] Set background colour for AvatarGroup's borders

See original GitHub issue

Summary 💡

Avatar group uses the background colour set for the app for the Avatar borders, but doesn’t pick up on the background colour of the div it’s within.

.MuiAvatarGroup-avatar {
  border-color: var(--background-color);
}

Examples 🌈

Solution could be to either have a property to set the border colour:

<AvatarGroup backgroundColor={something} />

or to wrap each one in a div that inherits the background colour from a parent. Giving a more hands-off approach.

Motivation 🔦

Used it on a different background and expected it to work without overriding colour.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Jul 7, 2020

@WillSquire I have noticed that facebook.com uses a clip logic to solve this problem. However, I’m not sure about the added complexity. I don’t see any clear solution out of this. The backgroundColor color sounds like an interesting tradeoff.

I have also noticed that the box model is wrong. We should change it:

diff --git a/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js b/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js
index 89ef01ac9..3716f65df 100644
--- a/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js
+++ b/packages/material-ui-lab/src/AvatarGroup/AvatarGroup.js
@@ -20,6 +20,7 @@ export const styles = (theme) => ({
   /* Styles applied to the avatar elements. */
   avatar: {
     border: `2px solid ${theme.palette.background.default}`,
+    boxSizing: 'content-box',
     marginLeft: -8,
     '&:last-child': {
       marginLeft: 0,
0reactions
MrEbbinghauscommented, Sep 17, 2021

Sorry to dig this up, after such a long time, but I noticed that the background/border color mismatch is very noticeable with the new paper colors in dark mode in v5.

Here is an example on an elevation12 paper: image

On elevation1, it’s still noticeable: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Avatar] Set background colour for AvatarGroup's borders
Summary Avatar group uses the background colour set for the app for the Avatar borders, but doesn't pick up on the background colour...
Read more >
Can I change the border color on an avatar? - WordPress.com
My picture/avatar shows up across wordpress, on comments etc. with a black border around it. I would like that to be white if...
Read more >
Avatar - Chakra UI
You can customize the background color and icon of the fallback avatar icon to match your design requirements. To update the background, pass...
Read more >
Material-UI Avatar Tutorial and Examples | React.School
Avatar Color. To change the color of the Avatar component, you will need to override the styles of the component and set the...
Read more >
Avatar - Naive UI
Avatar Props ; bordered, boolean, false, Whether to display a avatar with border. ; color, string, undefined, The background color of the avatar....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found