0

I am trying use inline css in html content but it shows the error you see in the picture below;

enter image description here

How can I use inline css in spfx webpart ?

Community
  • 1
  • 1
TyForHelpDude
  • 4,828
  • 10
  • 48
  • 96

3 Answers3

2

<div className={`ms-Grid-col ms-u-md3`} style={{"border-color": "black"}}>
//Some Code
</div>
1

It is not a good practice to do it. You should better use the sass files and define your styles there. Since this is not HTML, but JSX you can do something like this:

var style = {
      color: 'white',
      fontSize: 200
    };

return <div style={style}> Have a good and productive day! </div>;

but this is not recommended. The code piece is not mine, but taken from this post React.js inline style best practices

Community
  • 1
  • 1
Velin Georgiev
  • 2,359
  • 1
  • 15
  • 21
1

Simple way to do it is as follows, enter image description here

Jatin patil
  • 4,252
  • 1
  • 18
  • 27