Text
Alpha.8 adds motionSurface for plain-text entrance and rolling counters. Use an explicit text prop; rich/slotted text is unsupported for these effects. See visual motion for the Jolt RC.11 requirement; this is included in alpha.8.
m-text · Typography, semantic colors and accessible text.
Usage
<m-text as="h1" variant="title">The day is yours.</m-text>
<m-text tone="muted">Ready when you are.</m-text>API
| Prop | Type | Default | Purpose |
|---|---|---|---|
variant | display / title / heading / body / caption / overline | body | Theme typography scale. |
weight | normal / bold / 100 … 900 (strings) | theme | Weight independent of size. |
tone | palette key | text | Semantic color. |
as | p / span / h1 … h6 | p | Semantics independent of appearance. |
align | left / center / right | left | Text alignment. |
wrap | boolean | true | Allows line wrapping. |
maxLines | positive integer | unlimited | Clamps wrapping text to that many lines and ends the last one with an ellipsis. |
text | string | — | Alternative to slot text. |
grow / shrink | number | 0 / context | Space distribution. |
variant controls appearance; as controls semantics. as="h1" through h6 produces HTML headings on the Web and the heading accessibility role on NativeScript. The slot accepts text and MSpan; use layouts for other views.
Full example
This file also runs in the NativeScript catalog and the Web preview.
View source
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
const { t } = useCatalogLocale()
withDefaults(defineProps<{ lang?: 'en' | 'pt' }>(), { lang: 'pt' })
</script>
<template>
<m-column gap="md">
<m-text variant="display">{{ t(lang === 'pt' ? 'Olá.' : 'Hello.') }}</m-text>
<m-text variant="title">{{ t('Title') }}</m-text>
<m-text variant="heading">{{ t('Heading') }}</m-text>
<m-text
>{{ t('Body · ')
}}{{ t(lang === 'pt' ? 'Espaço para suas palavras.' : 'Room for your words.') }}</m-text
>
<m-text variant="caption" tone="muted"
>{{ t('Caption · ')
}}{{ t(lang === 'pt' ? 'Os pequenos detalhes.' : 'The small details.') }}</m-text
>
<m-text variant="heading"
>{{ t(lang === 'pt' ? 'Cada palavra ' : 'Every word ')
}}<m-span emphasis="em" tone="primary">{{
t(lang === 'pt' ? 'tem seu lugar.' : 'has its place.')
}}</m-span></m-text
>
<m-text variant="caption" weight="bold">{{
t(
lang === 'pt'
? 'Pequeno no tamanho. Forte na intenção.'
: 'Small in size. Clear in intent.',
)
}}</m-text>
<m-text variant="overline" tone="primary">{{ t('OVERLINE') }}</m-text>
<m-text :maxLines="2">{{
lang === 'pt'
? 'Um parágrafo longo, que passa de duas linhas, termina do mesmo jeito em toda plataforma: a segunda linha acaba em reticências e o resto fica escondido.'
: 'A long paragraph that runs past two lines ends the same way on every platform: the second line closes with an ellipsis and the rest stays hidden.'
}}</m-text>
<m-row gap="md" wrap>
<m-text tone="success">{{ t('Success') }}</m-text>
<m-text tone="danger">{{ t('Danger') }}</m-text>
<m-text tone="muted">{{ t('Muted') }}</m-text>
</m-row>
</m-column>
</template>In context
See the components in a complete vehicle controls screen.
See Layout and text for flexible sizing, large text and RTL direction.
MSpan
<m-text as="h1" variant="title">
Cada xícara <m-span emphasis="em" tone="primary">conta uma história.</m-span>
</m-text>
<m-text variant="caption" weight="bold">Um pequeno destaque.</m-text>MSpan describes runs inside MText (or another MSpan). It accepts text or a text slot, weight, tone and emphasis="strong" | "em". Strong adds semantic importance and bold weight; em adds stress emphasis and italics. An explicit weight takes precedence over the emphasis weight. Nested runs inherit family, size, color and emphasis, and can override weight and tone.
Web uses escaped text inside strong/em/span. NativeScript uses one Label with FormattedString/Span, preserving a continuous reading order and system text scaling. Spaces between runs are preserved; Vue's compiler still applies its whitespace policy. Use explicit interpolation spaces when needed. Wrapping and alignment belong to the parent MText.
Arbitrary HTML, layouts, events and controls are rejected inside MSpan. Rendering it outside MText throws an actionable error. Links remain a separate navigation contract; color/emphasis does not make a run interactive. MText's text prop takes precedence over the entire slot.
See Typography and customization and Atelier.