Text

Displays text with a style from the theme's type scale.

When to use

Pick a style from MaterialTheme.typography instead of setting font size and weight by hand. The style carries size, line height, letter spacing and weight together and follows theme changes.

Use the emphasized variants to mark selected or important text without changing its size.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Type scale in use

Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
    Text("Headline", style = MaterialTheme.typography.headlineMedium)
    Text("Emphasized title", style = MaterialTheme.typography.titleLargeEmphasized)
    Text("Body text uses the body styles for paragraphs.", style = MaterialTheme.typography.bodyLarge)
    Text("LABEL", style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.primary)
}

Parameters

NameTypeDefaultDescription
textString | AnnotatedStringThe content.
styleTextStyleLocalTextStyle.currentTake it from MaterialTheme.typography.
colorColorColor.UnspecifiedDefaults to the content color of the surface.
maxLines / overflowInt / TextOverflowInt.MAX_VALUE / ClipLimit and truncate long text.

Guidelines

Do:

Don't:

Accessibility

Related components