diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 709deaab6f..824c089486 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -72,6 +72,10 @@ export type Props = $Omit, 'mode'> & { * Icon to display for the `Button`. */ icon?: IconSource; + /** + * Trailing icon to display for the `Button`. + */ + trailingIcon?: IconSource; /** * Whether the button is disabled. A disabled button is greyed out and `onPress` is not called on touch. */ @@ -170,6 +174,7 @@ const Button = ( dark, loading, icon, + trailingIcon, buttonColor: customButtonColor, textColor: customTextColor, rippleColor: customRippleColor, @@ -314,6 +319,23 @@ const Button = ( styles[`md3IconTextMode${compact ? 'Compact' : ''}`], ]; + const trailingIconStyle = + StyleSheet.flatten(contentStyle)?.flexDirection === 'row-reverse' + ? [ + styles.icon, + isV3 && styles[`md3Icon${compact ? 'Compact' : ''}`], + isV3 && + isMode('text') && + styles[`md3IconTextMode${compact ? 'Compact' : ''}`], + ] + : [ + styles.iconReverse, + isV3 && styles[`md3IconReverse${compact ? 'Compact' : ''}`], + isV3 && + isMode('text') && + styles[`md3IconReverseTextMode${compact ? 'Compact' : ''}`], + ]; + return ( {children} + {trailingIcon ? ( + + + + ) : null} diff --git a/src/components/__tests__/Button.test.tsx b/src/components/__tests__/Button.test.tsx index 572963a97d..ac33ddb034 100644 --- a/src/components/__tests__/Button.test.tsx +++ b/src/components/__tests__/Button.test.tsx @@ -58,6 +58,14 @@ it('renders button with icon', () => { expect(tree).toMatchSnapshot(); }); +it('renders button with trailing icon', () => { + const tree = render( + + ).toJSON(); + + expect(tree).toMatchSnapshot(); +}); + it('renders button with icon in reverse order', () => { const tree = render(