The Text
component is used to display one or more lines of read-only text in the Scripting app. It supports plain text, attributed text (Markdown), and rich text styling.
TextProps
Defines the properties that can be passed to the Text
component. There are three possible structures for the TextProps
type:
Plain Text Props
children
(optional):
null | string | number | boolean | Array<string | number | boolean | undefined | null>
Markdown Text Props
attributedString
(optional):
string
Rich Text Props
styledText
(optional):
StyledText
UnderlineStyle
Defines the available underline styles for rich text:
"byWord"
: Underline each word."double"
: Double underline."patternDash"
: Dashed underline."patternDashDot"
: Dash-dot underline."patternDashDotDot"
: Dash-dot-dot underline."patternDot"
: Dotted underline."single"
: Single underline."thick"
: Thick underline.StyledText
Defines the structure for rich text styling:
font
(optional): Specifies the font name. Example: "title"
, "body"
.fontDesign
(optional): Customizes the font design. Example: "serif"
, "monospaced"
.fontWeight
(optional): Adjusts font weight. Example: "light"
, "bold"
.italic
(optional): Adds italic styling. Type: boolean
.bold
(optional): Adds bold styling. Type: boolean
.baselineOffset
(optional): Adjusts text's baseline position. Type: number
.kerning
(optional): Adjusts spacing between characters. Type: number
.monospaced
(optional): Uses a monospaced font. Type: boolean
.monospacedDigit
(optional): Ensures consistent width for numeric characters. Type: boolean
.underlineColor
(optional): Color for the underline. Type: Color
.underlineStyle
(optional): Style for the underline. Type: UnderlineStyle
.strokeColor
(optional): Color for the text stroke. Type: Color
.strokeWidth
(optional): Width of the text stroke. Type: number
.strikethroughColor
(optional): Color for the strikethrough. Type: Color
.strikethroughStyle
(optional): Style for the strikethrough. Type: UnderlineStyle
.foregroundColor
(optional): Text color. Type: Color
.backgroundColor
(optional): Background color for the text. Type: Color
.content
(required): Specifies the text content. Can be a string or an array of strings and StyledText
objects.link
(optional): URL to linkify the text. Type: string
.onTapGesture
(optional): A function to execute when the text is tapped. Type: () => void
.Text
ComponentA view that displays one or more lines of read-only text. The content can be styled using the properties in TextProps
.
Plain Text
Markdown Text
Rich Text
font
is not specified, the default system font is used.styledText
object remains immutable to avoid unnecessary re-renders.onTapGesture
property within StyledText
to add interactivity.