Preview 2.0 is now in Public Beta!
Read the Announcement
Note: You are on the beta version of our docs. This is a work in progress and may contain broken links and pages.

<Label> is a UI component that displays read-only text.

🟠 Note

This <Label> is not the same as the HTML <Label>.


Simple label

xml
<Label text="Label" />

Styling the label

If you need to style parts of the text, you can use a combination of a FormattedString and Span elements.

xml
<Label textWrap="true">
  <FormattedString>
    <Span text="This text has a " />
    <Span text="red " style="color: red" />
    <Span text="piece of text. " />
    <Span text="Also, this bit is italic, " fontStyle="italic" />
    <Span text="and this bit is bold." fontWeight="bold" />
  </FormattedString>
</Label>

Props

letterSpacing

xml
<Label text="Hello there!" letterSpacing="1"/>

Type: number

Gets or sets letter-spacing style property.


lineHeight

xml
<Label text="Hello there!" lineHeight="10"/>

Type: number

Gets or sets line-height style property.


text

xml
<Label text="Hello there!" />

Type: string Gets or sets the text displayed or to be displayed by the Label instance.


textAlignment

xml
<Label text="Hello there!" textAlignment="center" />

Gets or sets text-alignment style property. Valid values: "initial" | "left" | "center" | "right". Defaults to "left"


textDecoration

xml
<Label text="Hello there!" textDecoration="underline" />

Gets or sets text decoration style property. See TextDecorationType for valid values. Defaults to "none".


textTransform

xml
<Label text="Hello there!" textTransform="capitalize"/>

Gets or sets text transform style property. See TextTransformType for valid values. Defaults to "initial".


textWrap

xml
<Label text="In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available." textWrap="true"/>

Gets or sets whether the text breaks and renders on the next line if the current runs out of space. Defaults to false.


whiteSpace

xml
<Label text="In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available." whiteSpace="normal"/>

Gets or sets the white space style. Valid values: "initial" | "normal" | "nowrap" Defaults to "initial".


...Inherited

For additional inherited properties, refer to the API Reference.

Event(s)

textChange

xml
    <Label text="{{ greeting }}" loaded="{{ onLabelLoaded }}"/>
ts
onLabelLoaded(args: EventData) {
    const label = args.object as Label

    label.on("textChange", (textChangeEvent: PropertyChangeData)=>{

    console.log(textChangeEvent.eventName)
    })
}

Emitted when the label text is changed.


Native component

AndroidiOS
android.widget.TextViewUILabel
Previous
Image