Categories
JavaScript Answers

How to set inline styles with React?

Spread the love

Sometimes, we want to set inline styles with React.

In this article, we’ll look at how to set inline styles with React.

How to set inline styles with React?

To set inline styles with React, we set the style prop of an element.

For instance, we write

<span
  style={{ fontSize: 1.7 + "em" }}
  className="glyphicon glyphicon-remove-sign"
></span>

to set the fontSize property to set the font-size CSS property inline.

Conclusion

To set inline styles with React, we set the style prop of an element.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *