Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use any CSS with a dash in the name for inline CSS in React (parser error)

Tags:

reactjs

How can one use inline CSS with a dash in the name of the property in React?

My parser throws the following error when I do:

TS1005: The parser expected to find a '}' to match the '{' token here.

For example:

<div style={{background-color:blue}}/>
like image 772
samuelnihoul Avatar asked Oct 30 '25 14:10

samuelnihoul


1 Answers

Usually inline CSS in React does not include the dash. So background-color would be backgroundColor.

See e.g. Styling React Using CSS.

like image 161
David Harvey Avatar answered Nov 02 '25 04:11

David Harvey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!