跳到內容
+

字體排印

常見文字工具的文件與範例,用於控制對齊、換行、粗細等等。

變體

subtitle2
body1
body2
<Box sx={{ typography: 'subtitle2' }}>// theme.typography.subtitle2
<Box sx={{ typography: 'body1' }}><Box sx={{ typography: 'body2' }}>

文字對齊

Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus.
靠左對齊文字。
居中對齊文字。
靠右對齊文字。
<Box sx={{ textAlign: 'left' }}><Box sx={{ textAlign: 'center' }}><Box sx={{ textAlign: 'right' }}>

文字轉換

大寫開頭文字。
小寫文字。
大寫文字。
<Box sx={{ textTransform: 'capitalize' }}><Box sx={{ textTransform: 'lowercase' }}><Box sx={{ textTransform: 'uppercase' }}>

字體粗細

一般
中等
500
粗體
<Box sx={{ fontWeight: 'light' }}>// theme.typography.fontWeightLight
<Box sx={{ fontWeight: 'regular' }}><Box sx={{ fontWeight: 'medium' }}><Box sx={{ fontWeight: 500 }}><Box sx={{ fontWeight: 'bold' }}>

字體大小

預設
h6.fontSize
16px
<Box sx={{ fontSize: 'default' }}>// theme.typography.fontSize
<Box sx={{ fontSize: 'h6.fontSize' }}><Box sx={{ fontSize: 16 }}>

字體樣式

一般字體樣式。
斜體字體樣式。
傾斜字體樣式。
<Box sx={{ fontStyle: 'normal' }}><Box sx={{ fontStyle: 'italic' }}><Box sx={{ fontStyle: 'oblique' }}>

字體族系

預設
Monospace
<Box sx={{ fontFamily: 'default' }}><Box sx={{ fontFamily: 'Monospace' }}>

字元間距

字元間距 6px。
字元間距 10px。
<Box sx={{ letterSpacing: 6 }}><Box sx={{ letterSpacing: 10 }}>

行高

一般高度。
line-height: 2
<Box sx={{ lineHeight: 'normal' }}><Box sx={{ lineHeight: 10 }}>

API

import { typography } from '@mui/system';
導入名稱 Prop CSS 屬性 主題鍵
typography typography font-family, font-weight, font-size, line-height, letter-spacing, text-transform typography
fontFamily fontFamily font-family typography
fontSize fontSize font-size typography
fontStyle fontStyle font-style typography
fontWeight fontWeight font-weight typography
letterSpacing letterSpacing letter-spacing none
lineHeight lineHeight line-height none
textAlign textAlign text-align none
textTransform textTransform text-transform none