How to use inline style in the react?

React inline style:

If we need inline style in the react then we can use CSS code in this "{{...}}" because we use CSS code in the pair key and value so we need to write code in the double curly braces. This means this is an object, if not mandatory then don't use inline CSS this is bad practice for the good code.

We don't use any CSS property with dash as "font-size" it will show error so we need use as "fontSize". Need to use camelcase code.

<h4 style={{color:'Red', fontSize:'100px'}}>Your text here</h4>
<p style={{border:'3px solid #f00'}}>Your text here </p>


No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.