色彩
A guide to creating color tokens with variables for your design system.
Using colors
Master CSS provides a vibrant and precisely designed P3-compatible color palette that works seamlessly across brands or can be tailored to your unique identity.
Default color palette
The hues of each color in the preset palette range from 0, 5, ..., to 100, and you can choose a color as the main color of your brand or use them directly in the template.
<div class="bg:blue-5 fg:blue-60">…</div>
Adapting default colors
You can adapt the default color palette to your brand's primary color by using the variables
object in your master.css.js
file. For example, inherit from indigo:
import { variables } from '@master/css'export default { variables: { color: { primary: variables.indigo } }}
Apply them using the color-realted syntax:
<div class="bg:primary-5 fg:primary-60">…</div>
See the color variables for more details on how to add custom colors.
With variable modes
You can also use variable modes to define colors for different themes, such as light and dark modes.
<div class="fg:white@dark fg:black@light"><div class="fg:neutral">
As your styles grow, arbitrarily applying @dark
or @light
in template markup can make it difficult to maintain consistency in your design system's color tokens.
Primitive colors
Normal | Active | Text on Color |
---|---|---|
stone | stone-active | Aastone-text |
gray | gray-active | Aagray-text |
grey | grey-active | Aagrey-text |
slate | slate-active | Aaslate-text |
brown | brown-active | Aabrown-text |
orange | orange-active | Aaorange-text |
amber | amber-active | Aaamber-text |
yellow | yellow-active | Aayellow-text |
lime | lime-active | Aalime-text |
green | green-active | Aagreen-text |
beryl | beryl-active | Aaberyl-text |
teal | teal-active | Aateal-text |
cyan | cyan-active | Aacyan-text |
sky | sky-active | Aasky-text |
blue | blue-active | Aablue-text |
indigo | indigo-active | Aaindigo-text |
violet | violet-active | Aaviolet-text |
purple | purple-active | Aapurple-text |
fuchsia | fuchsia-active | Aafuchsia-text |
pink | pink-active | Aapink-text |
crimson | crimson-active | Aacrimson-text |
red | red-active | Aared-text |
Token | Keywords |
---|---|
white | |
black | |
base | background for page, modal |
invert | inverted color of the background |
By default, theme modes drive base color variables meticulously adjusted in light and dark modes.
<div class="light"> <div class="bg:yellow"></div></div><div class="dark"> <div class="bg:yellow"></div></div>
Add a primitive color to the base variables group.
export default { variables: { color: { primary: '#000' } }}
Apply the custom color:
<p class="bg:primary"></p>
Text colors
Token | Descriptions |
---|---|
Aatext-strong | page titles, subheadings, emphasized fields |
Aatext-neutral | body text, descriptions, and general content |
Aatext-light | light color, icons |
Aatext-lighter | lighter color, icons |
Aatext-lightest | dim color, placeholder, disabled text |
Aatext-invert | inverted color of the foreground |
Aatext-stone | earthy, soft contrast, organic tone |
Aatext-gray | neutral, subtle, muted |
Aatext-grey | neutral, subtle, muted |
Aatext-slate | cool, calm, sophisticated |
Aatext-brown | earthy, warm, rustic |
Aatext-orange | vibrant, energetic, lively |
Aatext-amber | warm, glowing, radiant |
Aatext-yellow | cheerful, sunny, bright |
Aatext-lime | fresh, lively, zesty |
Aatext-green | nature, growth, harmony |
Aatext-beryl | calm, soothing, tranquil |
Aatext-teal | sophisticated, elegant, refined |
Aatext-cyan | modern, futuristic, technological |
Aatext-sky | peaceful, serene, tranquil |
Aatext-blue | calm, trustworthy, reliable |
Aatext-indigo | mysterious, deep, spiritual |
Aatext-violet | creative, imaginative, magical |
Aatext-purple | royal, luxurious, majestic |
Aatext-fuchsia | vibrant, bold, playful |
Aatext-pink | feminine, romantic, delicate |
Aatext-crimson | passionate, intense, powerful |
Aatext-red | bold, energetic, attention-grabbing |
By default, theme modes drive text variables are meticulously adjusted in light and dark modes.
<div class="light"> <span class="fg:yellow">M</span></div><div class="dark"> <span class="fg:yellow">M</span></div>
See the color reference for more details on how to add custom text colors.
Line colors
Token | Descriptions |
---|---|
line-neutral | |
line-light | alpha, divider |
line-lighter | alpha, dotted, td |
line-lightest | alpha, layout, navbar, sidebar |
By default, theme modes drive line variables are meticulously adjusted in light and dark modes.
<div class="light"> <div class="b:3x|neutral size:96"></div></div><div class="dark"> <div class="b:3x|neutral size:96"></div></div>
See the border color reference for more details on how to add custom border colors.