React MUI顺时针填充属性

huangapple go评论61阅读模式
英文:

React MUI Clockwise padding properties

问题

Mui Box有任何填充的速记属性吗?用于顺时针语法?

这是不起作用的,并且会产生语法错误。

<Box padding={2 1 1 2}/>
英文:

Does Mui Box have any padding shorthand properties? for clockwise syntax?

This does not work and gives syntax error.

&lt;Box padding = {2 1 1 2}/&gt;

答案1

得分: 1

Not directly, no -- padding/p only accepts a single spacing value. If you do not want to use the longhand properties provided (pt, pr, pb, pl), and need to pass them as a list for some reason, your best bet is to provide a function to the padding/p prop from which the Box can derive the values (if you don't want to use sx). For example:

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

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

英文:

Not directly, no -- padding/p only accepts a single spacing value. If you do not want to use the longhand properties provided (pt, pr, pb, pl), and need to pass them as a list for some reason, your best bet is to provide a function to the padding/p prop from which the Box can derive the values (if you don't want to use sx). For example:

&lt;Box
  padding={(theme) =&gt; theme.spacing(2, 1, 1, 2)}
/&gt;

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

huangapple
  • 本文由 发表于 2023年7月18日 02:08:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76707071.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定