跳至主内容

文本样式属性

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

示例

参考

属性

color

Type
color

fontFamily

Type
string

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


fontSize

Type
number

fontStyle

Type
enum('normal', 'italic')

fontWeight

指定字体粗细。大多数字体支持 'normal''bold' 这两个值。并非所有字体都支持所有数值选项,这种情况下会自动选择最接近的数值。

TypeDefault
enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') or number'normal'

includeFontPadding
Android

设置为 false 可移除为某些上伸部/下伸部预留的额外内边距。部分字体中,此内边距可能导致垂直居中的文本显示偏移。为获得最佳效果,建议同时设置 textAlignVerticalcenter

TypeDefault
booltrue

fontVariant

支持设置字体的所有变体形式。可通过枚举数组或空格分隔的字符串设置,例如 'small-caps common-ligatures'

TypeDefault
array of enum('small-caps', 'oldstyle-nums', 'lining-nums', 'tabular-nums', 'proportional-nums') or string[]

letterSpacing

增减字符间距。默认无额外字间距。

Type
number

lineHeight

控制文本元素内行间垂直间距的数值。指定连续文本行基线之间的距离。

Type
number

textAlign

指定文本对齐方式。在 Android 上,'justify' 值仅支持 Oreo (8.0) 及以上版本(API level >= 26)。低版本 Android 会自动回退为 left

TypeDefault
enum('auto', 'left', 'right', 'center', 'justify')'auto'

textAlignVertical
Android

TypeDefault
enum('auto', 'top', 'bottom', 'center')'auto'

textDecorationColor
iOS

Type
color

textDecorationLine

TypeDefault
enum('none', 'underline', 'line-through', 'underline line-through')'none'

textDecorationStyle
iOS

TypeDefault
enum('solid', 'double', 'dotted', 'dashed')'solid'

textShadowColor

Type
color

textShadowOffset

Type
object: {width?: number, height?: number}

textShadowRadius

Type
number

textTransform

TypeDefault
enum('none', 'uppercase', 'lowercase', 'capitalize')'none'

verticalAlign
Android

TypeDefault
enum('auto', 'top', 'bottom', 'middle')'auto'

writingDirection
iOS

TypeDefault
enum('auto', 'ltr', 'rtl')'auto'

userSelect

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

TypeDefault
enum('auto', 'text', 'none', 'contain', 'all')none