3

Im trying to use the CSS grid in a React component, but I get an error in the first dash of grid-template-columns, any ideas why this happens?

<div style={{display:'grid', grid-template-columns: '1fr 1fr'}}>
ravibagul91
  • 20,072
  • 5
  • 36
  • 59
Tapioca
  • 309
  • 3
  • 7

1 Answers1

8

From the docs,

The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string.

In React, inline style uses camelCase name for CSS properties without -, like

<div style={{display:'grid', gridTemplateColumns: '1fr 1fr'}}>
ravibagul91
  • 20,072
  • 5
  • 36
  • 59