Migrating Material 2 colors to Material 3
A Material 2 palette is a handful of hand-picked shades: a primary, a darker and a lighter primary, and an accent. Material 3 generates around 50 color roles from one seed color, in light and dark. Moving over means picking a seed, then renaming every place that used the old roles.
1. Pick the seed
Use your Material 2 primary (the 500 shade) as the seed. Material 3 keeps its hue but picks its own tones, so the new primary is usually a little darker or softer than the old one. If you need the exact old color, choose the Fidelity or Content scheme in the theme builder: they stay closest to the seed.
Your old accent has no direct slot. Material 3 derives secondary from the seed. The usual home for a distinct accent is tertiary: build its tonal palette from the accent and use tones 40/100/90/10 in light and 80/20/30/90 in dark. Every palette page on this site shows that mapping.
2. Map the roles
| Material 2 | Material 3 | Notes |
|---|---|---|
primary (500) | primary | Filled buttons, active states. |
primaryVariant / primary dark (700) | primaryContainer or none | Status bars are transparent with edge-to-edge, so the dark primary is often not needed. |
| primary light (100) | primaryContainer | Selected and highlighted areas. |
secondary / accent | tertiary (or secondary) | FABs moved to primaryContainer. |
secondaryVariant | tertiaryContainer | |
background, surface | surface, surfaceContainer* | Five container levels replace elevation overlays. |
onPrimary, onSecondary, onSurface, onError | Same names, plus on…Container | Always pair a role with its on-role. |
| Primary text (87% black) | onSurface | |
| Secondary text (54% black) | onSurfaceVariant | |
| Divider (12% black) | outlineVariant | Use outline for borders that must be visible. |
error | error, errorContainer |
3. Update the code
Jetpack Compose
| Before | After |
|---|---|
androidx.compose.material | androidx.compose.material3 |
lightColors() / darkColors() | lightColorScheme() / darkColorScheme() |
MaterialTheme(colors = …) | MaterialTheme(colorScheme = …) |
MaterialTheme.colors.primaryVariant | MaterialTheme.colorScheme.primaryContainer |
MaterialTheme.colors.secondary | MaterialTheme.colorScheme.tertiary or .secondary |
ContentAlpha.medium | MaterialTheme.colorScheme.onSurfaceVariant |
// Material 3 scheme from your old primary, with the old accent kept as tertiary
private val LightColors = lightColorScheme(
primary = md_theme_light_primary,
// ...every role from the theme builder export...
tertiary = Color(0xFFB81D27), // accent palette, tone 40
tertiaryContainer = Color(0xFFFFDAD7), // tone 90
)
@Composable
fun AppTheme(content: @Composable () -> Unit) {
MaterialTheme(colorScheme = if (isSystemInDarkTheme()) DarkColors else LightColors, content = content)
}
Android XML (Material Components)
| Before | After |
|---|---|
Theme.MaterialComponents.* | Theme.Material3.* |
colorPrimaryVariant | colorPrimaryContainer |
colorSecondaryVariant | colorTertiaryContainer |
colorAccent (AppCompat) | colorTertiary or colorSecondary |
android:textColorSecondary | colorOnSurfaceVariant |
android:statusBarColor | Edge-to-edge, transparent system bars |
Material 3 versions of the classic colors
Each classic Material color, used as a seed at shade 500:
| Classic 500 | M3 primary | M3 primary container | Theme |
|---|---|---|---|
#F44336 Red |
#904A42 |
#FFDAD5 |
Material Red |
#E91E63 Pink |
#8E4957 |
#FFD9DE |
Material Pink |
#9C27B0 Purple |
#7B4E7F |
#FFD6FE |
Material Purple |
#673AB7 Deep Purple |
#68548E |
#EBDDFF |
Material Deep Purple |
#3F51B5 Indigo |
#515B92 |
#DEE0FF |
Material Indigo |
#2196F3 Blue |
#36618E |
#D1E4FF |
Material Blue |
#03A9F4 Light Blue |
#27638A |
#CAE6FF |
Material Light Blue |
#00BCD4 Cyan |
#006876 |
#A1EFFF |
Material Cyan |
#009688 Teal |
#006A60 |
#9EF2E4 |
Material Teal |
#4CAF50 Green |
#3B6939 |
#BCF0B4 |
Material Green |
#8BC34A Light Green |
#4B662C |
#CCEDA4 |
Material Light Green |
#CDDC39 Lime |
#5C631D |
#E1E994 |
Material Lime |
#FFEB3B Yellow |
#685F12 |
#F1E48A |
Material Yellow |
#FFC107 Amber |
#775A0B |
#FFDF9E |
Material Amber |
#FF9800 Orange |
#855318 |
#FFDCBE |
Material Orange |
#FF5722 Deep Orange |
#8F4C38 |
#FFDBD1 |
Material Deep Orange |
#795548 Brown |
#8F4C33 |
#FFDBCF |
Material Brown |
#9E9E9E Grey |
#006874 |
#9EEFFD |
Material Grey |
#607D8B Blue Grey |
#116682 |
#BDE9FF |
Material Blue Grey |