Skip to content

fix: Remove default background color from AvatarFallback#5

Closed
robdimarco-atxp wants to merge 1 commit intomainfrom
fix/avatar-fallback-color-override
Closed

fix: Remove default background color from AvatarFallback#5
robdimarco-atxp wants to merge 1 commit intomainfrom
fix/avatar-fallback-color-override

Conversation

@robdimarco-atxp
Copy link
Contributor

Problem

When passing custom background colors to AvatarFallback via className (e.g., bg-indigo-500 text-white), the default bg-muted class was creating conflicts. Even though cn() uses tailwind-merge, having default background colors on a component designed to accept custom colors leads to:

  • Confusion about what color will actually render
  • Potential CSS specificity issues
  • Inconsistent behavior across contexts

This was discovered when implementing consistent avatar colors in LibreChat - same user was showing different colors in different contexts due to these class conflicts.

Solution

Remove bg-muted and text-foreground from AvatarFallback default classes. Components using AvatarFallback should always provide their own background and text colors via className prop.

Breaking Change

⚠️ Yes - AvatarFallback will no longer have a default background/text color.

Migration:

  • All usage sites must provide className with background color
  • For existing usage that relied on default, add bg-muted text-foreground to className
  • AvatarGroup/AvatarGroupItem already passes colors, so no changes needed there

Test Plan

  • ✅ Rebuilt package successfully
  • ✅ Tested in LibreChat - avatar colors now consistent across all contexts
  • Verify no other components in design system rely on default colors
  • Update Storybook examples if needed

Remove bg-muted and text-foreground default classes from AvatarFallback to
allow custom colors to be applied without conflicts.

Problem: When passing custom background colors via className (e.g.,
bg-indigo-500 text-white), the default bg-muted class was creating conflicts.
Even though tailwind-merge should handle this, having default background colors
on a component that is designed to accept custom colors leads to confusion.

Solution: Remove bg-muted and text-foreground from default classes. Components
using AvatarFallback should always provide their own background and text colors
via className prop.

Breaking change: Yes - AvatarFallback will no longer have a default background.
All usage sites must provide className with background color.

Affected components:
- AvatarGroup/AvatarGroupItem already passes className with colors
- Any other usage will need to add bg-muted explicitly if desired
@robdimarco-atxp
Copy link
Contributor Author

Closing in favor of a better approach - will fix AvatarGroupItem to properly separate container classes from fallback classes instead of removing default colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant