Home  >  Q&A  >  body text

React MUI fills properties clockwise

<p>Does MuiBox have any populated shorthand properties? for clockwise syntax? </p><p>This is invalid and will cause a syntax error. </p> <pre class="brush:php;toolbar:false;"><Box padding = {2 1 1 2}/></pre> <p><br /></p>
P粉312195700P粉312195700476 days ago449

reply all(1)I'll reply

  • P粉950128819

    P粉9501288192023-07-26 09:59:00

    Strictly speaking, there will be no such shorthand attribute, and the padding/p attribute only accepts a single spacing value. If you don't want to use the provided long-hand properties (pt, pr, pb, pl) and for some reason need to pass them as a list, the best way is to provide a function to the padding/p property from which Box can be derived value (if you don't want to use sx). For example:

    <Box
      padding={(theme) => theme.spacing(2, 1, 1, 2)}
    />

    Runnable CodeSandbox example code: : https://codesandbox.io/s/box-padding-example-r6v28m?file=/demo.tsx

    reply
    0
  • Cancelreply