Label
<Label>
is a UI component that displays read-only text.
This |
Examples
Example: Styling the label
If you need to style parts of the text, you can use a combination of a FormattedString
and Span
elements.
<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>
<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>
<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>
<label textWrap="true">
<FormattedString>
<span text="This text has a "></span>
<span text="red " style="color: red"></span>
<span text="piece of text. "></span>
<span text="Also, this bit is italic, " fontStyle="italic"></span>
<span text="and this bit is bold." fontWeight="bold"></span>
</FormattedString>
</label>
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 |
---|---|---|
|
|
Gets or sets letterSpace style property. |
|
|
Gets or sets lineHeight style property. |
|
|
Gets or sets the Label text. |
|
|
Gets or sets text-alignment style property. |
|
|
Gets or sets text decoration style property. |
|
|
Gets or sets text transform style property. |
|
|
Gets or sets whether the Label wraps text or not. |
|
|
Gets or sets the whitespace style. |
|
|
Additional inherited properties not shown. Refer to the API Reference |