diff --git a/components/src/components/atoms/Banner/Banner.tsx b/components/src/components/atoms/Banner/Banner.tsx index 28bb0b1a..0d9a9906 100644 --- a/components/src/components/atoms/Banner/Banner.tsx +++ b/components/src/components/atoms/Banner/Banner.tsx @@ -269,48 +269,61 @@ const defaultIconType = ( return 'none' } -export const Banner = ({ - title, - alert = 'info', - icon, - iconType, - as: asProp, - children, - onDismiss, - ...props -}: React.PropsWithChildren) => { - const Icon = - icon || - (alert && ['error', 'warning'].includes(alert) ? : ) - - const hasHref = !!props.href - const hasAction = hasHref || !!props.onClick - const _iconType = iconType || defaultIconType(alert, icon) - - return ( - - {_iconType !== 'none' && ( - - {Icon} - - )} - - {title && {title}} - {children} - - - - ) -} +export const Banner = React.forwardRef< + HTMLDivElement, + React.PropsWithChildren +>( + ( + { + title, + alert = 'info', + icon, + iconType, + as: asProp, + children, + onDismiss, + ...props + }, + ref, + ) => { + const Icon = + icon || + (alert && ['error', 'warning'].includes(alert) ? ( + + ) : ( + + )) + + const hasHref = !!props.href + const hasAction = hasHref || !!props.onClick + const _iconType = iconType || defaultIconType(alert, icon) + + return ( + + {_iconType !== 'none' && ( + + {Icon} + + )} + + {title && {title}} + {children} + + + + ) + }, +) Banner.displayName = 'Banner'