Theming
A single seed colour generates the full Material Design 3 token set for both light and dark modes.
How colour generation works
Under the hood, createMD3Theme uses Google's @material/material-color-utilities to derive tonal palettes from the HCT colour space. Each palette produces tokens at specific tone levels defined by the MD3 spec—e.g. primary is tone 40 in light mode and tone 80 in dark mode.
import { createMD3Theme } from "md3-next";
// One seed → full MD3 palette
const theme = createMD3Theme({ seed: "#006A6A" });
// Access raw tokens
theme.tokens.light.primary; // hex string
theme.tokens.dark.primaryContainer; // hex stringChoosing a seed colour
Your seed colour is your brand colour. The algorithm extracts its hue and chroma, then builds harmonious secondary and tertiary palettes automatically. A few examples:
Light, dark & system modes
Pass mode to createMD3Theme to set the initial preference. The MD3Provider resolves "system" at runtime using prefers-color-scheme. Users can switch at any time via setMode or toggleMode.
const { mode, setMode, toggleMode } = useMD3();
// mode is the resolved value: "light" | "dark"
// setMode("dark") — explicit
// setMode("system") — follow OS
// toggleMode() — flip light ↔ darkFull token reference(showing light mode)
Primary
| Token | Description | Value | |
|---|---|---|---|
primary | Primary brand colour | #6750a4 | |
onPrimary | Text/icon on primary | #ffffff | |
primaryContainer | Lighter primary for containers | #e9ddff | |
onPrimaryContainer | Text on primary container | #22005d | |
inversePrimary | Primary for inverse surfaces | #cfbcff |
Secondary
| Token | Description | Value | |
|---|---|---|---|
secondary | Secondary colour | #625b71 | |
onSecondary | Text/icon on secondary | #ffffff | |
secondaryContainer | Secondary container | #e8def8 | |
onSecondaryContainer | Text on secondary container | #1e192b |
Tertiary
| Token | Description | Value | |
|---|---|---|---|
tertiary | Tertiary accent | #7e5260 | |
onTertiary | Text/icon on tertiary | #ffffff | |
tertiaryContainer | Tertiary container | #ffd9e3 | |
onTertiaryContainer | Text on tertiary container | #31101d |
Error
| Token | Description | Value | |
|---|---|---|---|
error | Error colour | #ba1a1a | |
onError | Text/icon on error | #ffffff | |
errorContainer | Error container | #ffdad6 | |
onErrorContainer | Text on error container | #410002 |
Surface
| Token | Description | Value | |
|---|---|---|---|
surface | Default surface | #fdf8fd | |
onSurface | Primary text on surface | #1c1b1e | |
surfaceVariant | Variant surface | #e7e0eb | |
onSurfaceVariant | Secondary text | #49454e | |
surfaceDim | Dimmed surface | #ddd8dd | |
surfaceBright | Bright surface | #fdf8fd | |
surfaceContainerLowest | Lowest container | #ffffff | |
surfaceContainerLow | Low container | #f7f2f7 | |
surfaceContainer | Default container | #f2ecf1 | |
surfaceContainerHigh | High container | #ece7eb | |
surfaceContainerHighest | Highest container | #e6e1e6 |
Other
| Token | Description | Value | |
|---|---|---|---|
outline | Borders and dividers | #7a757f | |
outlineVariant | Subtle borders | #cac4cf | |
inverseSurface | Snackbar/tooltip bg | #313033 | |
inverseOnSurface | Text on inverse surface | #f4eff4 | |
shadow | Shadow colour | #000000 | |
scrim | Scrim overlay | #000000 |
Typography scale
The MD3 type scale is mapped to MUI typography variants automatically:
| MUI variant | MD3 role |
|---|---|
h1 | Display Large |
h2 | Display Medium |
h3 | Display Small |
h4 | Headline Large |
h5 | Headline Medium |
h6 | Headline Small |
subtitle1 | Title Large |
subtitle2 | Title Medium |
body1 | Body Large |
body2 | Body Medium |
button | Label Large |
caption | Body Small |
overline | Label Small |
Want this pre-built?
Our templates come pre-configured with MD3Provider, theming, and fully styled layouts. Save hours of setup time.
View 6 Templates — from $29