Theming
A theme is one place for the colors, text styles, shapes and motion of your app. Components read it, so you don't pass these values around yourself.
Example
@Composable
fun AppTheme(content: @Composable () -> Unit) {
MaterialTheme(
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme(),
typography = Typography(),
shapes = Shapes(),
content = content,
)
}
// In main() or your Activity:
AppTheme { App() }
Write your own AppTheme once, and wrap your whole app in it.
Make a theme with the Theme Builder
The Material Theme Builder makes a full theme from one color or an image:
- Pick a source color, or upload an image to take colors from.
- Pick fonts for headlines and body text.
- Click Export and choose Jetpack Compose (Theme.kt).
You get Color.kt, Theme.kt and Type.kt with light, dark and high-contrast color schemes. They work in Compose Multiplatform too. Remove the Android-only parts, like dynamic color.
What a theme holds
| Part | Type | Read it with | Guide |
|---|---|---|---|
| Colors | ColorScheme |
MaterialTheme.colorScheme |
Colors |
| Text styles | Typography |
MaterialTheme.typography |
Typography |
| Corner shapes | Shapes |
MaterialTheme.shapes |
Shapes |
| Animations | MotionScheme |
MaterialTheme.motionScheme |
— |
Every parameter of MaterialTheme is optional. What you leave out stays as it is: the baseline values, or the values of a theme around it.
How components find the theme
MaterialTheme(...) { } doesn't pass anything as a parameter. It puts the values in CompositionLocals: values that every composable inside can read, however deep.
MaterialTheme.colorScheme is a short way to read one of them. Defaults read them too. When you write nothing, a Button calls ButtonDefaults.buttonColors(), which reads MaterialTheme.colorScheme.primary.
So: change the theme, and every default in it changes.
Two other locals matter for everyday code:
LocalContentColor: the color for text and icons. ASurfacesets it. See the Colors guide.LocalTextStyle: the style forTextwithout astyle. See the Typography guide.
Dark mode
Give the theme a different color scheme for dark mode. darkColorScheme is the dark version of the baseline colors.

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
MaterialTheme(colorScheme = lightColorScheme()) {
Surface(shape = MaterialTheme.shapes.medium) {
Button(onClick = {}, Modifier.padding(16.dp)) { Text("Light") }
}
}
MaterialTheme(colorScheme = darkColorScheme()) {
Surface(shape = MaterialTheme.shapes.medium) {
Button(onClick = {}, Modifier.padding(16.dp)) { Text("Dark") }
}
}
}
isSystemInDarkTheme() tells you what the system uses. It works on Android, desktop, iOS and web.
Only the colors change between light and dark. Keep the same typography and shapes.
Nested themes
A MaterialTheme inside another one changes only the part of the screen inside it. Start from the current values with copy():

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(onClick = {}) { Text("App theme") }
// Copy the current colors and change one. Everything inside uses the new primary.
MaterialTheme(colorScheme = MaterialTheme.colorScheme.copy(primary = Color(0xFF006A60))) {
Button(onClick = {}) { Text("Nested theme") }
}
}
Use it for a section with its own colors, like a brand area or a dark player bar on a light screen.
The Expressive theme
MaterialExpressiveTheme works like MaterialTheme, with two differences:
- Values you leave out use the Expressive defaults:
expressiveLightColorScheme()andMotionScheme.expressive(), which is bouncier. - Inside another theme, it keeps that theme's values instead.
Expressive components work in both themes. The Expressive theme only changes the defaults.
MaterialExpressiveTheme(
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else expressiveLightColorScheme(),
) { App() }
Your own theme values
Material has no slot for things like spacing sizes or extra brand colors. Add your own with a CompositionLocal, the same way Material does:

/** Your own theme value: a spacing that is not part of Material. */
val LocalSpacing = staticCompositionLocalOf { 8.dp }
CompositionLocalProvider(LocalSpacing provides 24.dp) {
// Anything inside can read LocalSpacing.current.
Row(horizontalArrangement = Arrangement.spacedBy(LocalSpacing.current)) {
OutlinedButton(onClick = {}) { Text("One") }
OutlinedButton(onClick = {}) { Text("Two") }
}
}
staticCompositionLocalOfis for values that rarely change, like spacing. UsecompositionLocalOffor values that change often.- Put the
CompositionLocalProviderin yourAppTheme, next toMaterialTheme. - To read it like the Material values, add an object:
object AppTheme {
val spacing: Dp
@Composable get() = LocalSpacing.current
}
// AppTheme.spacing
Summary
| You want | Write |
|---|---|
| One theme for the app | MaterialTheme(colorScheme, typography, shapes) { App() } |
| Dark mode | colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme() |
| Read a value | MaterialTheme.colorScheme.primary |
| Change part of a screen | A nested MaterialTheme(colorScheme = MaterialTheme.colorScheme.copy(...)) |
| Expressive defaults | MaterialExpressiveTheme { ... } |
| Your own value | staticCompositionLocalOf + CompositionLocalProvider |