2

I have button like the sample below with an icon (addFriendIcon).

https://developer.microsoft.com/en-us/fluentui#/controls/web/button

How do I add a style to this icon? For example change the color?


import * as React from 'react'; import { ActionButton, IIconProps } from 'office-ui-fabric-react';

const addFriendIcon: IIconProps = { iconName: 'AddFriend' };

export const ButtonActionExample: React.FunctionComponent = props => {

return ( Create account ); };

EvilEddie
  • 1,026
  • 2
  • 12
  • 23
  • Do you have a working example you can provide? If it's a react component, are you able to use `className`? – Dom Aug 11 '20 at 22:11
  • Here's a codepen from the official MS fluid site https://codepen.io/evileddie/pen/zYqvjpQ?editable=true%3Dhttps%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Ffluentui – EvilEddie Aug 11 '20 at 22:24

1 Answers1

4

If you want to do it the Fluent UI way, just add the according styles to the IIconProps:

const addFriendIcon: IIconProps = {
  iconName: 'AddFriend',
  styles: {
    root: { color: 'red' }
  }
};

Here is the adjusted codepen: https://codepen.io/alex3683/pen/RwarOrb

alex3683
  • 1,460
  • 14
  • 25