请求提供MUI v5全部可用样式简写属性完整列表
我完全懂这种找不到之前看过的文档内容的懊恼!MUI v5里这些便捷的样式简写其实属于它的系统属性(System Properties),下面整理了完整的常用简写列表,帮你快速查找:
MUI v5 样式简写属性完整列表
边距(Margin)简写
m:对应 CSS 属性margin(四边统一边距)mt:对应margin-topmb:对应margin-bottomml:对应margin-leftmr:对应margin-rightmx:同时控制margin-left和margin-right(水平方向边距)my:同时控制margin-top和margin-bottom(垂直方向边距)
内边距(Padding)简写
p:对应 CSS 属性padding(四边统一内边距)pt:对应padding-toppb:对应padding-bottompl:对应padding-leftpr:对应padding-rightpx:同时控制padding-left和padding-right(水平方向内边距)py:同时控制padding-top和padding-bottom(垂直方向内边距)
尺寸(Size)简写
width/w:对应widthminWidth/minW:对应min-widthmaxWidth/maxW:对应max-widthheight/h:对应heightminHeight/minH:对应min-heightmaxHeight/maxH:对应max-heightboxSizing:对应box-sizing
排版(Typography)简写
fontSize/fs:对应font-sizefontWeight/fw:对应font-weightfontStyle/fst:对应font-stylelineHeight/lh:对应line-heighttextAlign/ta:对应text-aligntextDecoration/td:对应text-decorationtextTransform/tt:对应text-transform
颜色与透明度简写
color/c:对应color(文字颜色)backgroundColor/bgcolor/bg:对应background-coloropacity:对应opacity
布局与定位简写
display/d:对应displayflexDirection/fd:对应flex-directionjustifyContent/jc:对应justify-contentalignItems/ai:对应align-itemsalignSelf/as:对应align-selfflexWrap/fw:对应flex-wrapflex:对应flexposition/pos:对应positiontop/t:对应topbottom/b:对应bottomleft/l:对应leftright/r:对应rightzIndex/z:对应z-index
使用示例
这些简写属性的值支持多种格式:数字(对应MUI主题的spacing值)、固定单位字符串、甚至响应式对象,比如:
<Stack mt={3} // 上边距等于 theme.spacing(3) px={{ xs: 2, md: 4 }} // 移动端水平内边距为2,桌面端为4 bg="#f5f5f5" // 背景色设为浅灰 jc="center" // flex主轴方向居中对齐 > {props.children} </Stack>
内容的提问来源于stack exchange,提问作者Cesar Cisneros
相关产品推荐
相关产品推荐

