Skip to content

Commit

Permalink
Allow passing style attribute down to Avatar component
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain committed Aug 9, 2023
1 parent 34273d0 commit 71af95c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(
type = "round",
className = "",
size,
style = {},
onError,
...props
},
ref,
) {
const hash = useIdColorHash(id);
const style = {
"--cpd-avatar-size": size,
} as React.CSSProperties;
const fallbackInitial = <>{getInitialLetter(name)}</>;

return (
Expand All @@ -59,7 +57,12 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(function Avatar(
data-type={type}
data-color={hash}
className={classnames(styles.avatar, className)}
style={style}
style={
{
...style,
"--cpd-avatar-size": size,
} as React.CSSProperties
}
>
{!src ? (
fallbackInitial
Expand Down

0 comments on commit 71af95c

Please sign in to comment.