Material 3 color roles explained
Material 3 components don't use fixed colors. They use color roles: named slots such as primary or surface that are filled in from a color scheme. Change the scheme, or switch to dark mode, and every component updates.
Where the colors come from
A Material 3 scheme starts from one seed color. Google's material-color-utilities library converts it to the HCT color space (hue, chroma, tone) and builds five tonal palettes: primary, secondary, tertiary, neutral and neutral variant. Each role takes a tone from one palette. Light themes use dark tones for primary and light tones for containers; dark themes flip that.
Accent roles
Each accent color comes as a group of four: the color, the color to put on it, a softer container, and the color to put on the container.
| Role | Use it for |
|---|---|
primary / onPrimary | The most important actions: filled buttons, active states, the FAB in some styles. Text and icons on it use onPrimary. |
primaryContainer / onPrimaryContainer | Less prominent emphasis: FABs, selected chips, highlighted cards. |
secondary / secondaryContainer | Supporting elements: filter chips, tonal buttons, the selected item in a navigation bar. |
tertiary / tertiaryContainer | Contrasting accents that balance primary and secondary, such as badges or an input field you want to stand out. |
error / errorContainer | Errors and destructive actions. |
Surface roles
| Role | Use it for |
|---|---|
surface / onSurface | The default background and the main text on it. |
onSurfaceVariant | Secondary text and icons, such as subtitles and inactive icons. |
surfaceContainerLowest … surfaceContainerHighest | Five levels for layered areas: cards, navigation bars, sheets and dialogs. Higher containers sit "closer" to the user. They replace the tinted elevation overlays of earlier Material 3 versions. |
surfaceDim / surfaceBright | The darkest and brightest surface, for areas that should stay dim or bright in both themes. |
inverseSurface / inverseOnSurface / inversePrimary | Elements that contrast with the rest of the screen, such as snackbars. |
Outline and other roles
| Role | Use it for |
|---|---|
outline | Borders that must be visible: text fields, outlined buttons. |
outlineVariant | Decorative borders and dividers. |
scrim / shadow | The dimmed layer behind modals, and shadows. |
primaryFixed, secondaryFixed, tertiaryFixed (and Dim) | Colors that stay the same in light and dark themes. |
Rules of thumb
- Always pair a role with its
onrole. They are tuned to meet contrast together. - Use primary sparingly, for the one or two things you want people to press.
- Don't hard-code hex values in components. Reference the role, so dark mode, dynamic color and high contrast work.
- Check contrast for any custom pairing with a contrast checker.