Skip to content
NativeScript Unified

NativeScript views

Label and text runs

Label

<Label> shows text. The text input is the string to display. Child content is also projected.

FormattedString and Span

<FormattedString> holds <NSpan> children, each with its own text. Style a span with classes such as font-bold and text-primary, which work on both platforms. The web polyfill also reads font-weight and color attributes, but on a device those set nothing.

On a device MasonKit owns the span and Span tags, so NativeScript's own Span is <NSpan> (and its Button is <NButton>). The web polyfill answers to both Span and NSpan.

HTML-first equivalent

Write ordinary text elements. <Label text="..."> is a <p> or <span>, and <FormattedString> with <NSpan> children is inline markup. On a device, MasonKit nests them into one native text run:

Bold and teal and plain.