0

I am using Material UI 4 for React, and receiving error below. How do I fix? It actually works in modifying CSS, and I got similar code from here Why does my MUI Divider not show up in a MUI Container or Paper? .

Code:

  <Divider style={{ padding: '1px' }} />

Error:

(property) style: {
    padding: string;
}
Type '{ style: { padding: string; }; }' is not assignable to type 'IntrinsicAttributes & DividerProps'.
  Property 'style' does not exist on type 'IntrinsicAttributes & DividerProps'.ts(2322)

enter image description here

mattsmith5
  • 540
  • 4
  • 29
  • 67

1 Answers1

1

MUI encourages the usage of sx prop and prefers it over style attribute.

  <Divider sx={{ padding: "1px" }} />

https://mui.com/system/the-sx-prop/

With sx you can shorten your styling object even further by using p instead of padding:

  <Divider sx={{ p: "1px" }} />
sm3sher
  • 2,764
  • 1
  • 11
  • 23