跳到主要内容

文本样式属性

示例

参考

属性

color

类型
color

fontFamily

类型
string

iOS 支持通用字体族 system-uiui-sans-serifui-serifui-monospaceui-rounded


fontSize

类型
number

fontStyle

类型
enum('normal', 'italic')

fontWeight

指定字体粗细。大多数字体支持 'normal''bold',并非所有字体都支持所有数值型选项,在不存在的情况下会选择最接近的。

类型默认值
enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') 或 number'normal'

includeFontPadding
Android

设置为 false 可移除字体用于部分字符(如升部和降部)预留的额外内边距。部分字体中,这样的内边距可能导致文本垂直居中时轻微偏移。建议配合 textAlignVertical 设置为 center

类型默认值
booltrue

fontVariant

允许设置字体的所有变体。可传入枚举数组或以空格分隔的字符串,例如 'small-caps common-ligatures'

类型默认值
枚举数组('small-caps', 'oldstyle-nums', 'lining-nums', 'tabular-nums', 'proportional-nums') 或字符串[]

letterSpacing

控制字符间距,可增加或减少。默认无额外字间距。

类型
number

lineHeight

数值,控制文本行间的垂直间距,即相邻文本行基线间的距离。

类型
number

textAlign

文本对齐方式。在 Android 中,justify 仅在 Oreo (8.0) 或更高版本(API >= 26)支持。低版本会回退到 left

类型默认值
enum('auto', 'left', 'right', 'center', 'justify')'auto'

textAlignVertical
Android

类型默认值
enum('auto', 'top', 'bottom', 'center')'auto'

textDecorationColor
iOS

类型
color

textDecorationLine

类型默认值
enum('none', 'underline', 'line-through', 'underline line-through')'none'

textDecorationStyle
iOS

类型默认值
enum('solid', 'double', 'dotted', 'dashed')'solid'

textShadowColor

类型
color

textShadowOffset

类型
对象: {width?: number, height?: number}

textShadowRadius

类型
number

textTransform

类型默认值
enum('none', 'uppercase', 'lowercase', 'capitalize')'none'

verticalAlign
Android

类型默认值
enum('auto', 'top', 'bottom', 'middle')'auto'

writingDirection
iOS

类型默认值
enum('auto', 'ltr', 'rtl')'auto'

userSelect

允许用户选择文本并使用系统的复制粘贴功能。优先级高于 selectable 属性。

类型默认值
enum('auto', 'text', 'none', 'contain', 'all')none