Skip to content

Fix the tooltip centered when wrapping an avatar inside an avatar group #1232

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface FlowbiteAvatarRootTheme {
rounded: string;
size: AvatarSizes;
stacked: string;
tooltip: string;
status: FlowbiteAvatarStatusTheme;
statusPosition: FlowbitePositions;
}
Expand Down Expand Up @@ -108,7 +109,11 @@ const AvatarComponent: FC<AvatarProps> = ({
'data-testid': 'flowbite-avatar-img',
};
return (
<div className={twMerge(theme.root.base, className)} data-testid="flowbite-avatar" {...props}>
<div
className={twMerge(theme.root.base, stacked && theme.root.tooltip, className)}
data-testid="flowbite-avatar"
{...props}
>
<div className="relative">
{img ? (
typeof img === 'string' ? (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Avatar/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const avatarTheme: FlowbiteAvatarTheme = {
xl: 'w-36 h-36',
},
stacked: 'ring-2 ring-gray-300 dark:ring-gray-500',
tooltip: '-ml-2',
statusPosition: {
'bottom-left': '-bottom-1 -left-1',
'bottom-center': '-bottom-1 center',
Expand All @@ -54,7 +55,7 @@ export const avatarTheme: FlowbiteAvatarTheme = {
},
},
group: {
base: 'flex -space-x-4',
base: 'flex ml-4',
},
groupCounter: {
base: 'relative flex items-center justify-center w-10 h-10 text-xs font-medium text-white bg-gray-700 rounded-full ring-2 ring-gray-300 hover:bg-gray-600 dark:ring-gray-500',
Expand Down