英文:
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.
<Box padding = {2 1 1 2}/>
答案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:
<Box
padding={(theme) => theme.spacing(2, 1, 1, 2)}
/>
Working CodeSandbox: https://codesandbox.io/s/box-padding-example-r6v28m?file=/demo.tsx
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论