Logo

Text

The Text component displays textual information in a number of optional styles and variants.
You can learn more about this component in the Working with Text article.
Also note that variants of the Text component are also mapped to HtmlTag components. See the variant section to check which variant maps to which HtmlTag.

Properties

ellipses (default: true)

This property indicates whether ellipses should be displayed when the text is cropped (true) or not (false).
<App>
  <VStack width="120px">
    <Text
      backgroundColor="cyan"
      color="black"
      maxLines="1"
      ellipses="false">
      Though this long text does is about to crop!
    </Text>
    <Text
      backgroundColor="cyan"
      color="black"
      maxLines="1">
      Though this long text does is about to crop!
    </Text>
  </VStack>
</App>
Example: ellipses
<App>
  <VStack width="120px">
    <Text
      backgroundColor="cyan"
      color="black"
      maxLines="1"
      ellipses="false">
      Though this long text does is about to crop!
    </Text>
    <Text
      backgroundColor="cyan"
      color="black"
      maxLines="1">
      Though this long text does is about to crop!
    </Text>
  </VStack>
</App>

maxLines

This property determines the maximum number of lines the component can wrap to. If there is no space to display all the contents, the component displays up to as many lines as specified in this property. When the value is not defined, there is no limit on the displayed lines.
<App>
  <Text
    maxWidth="120px"
    backgroundColor="cyan"
    color="black"
    value="A long text that will likely overflow"
    maxLines="2" />
</App>
Example: maxLines
<App>
  <Text
    maxWidth="120px"
    backgroundColor="cyan"
    color="black"
    value="A long text that will likely overflow"
    maxLines="2" />
</App>

preserveLinebreaks (default: false)

This property indicates if linebreaks should be preserved when displaying text.
<App>
  <HStack>
    <Text
      width="250px"
      backgroundColor="cyan"
      color="black"
      preserveLinebreaks="true"
      value="(preserve) This long text
      with several line breaks
              does not fit into a viewport with a 200-pixel width." />
    <Text
      width="250px"
      backgroundColor="cyan"
      color="black"
      value="(don't preserve) This long text
      with several line breaks
              does not fit into a viewport with a 200-pixel width." />
  </HStack>
</App>
Example: preserveLinebreaks
<App>
  <HStack>
    <Text
      width="250px"
      backgroundColor="cyan"
      color="black"
      preserveLinebreaks="true"
      value="(preserve) This long text
      with several line breaks
              does not fit into a viewport with a 200-pixel width." />
    <Text
      width="250px"
      backgroundColor="cyan"
      color="black"
      value="(don't preserve) This long text
      with several line breaks
              does not fit into a viewport with a 200-pixel width." />
  </HStack>
</App>
Note: Remember to use the value property of the Text. Linebreaks are converted to spaces when nesting the text inside the Text component.

value

The text to be displayed. This value can also be set via nesting the text into the Text component.
<App>
  <Text value="An example text" />
  <Text>An example text</Text>
</App>
Example: value
<App>
  <Text value="An example text" />
  <Text>An example text</Text>
</App>

variant

An optional string value that provides named presets for text variants with a unique combination of font style, weight, size, color, and other parameters. If not defined, the text uses the current style of its context.
Available values:
ValueDescription
abbrRepresents an abbreviation or acronym
captionRepresents the caption (or title) of a table
citeIs used to mark up the title of a cited work
codeRepresents a line of code
codefenceHandles the display of code blocks if combined with a code variant
deletedRepresents text that has been deleted
emMarks text to stress emphasis
inheritRepresents text that inherits the style from its parent element
insertedRepresents a range of text that has been added to a document
keyboardRepresents a span of text denoting textual user input from a keyboard or voice input
markedRepresents text which is marked or highlighted for reference or notation
monoText using a mono style font family
paragraphRepresents a paragraph
placeholderText that is mostly used as the placeholder style in input controls
sampleRepresents sample (or quoted) output from a computer program
secondaryRepresents a bit dimmed secondary text
smallRepresents side-comments and small print
subSpecifies inline text as subscript
strongContents have strong importance
subheadingIndicates that the text is the subtitle in a heading
subtitleIndicates that the text is the subtitle of some other content
supSpecifies inline text as superscript
tableheadingIndicates that the text is a table heading
titleIndicates that the text is the title of some other content
varRepresents the name of a variable in a mathematical expression
Example: variant
HtmlTag Mappings
The table below indicates which Text variant maps to which HtmlTag component.
VariantComponent
abbrabbr
citecite
codecode
codefencepre
deleteddel
insertedins
keyboardkbd
markedmark
samplesamp
subsub
supsup
varvar
strongstrong
emem
paragraphp

Events

This component does not have any events.

Exposed Methods

This component does not expose any methods.

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-Text-codergb(from $color-surface-100 r g b / 0.4)rgb(from $color-surface-100 r g b / 0.4)
backgroundColor-Text-keyboardrgb(from $color-surface-100 r g b / 0.4)rgb(from $color-surface-100 r g b / 0.4)
backgroundColor-Text-markedrgb(from $color-primary-200 r g b / 0.4)rgb(from $color-primary-400 r g b / 0.4)
borderColor-Text-code$color-surface-100$color-surface-100
borderColor-Text-keyboard$color-surface-300$color-surface-300
borderRadius-Text$borderRadius$borderRadius
borderRadius-Text-code4px4px
borderRadius-Text-keyboardnonenone
borderStyle-Textsolidsolid
borderStyle-Text-codesolidsolid
borderStyle-Text-keyboardnonenone
borderWidth-Text$space-0$space-0
borderWidth-Text-code1px1px
borderWidth-Text-keyboard1px1px
color-Text-codefence$color-surface-900$color-surface-900
color-Text-markednonenone
color-Text-placeholder$color-surface-500$color-surface-500
color-Text-secondary$textColor-secondary$textColor-secondary
color-Text-subheading$textColor-secondary$textColor-secondary
fontFamily-Text$fontFamily$fontFamily
fontFamily-Text-code$fontFamily-monospace$fontFamily-monospace
fontFamily-Text-codefence$fontFamily-monospace$fontFamily-monospace
fontFamily-Text-keyboard$fontFamily-monospace$fontFamily-monospace
fontFamily-Text-mono$fontFamily-monospace$fontFamily-monospace
fontFamily-Text-sample$fontFamily-monospace$fontFamily-monospace
fontSize-Text$fontSize-small$fontSize-small
fontSize-Text-code$fontSize-small$fontSize-small
fontSize-Text-codefence$fontSize-code$fontSize-code
fontSize-Text-keyboard$fontSize-small$fontSize-small
fontSize-Text-markdownfontSize-TextfontSize-Text
fontSize-Text-paragraphnonenone
fontSize-Text-placeholder$fontSize-smaller$fontSize-smaller
fontSize-Text-sample$fontSize-small$fontSize-small
fontSize-Text-secondary$fontSize-small$fontSize-small
fontSize-Text-small$fontSize-small$fontSize-small
fontSize-Text-sub$fontSize-smaller$fontSize-smaller
fontSize-Text-subheading$fontSize-H6$fontSize-H6
fontSize-Text-subtitle$fontSize-medium$fontSize-medium
fontSize-Text-sup$fontSize-smaller$fontSize-smaller
fontSize-Text-tableheading$fontSize-H6$fontSize-H6
fontSize-Text-title$fontSize-large$fontSize-large
fontStyle-Text-citeitalicitalic
fontStyle-Text-emitalicitalic
fontStyle-Text-markednonenone
fontStyle-Text-placeholdernonenone
fontStyle-Text-subheadingnonenone
fontStyle-Text-varitalicitalic
fontWeight-Text$fontWeight-normal$fontWeight-normal
fontWeight-Text-abbr$fontWeight-bold$fontWeight-bold
fontWeight-Text-keyboard$fontWeight-bold$fontWeight-bold
fontWeight-Text-markdownfontWeight-TextfontWeight-Text
fontWeight-Text-markednonenone
fontWeight-Text-placeholdernonenone
fontWeight-Text-subheading$fontWeight-bold$fontWeight-bold
fontWeight-Text-tableheading$fontWeight-bold$fontWeight-bold
letterSpacing-Text-caption0.05rem0.05rem
letterSpacing-Text-subheading0.04em0.04em
lineHeight-Text-codefence1.51.5
lineHeight-Text-markednonenone
lineHeight-Text-small$lineHeight-tight$lineHeight-tight
marginBottom-Textnonenone
marginBottom-Text-codenonenone
marginBottom-Text-codefencenonenone
marginBottom-Text-markdown$space-6$space-6
marginBottom-Text-smallnonenone
marginBottom-Text-tableheading$space-4$space-4
marginLeft-Textnonenone
marginLeft-Text-codenonenone
marginLeft-Text-codefencenonenone
marginLeft-Text-markdownnonenone
marginLeft-Text-smallnonenone
marginRight-Textnonenone
marginRight-Text-codenonenone
marginRight-Text-codefencenonenone
marginRight-Text-markdownnonenone
marginRight-Text-smallnonenone
marginTop-Textnonenone
marginTop-Text-codenonenone
marginTop-Text-codefencenonenone
marginTop-Text-markdown$space-3$space-3
marginTop-Text-smallnonenone
marginTop-Text-tableheading$space-1$space-1
paddingBottom-Text-code2px2px
paddingHorizontal-Text-code$space-0_5$space-0_5
paddingHorizontal-Text-codefence$space-4$space-4
paddingHorizontal-Text-keyboard$space-1$space-1
paddingHorizontal-Text-tableheading$space-1$space-1
paddingVertical-Text-codefence$space-3$space-3
paddingVertical-Text-paragraph$space-1$space-1
textColor-Text$textColor-primary$textColor-primary
textDecorationColor-Text-deletednonenone
textDecorationColor-Text-insertednonenone
textDecorationLine-Text-deletedline-throughline-through
textDecorationLine-Text-insertedunderlineunderline
textDecorationStyle-Text-deletednonenone
textDecorationStyle-Text-insertednonenone
textDecorationThickness-Text-deletednonenone
textDecorationThickness-Text-insertednonenone
textTransform-Text-abbruppercaseuppercase
textTransform-Text-subheadinguppercaseuppercase
verticalAlignment-Textnonenone
verticalAlignment-Text-codenonenone
verticalAlignment-Text-codefencenonenone
verticalAlignment-Text-markdownnonenone
verticalAlignment-Text-smallnonenone
verticalAlignment-Text-subsubsub
verticalAlignment-Text-supsupersuper
This site is an XMLUI™ app.