Label
<label> is a UI component that displays read-only text.
IMPORTANT: This <label> is not the same as the HTML <label>.
See also:
You can either use the <label> element's text prop or enter text as a child node.
import * as React from "react";
<label>This is a Label</label>
Styling the label
If you need to style parts of the text, you can use a combination of a FormattedString and Span elements.
You can either use the <span> element's text prop or enter text as a child node.
import * as React from "react";
import { Color } from "@nativescript/core";
<label textWrap={true}>
<formattedString>
<span>This text has a </span>
<span color={new Color("red")}>red </span>
<span>piece of text. </span>
<span fontStyle="italic">Also, this bit is italic, </span>
<span fontWeight="bold">and this bit is bold.</span>
</formattedString>
</label>
Props
| Name | Type | Description |
|---|---|---|
text | string | Gets or sets the text of the label. |
textWrap | boolean | Gets or sets whether the label wraps text. Default value: false. |
Native component
| Android | iOS |
|---|---|
android.widget.TextView | UILabel |