diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index bd42c7d4b6..d5701168b7 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -22,36 +22,31 @@ export const Avatar = React.forwardRef((props, ref) className, style: styleProp, qa, + children, } = props; const style = {backgroundColor, color: borderColor, ...styleProp}; - const renderContent = () => { - if ('imgUrl' in props && props.imgUrl) { - return ( - - ); - } + let content: React.ReactNode = null; - if ('icon' in props && props.icon) { - return ; - } - - if ('text' in props && props.text) { - return ; - } - - return null; - }; + if ('imgUrl' in props && props.imgUrl) { + content = ( + + ); + } else if ('icon' in props && props.icon) { + content = ; + } else if ('text' in props && props.text) { + content = ; + } return (
((props, ref) ref={ref} {...filterDOMProps(props, {labelable: true})} > - {renderContent()} + {content} + {children}
); }); diff --git a/src/components/Avatar/types/main.ts b/src/components/Avatar/types/main.ts index 242b1ebf38..9f984db2a4 100644 --- a/src/components/Avatar/types/main.ts +++ b/src/components/Avatar/types/main.ts @@ -18,6 +18,7 @@ interface AvatarBaseProps extends AriaLabelingProps, DOMProps, QAProps { backgroundColor?: string; borderColor?: string; title?: string; + children?: React.ReactNode; } export type AvatarProps = AvatarBaseProps &