androidx.compose.material3

MaterialTheme

Object

A theme sets the colors, fonts, shapes and motion that all Material components inside it use. Wrap your whole app in one. The Theming guide explains dark mode, nested themes and adding your own values.

Read the current values anywhere with MaterialTheme.colorScheme, MaterialTheme.typography, MaterialTheme.shapes and MaterialTheme.motionScheme.

Your own colors
Your own colors
val myColors: ColorScheme = lightColorScheme(
    primary = Color(0xFF00696B),
    onPrimary = Color.White,
    secondaryContainer = Color(0xFFCCE8E8),
    onSecondaryContainer = Color(0xFF051F20),
)
MaterialTheme(colorScheme = myColors) {
    Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
        Button(onClick = {}) { Text("Primary") }
        FilledTonalButton(onClick = {}) { Text("Tonal") }
        OutlinedButton(onClick = {}) { Text("Outlined") }
    }
}

MaterialExpressiveTheme turns on the Expressive defaults: livelier motion and the Expressive component looks. Use it if your app uses Expressive components.

object MaterialTheme

Without motion

Colors, shapes and fonts.

@Composable
fun MaterialTheme(
    colorScheme: ColorScheme = MaterialTheme.colorScheme,
    shapes: Shapes = MaterialTheme.shapes,
    typography: Typography = MaterialTheme.typography,
    content: @Composable () -> Unit,
)

colorScheme: ColorSchemeOptional

Default: MaterialTheme.colorScheme

All colors of the theme. Use lightColorScheme(...) or darkColorScheme(...), and pass only the colors you want to change. Pick between them with isSystemInDarkTheme(). See the Colors guide.

shapes: ShapesOptional

Default: MaterialTheme.shapes

The corner sizes of the theme. See the Shapes guide.

typography: TypographyOptional

Default: MaterialTheme.typography

All text styles of the theme. Create one with Typography(...) and pass only the styles you want to change. See the Typography guide.

content: @Composable () -> UnitRequired

Your app. Everything inside uses this theme.

With motion

Also takes a motionScheme.

@Composable
fun MaterialTheme(
    colorScheme: ColorScheme = MaterialTheme.colorScheme,
    motionScheme: MotionScheme = MaterialTheme.motionScheme,
    shapes: Shapes = MaterialTheme.shapes,
    typography: Typography = MaterialTheme.typography,
    content: @Composable () -> Unit,
)

motionScheme: MotionSchemeOptionalSince 1.10

Default: MaterialTheme.motionScheme

How animations feel. MotionScheme.standard() is calm. MotionScheme.expressive() is bouncier.

How to get one

Create it

Properties

colorScheme

@Composable val colorScheme: ColorScheme

Retrieves the current ColorScheme at the call site's position in the hierarchy.

typography

@Composable val typography: Typography

Retrieves the current Typography at the call site's position in the hierarchy.

shapes

@Composable val shapes: Shapes

Retrieves the current Shapes at the call site's position in the hierarchy.

motionSchemeSince 1.10

@Composable val motionScheme: MotionScheme

Retrieves the current MotionScheme at the call site's position in the hierarchy.

LocalMaterialThemeSince 1.11

val LocalMaterialTheme: CompositionLocal<Values>

CompositionLocal providing MaterialTheme subsystems throughout the hierarchy. You can use properties in the companion object to access specific subsystems, for example colorScheme. To provide a new value for this, use MaterialTheme. This API is exposed to allow retrieving values from inside CompositionLocalConsumerModifierNode implementations - in most cases you should use colorScheme and other properties directly.

Nested types