- Instant help with your JavaScript coding problems

Use inline style in React

Question:
How to use inline style in React?
Answer:
<div style={{left:20; borderTop:'2px solid red'}}>

<div style={{left: this.state.left}}>
Description:

The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string. React will automatically append a “px” suffix to certain numeric inline style properties. If you want to use units other than “px”, specify the value as a string with the desired unit.

 

 

Share "How to use inline style in React?"
Tags:
react inline style, inline style, react style object
Technical term:
Use inline style in React