Material Design 有預定一組 顏色變數
,只要提供後就可根據系統設定自動切換 Light Mode 與 Dark Mode。
Version
Material Design 3
Color
Roles
Surface
:A role used forbackgrounds
andlarge
,low-emphasis areas
of the screenPrimary, Secondary, Tertiary
:Accent color roles used toemphasize
orde-emphasize
foreground
elementsContainer
:Roles used as afill color
forforeground
elements like buttons. Theyshould not
be used fortext
oricons
On
:Roles starting with this term indicate a color for text or iconson top
of its paired parent color. For example,on Primary
is used for text and icons against theprimary
fill colorVariant
:Roles ending with this term offer alower emphasis
alternative to its non-variant pair. For example,outline variant
is aless emphasized
version of theoutline
color
Primary
Use
primary
roles for themost prominent
components across the UI, such as theFAB
(FloatingActionButton),high-emphasis
buttons, andactive states
* primary
:required
High-emphasis fills, texts, and icons against surface
* onPrimary
:required
Text and icons against primary
* primaryContainer
:Standout fill color against surface, for key components like FAB
* onPrimaryContainer
: Text and icons against primary container
* primaryFixed
* primaryFixedDim
* onPrimaryFixed
* onPrimaryFixedVariant
onPrimary
primary
onPrimaryContainer
primaryContainer
Secondary
Use
secondary
roles forless prominent
components in the UI such asfilter chips
.
* secondary
:required
Less prominent
fills, text, and icons against surface
* onSecondary
:required
Text and icons against secondary
* secondaryContainer
:Less prominent
fill color against surface, for recessive components like tonal buttons
* onSecondaryContainer
:Text and icons against secondary container
* secondaryFixed
* secondaryFixedDim
* onSecondaryFixed
* onSecondaryFixedVariant
primary
onPrimary
secondary
onSecondary
- Icon:
onSecondContainer
- Button:
secondaryContainer
Tertiary
Use
tertiary
roles for contrasting accents thatbalance
primary and secondary colors or bringheightened
attention to an element such as aninput field
* tertiary
:required
Complementary fills, text, and icons against surface
* onTertiary
:Text and icons against tertiary
* tertiaryContainer
:Complementary container color against surface, for components like input fields
* onTertiaryContainer
:Text and icons against tertiary container
* tertiaryFixed
* tertiaryFixedDim
* onTertiaryFixed
* onTertiaryFixedVariant
onTertiaryContainer
tertiaryContainer
Error
Use
error
roles to communicateerror
states, such as anincorrect password
entered intoa text field
.
error
:required
onError
:required
errorContainer
:A color used for error elements needingless emphasis
thanerror
onErrorContainer
Surface
Use
surface
roles for moreneutral backgrounds
, andcontainer colors
for components likecards
,sheets
, anddialogs
.
surface
:required
Default color for backgroundsonSurface
:required
Text and icons against any surface colorsurfaceDim
:surfaceBright
:A color that’s always thelightest
in the dark or light themesurfaceContainerLowest
:A surface container color with thelightest tone
andthe least emphasis
relative to thesurface
surfaceContainerLow
:A surface container color with alighter tone
that createsless emphasis
thansurfaceContainer
butmore emphasis
thansurfaceContainerLowest
surfaceContainer
:A recommended color role for adistinct area
within thesurface
surfaceContainerHigh
:A surface container color with a darker tone. It is used to createmore emphasis
thansurfaceContainer
butless emphasis
thansurfaceContainerHighest
surfaceContainerHighest
:A surface container color with the darkest tone. It is used to create themost emphasis
against thesurface
onSurfaceVariant
:Lower-emphasis color for text and icons against any surface colorsurfaceTint
surface
:background colorsurfaceContainer
:navigation area
surfaceContainerLow
surfaceContainer
surfaceContainerHigh
surfaceContainerHighest
Outline
There are two outline colors to be used against surface:
outline
:Importantboundaries
, such as atext
fieldoutline
outlineVariant
: Decorative elements, such asdividers
shadow
scrim
inverseSurface
onInverseSurface
inversePrimary
outline
outlineVariant
Add-on Colors
Most products
won't
need to use these add-on color roles. However, some products require the greater flexibility and control that add-on roles provide. If you aren’t sure whether your product should use the add-on roles, it probably shouldn’t and you can ignore them.
-Fixed
roles are appropriate to use in places whereContainer
roles are normally used, but they stay thesame color
between light and dark themes-Dim
roles provide astronger
,more emphasized color
with the same fixed behavior-FixedVariant
:also have the same color betweenlight
anddark
themes, but compared with on-Fixed
roles, they provide alower-emphasis
option fortext
andicons
primaryFixed
Light mode 與 dark mode 完全不變
primaryContainer
Light mode 與 dark mode 不太一樣
primaryFixed
primaryFixedDim
Reference
Philipp Lackner:Introduction to Matirial 3 (Color Theming、Typography、Shapes)
Material Design, Color System
Material Design, Color Roles
Material Theme Builder