Guides

Typography

The theme has a set of text styles called the type scale. It is a Typography. Read it with MaterialTheme.typography.

Example

// Use a style from the theme
Text("Settings", style = MaterialTheme.typography.titleLarge)

// Change one thing of a style
Text("Done", style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold))

// Change styles for the whole app
MaterialTheme(typography = Typography(titleLarge = TextStyle(...))) { App() }

The type scale

There are five groups with three sizes each:

The 15 text styles of the theme
The 15 text styles of the theme
val t = MaterialTheme.typography
val styles = listOf(
    "displayLarge" to t.displayLarge, "displayMedium" to t.displayMedium, "displaySmall" to t.displaySmall,
    "headlineLarge" to t.headlineLarge, "headlineMedium" to t.headlineMedium, "headlineSmall" to t.headlineSmall,
    "titleLarge" to t.titleLarge, "titleMedium" to t.titleMedium, "titleSmall" to t.titleSmall,
    "bodyLarge" to t.bodyLarge, "bodyMedium" to t.bodyMedium, "bodySmall" to t.bodySmall,
    "labelLarge" to t.labelLarge, "labelMedium" to t.labelMedium, "labelSmall" to t.labelSmall,
)
Column {
    styles.forEach { (name, style) -> Text(name, style = style) }
}
Group Use it for Sizes (large / medium / small)
display Big numbers or short words, like a clock 57 / 45 / 36 sp
headline Page and section titles 32 / 28 / 24 sp
title Smaller titles: app bars, cards, dialogs 22 / 16 / 14 sp
body Running text 16 / 14 / 12 sp
label Text in buttons, chips, tabs and badges 14 / 12 / 11 sp

titleMedium, titleSmall and all label styles use medium weight. The others use regular.

Each style is a TextStyle: font, size, weight, line height and letter spacing in one value.

How Text picks a style

Text without a style uses LocalTextStyle. MaterialTheme sets it to bodyLarge.

Components set it for their own content. A Button sets labelLarge, a TopAppBar title titleLarge. That is why a plain Text("Save") inside a button already looks right.

You can do the same with ProvideTextStyle: every Text inside takes the style.

Two texts that take the style from ProvideTextStyle
Two texts that take the style from ProvideTextStyle
ProvideTextStyle(MaterialTheme.typography.headlineSmall) {
    Column {
        Text("Both lines")
        Text("use headlineSmall")
    }
}

Picking a style

Pick a style for each Text
Pick a style for each Text
Column(Modifier.width(300.dp)) {
    Text("Trip to Lisbon", style = MaterialTheme.typography.headlineSmall)
    Text("12 – 18 May", style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.primary)
    Spacer(Modifier.height(8.dp))
    // No style: Text uses bodyLarge from the theme.
    Text("Four days of old streets, tiles and the sea.")
    // Change one thing of a style with copy().
    Text("Booked", style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold))
}

Emphasized styles

Expressive adds an emphasized version of every style: titleLargeEmphasized, bodyMediumEmphasized, and so on. They are heavier, for text that should stand out, like a selected item or a key number.

Regular and emphasized stylesExpressive theme
Regular and emphasized styles
val t = MaterialTheme.typography
Column {
    Text("titleLarge", style = t.titleLarge)
    Text("titleLargeEmphasized", style = t.titleLargeEmphasized)
    Spacer(Modifier.height(8.dp))
    Text("bodyLarge", style = t.bodyLarge)
    Text("bodyLargeEmphasized", style = t.bodyLargeEmphasized)
}

They work in any theme, not only MaterialExpressiveTheme.

Your own type scale

Create a Typography and pass only the styles you want to change. Start from the defaults with copy(), so the sizes and line heights stay right:

A theme with a serif font for headlines
A theme with a serif font for headlines
val base = Typography()
// Change only the styles you need. The others keep their defaults.
val typography = Typography(
    headlineSmall = base.headlineSmall.copy(fontFamily = FontFamily.Serif),
    titleLarge = base.titleLarge.copy(fontFamily = FontFamily.Serif, fontSize = 24.sp),
)
MaterialTheme(typography = typography) {
    Column {
        Text("Serif headline", style = MaterialTheme.typography.headlineSmall)
        Text("Serif title", style = MaterialTheme.typography.titleLarge)
        Text("Body text keeps the default font.")
    }
}

To use one font everywhere, copy every style. A small helper keeps that short:

fun Typography.withFont(font: FontFamily) = Typography(
    displayLarge = displayLarge.copy(fontFamily = font),
    displayMedium = displayMedium.copy(fontFamily = font),
    // ... the same for all 15 styles
)

Loading a font

In Compose Multiplatform, put the font files in composeResources/font/. Then load them in a @Composable with Font(...):

@Composable
fun InterFamily() = FontFamily(
    Font(Res.font.inter_regular, FontWeight.Normal),
    Font(Res.font.inter_medium, FontWeight.Medium),
)

Add a file for each weight the theme uses: regular and medium. Without a medium file, the label and title styles fall back to regular.

Summary

You want Write
A theme style style = MaterialTheme.typography.titleLarge
Change one thing MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold)
A style for a whole block ProvideTextStyle(MaterialTheme.typography.titleMedium) { ... }
Stronger text (Expressive) MaterialTheme.typography.titleLargeEmphasized
Change fonts app-wide MaterialTheme(typography = Typography(...))