fix: Remove default background color from AvatarFallback#5
Closed
robdimarco-atxp wants to merge 1 commit intomainfrom
Closed
fix: Remove default background color from AvatarFallback#5robdimarco-atxp wants to merge 1 commit intomainfrom
robdimarco-atxp wants to merge 1 commit intomainfrom
Conversation
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When passing custom background colors to AvatarFallback via className (e.g.,
bg-indigo-500 text-white), the defaultbg-mutedclass was creating conflicts. Even thoughcn()uses tailwind-merge, having default background colors on a component designed to accept custom colors leads to: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-mutedandtext-foregroundfrom AvatarFallback default classes. Components using AvatarFallback should always provide their own background and text colors via className prop.Breaking Change
Migration:
bg-muted text-foregroundto classNameTest Plan