@@ -45,7 +45,12 @@ export const Button = <RootComponent extends React.ElementType = 'button'>(
4545 } = props ;
4646
4747 const translate = useTranslate ( ) ;
48- const translatedLabel = label ? translate ( label , { _ : label } ) : undefined ;
48+ let translatedLabel = label ;
49+ if ( typeof label === 'string' ) {
50+ translatedLabel = translate ( label , {
51+ _ : label ,
52+ } ) ;
53+ }
4954 const linkParams = getLinkParams ( locationDescriptor ) ;
5055
5156 const isXSmall = useMediaQuery ( ( theme : Theme ) =>
@@ -56,7 +61,12 @@ export const Button = <RootComponent extends React.ElementType = 'button'>(
5661 label && ! disabled ? (
5762 < Tooltip title = { translatedLabel } >
5863 < IconButton
59- aria-label = { translatedLabel }
64+ // If users provide a ReactNode as label, its their responsibility to also provide an aria-label should they need it
65+ aria-label = {
66+ typeof translatedLabel === 'string'
67+ ? translatedLabel
68+ : undefined
69+ }
6070 className = { className }
6171 color = { color }
6272 size = "large"
@@ -83,7 +93,12 @@ export const Button = <RootComponent extends React.ElementType = 'button'>(
8393 className = { className }
8494 color = { color }
8595 size = { size }
86- aria-label = { translatedLabel }
96+ // If users provide a ReactNode as label, its their responsibility to also provide an aria-label should they need it
97+ aria-label = {
98+ typeof translatedLabel === 'string'
99+ ? translatedLabel
100+ : undefined
101+ }
87102 disabled = { disabled }
88103 startIcon = { alignIcon === 'left' && children ? children : undefined }
89104 endIcon = { alignIcon === 'right' && children ? children : undefined }
@@ -102,7 +117,7 @@ interface Props<RootComponent extends React.ElementType> {
102117 component ?: RootComponent ;
103118 to ?: LocationDescriptor | To ;
104119 disabled ?: boolean ;
105- label ?: string ;
120+ label ?: React . ReactNode ;
106121 size ?: 'small' | 'medium' | 'large' ;
107122 variant ?: string ;
108123}
0 commit comments