文本样式属性
示例
- TypeScript
- JavaScript
参考
属性
color
类型 |
---|
颜色 |
fontFamily
类型 |
---|
字符串 |
fontSize
类型 |
---|
数字 |
fontStyle
类型 |
---|
enum('normal' , 'italic' ) |
fontWeight
指定字体粗细。大多数字体支持 'normal'
和 'bold'
值。并非所有字体都支持每个数值变体,在这种情况下会选择最接近的变体。
类型 | 默认值 |
---|---|
enum('normal' , 'bold' , '100' , '200' , '300' , '400' , '500' , '600' , '700' , '800' , '900' ) 或 数字 | 'normal' |
includeFontPadding
Android
设置为 false
以移除额外的字体内边距,这些内边距旨在为某些上升/下降部留出空间。对于某些字体,当垂直居中时,此内边距可能会使文本看起来略微错位。为了获得最佳效果,也请将 textAlignVertical
设置为 center
。
类型 | 默认值 |
---|---|
布尔值 | true |
fontVariant
允许你设置字体的所有变体。可以通过使用枚举数组或空格分隔的字符串来设置,例如 'small-caps common-ligatures'
。
类型 | 默认值 |
---|---|
array of enum('small-caps' , 'oldstyle-nums' , 'lining-nums' , 'tabular-nums' , 'proportional-nums' ) 或 字符串 | [] |
letterSpacing
增加或减少字符之间的间距。默认情况下,没有额外的字母间距。
类型 |
---|
数字 |
lineHeight
数值,用于控制文本元素中多行文本之间的垂直间距。它指定了连续文本行基线之间的距离。
类型 |
---|
数字 |
textAlign
指定文本对齐方式。在 Android 上,只有 Oreo (8.0) 或更高版本(API 级别 >= 26)支持 'justify'
值。在较低的 Android 版本上,该值将回退为 left
。
类型 | 默认值 |
---|---|
enum('auto' , 'left' , 'right' , 'center' , 'justify' ) | 'auto' |
textAlignVertical
Android
类型 | 默认值 |
---|---|
enum('auto' , 'top' , 'bottom' , 'center' ) | 'auto' |
textDecorationColor
iOS
类型 |
---|
颜色 |
textDecorationLine
类型 | 默认值 |
---|---|
enum('none' , 'underline' , 'line-through' , 'underline line-through' ) | 'none' |
textDecorationStyle
iOS
类型 | 默认值 |
---|---|
enum('solid' , 'double' , 'dotted' , 'dashed' ) | 'solid' |
textShadowColor
类型 |
---|
颜色 |
textShadowOffset
类型 |
---|
object: {width?: number, height?: number} |
textShadowRadius
类型 |
---|
数字 |
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 |