Sub topic 1
The default palette and shade scale
Tailwind ships with a built-in palette of 22 named color families, each with a numbered scale of shades. Every color utility in this tutorial draws from it, so this chapter covers how the palette is organized, how its class names are built, and the mistakes that cause a color class to do nothing.
Prerequisites
This chapter assumes you have:
- Basic HTML and CSS, including the box model.
- A working idea of what a utility class is in Tailwind CSS.
- A Tailwind CSS project or an online playground to try the examples in.
- Some familiarity with hex and RGB color notation.
The chapter notes where Tailwind v3 and v4 differ. Everything else applies to both.
How a color class is built
Every color utility follows one pattern: a property prefix, a color name, and a shade number.
The prefix chooses which CSS property receives the color. The same family and shade work with many prefixes:
| Prefix | CSS property it sets |
|---|---|
| `text-` | `color` |
| `bg-` | `background-color` |
| `border-` | `border-color` |
| `divide-` | border color between siblings |
| `ring-` and `outline-` | focus ring and outline color |
| `shadow-` | box shadow color |
| `fill-` and `stroke-` | SVG paint |
| `accent-`, `caret-`, `decoration-` | form accents, text cursor, underline color |
Once you know bg-indigo-600, you also know border-indigo-600, ring-indigo-600, and text-indigo-600. The later chapters on borders, rings, and shadows reuse this same naming.
The color families
The default palette has two kinds of families.
- Grays. There are five of them:
slate,gray,zinc,neutral, andstone. They differ in undertone. Slate leans blue, gray leans slightly blue, zinc is nearly neutral with a cool tint, neutral has no tint, and stone leans warm. - Hues. There are seventeen:
red,orange,amber,yellow,lime,green,emerald,teal,cyan,sky,blue,indigo,violet,purple,fuchsia,pink, androse.
Four single-value colors have no shade number: black, white, transparent, and current. The current value maps to currentColor, so border-current uses the element's text color. The classes are bg-white, text-black, border-transparent, and border-current.
Pick one gray family for a whole project and use it consistently. Mixing slate and stone in the same interface produces borders and backgrounds that look slightly off against each other, even though the difference is hard to name.
The shade scale
Each family has eleven shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, and 950. Lower numbers are lighter and higher numbers are darker. The number is only a label, so bg-blue-500 is not "half" of bg-blue-1000. The scale has no 1000, and 950 is the darkest step.
Treat the scale as a set of roles:
| Shades | Typical use |
|---|---|
| 50 to 100 | Page and panel backgrounds, subtle highlights |
| 200 to 300 | Borders, dividers, disabled fills |
| 400 to 500 | Icons, accents, hover targets, placeholder text |
| 600 to 700 | Solid buttons, links, body text on light backgrounds |
| 800 to 950 | Headings, dark-mode surfaces, strong text |
Here is a button that applies those roles, using a solid 600 fill that gets lighter on hover:
<button class="rounded-md bg-indigo-600 px-4 py-2 text-white hover:bg-indigo-500">
Save changes
</button>The hover: prefix is a variant. It applies the utility only while the pointer is over the element. Hover and focus variants get their own chapter, but you can already read this class: on hover, bg-indigo-500 replaces bg-indigo-600. Moving to a lower number gives a lighter shade, which is a common hover pattern on dark fills. On light fills, designers often go the other way and pick a darker shade.
What the values actually are
In v3, each shade is a fixed hex value. For example, indigo-500 is #6366f1 and indigo-600 is #4f46e5. In v4, the same names are defined as theme variables using the OKLCH color space, such as --color-indigo-500. Every shade also becomes a CSS custom property you can use in your own CSS:
/* Tailwind CSS v4: theme colors are exposed as CSS variables */
@import "tailwindcss";
.callout {
border-left: 4px solid var(--color-indigo-600);
background-color: var(--color-indigo-50);
}You rarely need this inside markup, but it is useful for third-party widgets and hand-written CSS that should stay in sync with your utilities.
Choosing and reusing shades
A consistent approach keeps interfaces coherent.
- Choose one gray family for text, borders, and surfaces.
- Choose one hue as the primary action color.
- Use the same shade for the same role everywhere. For example, always use
border-slate-200for card borders andtext-slate-600for secondary text. - Use the 50 shade for tinted backgrounds and 600 or 700 for the matching text, such as
bg-emerald-50 text-emerald-700for a success message.
Contrast depends on the pairing, not on the shade alone. White text on a 600 fill is a safe default for most hues. White on a 400 fill often fails the WCAG minimum of 4.5:1 for normal text. Light hues such as yellow and lime need dark text (text-yellow-950) even on 400 or 500 fills. The accessibility chapter covers checking this properly.
Common errors
Most color problems at this stage come from five mistakes.
1. Leaving off the shade. bg-blue is not a class in the default palette, because a family is not itself a color. Write bg-blue-500. In v3, a family-less color exists only if you define it with a single value in your config.
2. Using a shade that does not exist. Classes such as bg-blue-550 or text-gray-1000 generate nothing. If a color is simply missing, check the number against the eleven valid shades.
3. Building class names dynamically. Tailwind finds classes by scanning your source files for complete strings. It cannot evaluate template strings:
// Broken: "bg-red-500" never appears as a complete string
const classes = `bg-${color}-500`;Write the full class names and look them up instead:
// Works: every class is a complete literal string the scanner can find
const badgeColors = {
danger: "bg-red-100 text-red-800",
success: "bg-emerald-100 text-emerald-800",
info: "bg-sky-100 text-sky-800",
};
function badgeClass(kind) {
return badgeColors[kind] ?? badgeColors.info;
}
console.log(badgeClass("danger"));4. Using retired names. In v2 and earlier, some families had different names. Tailwind v3 renamed lightBlue to sky, warmGray to stone, trueGray to neutral, and coolGray to gray. Old tutorials may use the old names, which no longer work.
5. Replacing the palette by accident. In a v3 config, putting colors directly under theme replaces the whole default palette. Putting it under theme.extend adds to it. If every default color suddenly stops working after a config change, this is the usual cause.
// tailwind.config.js (Tailwind CSS v3)
const colors = require("tailwindcss/colors");
module.exports = {
theme: {
extend: {
colors: {
// Alias: "gray-*" now resolves to the slate scale
gray: colors.slate,
},
},
},
};This alias is a handy trick. You can switch the whole project's gray family in one line without editing any markup.
Practice
Exercise
A teammate writes <div class="bg-green text-white"> and the background does not appear. They also build a badge with ` bg-${status}-100 ` and some badges are unstyled. Explain both problems and give corrected code for each.
Show answer
The first problem is the missing shade. green is a family, not a color, so bg-green generates no CSS. Use bg-green-600 (white text is readable on it). The second problem is that bg-${status}-100 never appears as a complete string in the source, so Tailwind's scanner does not generate those classes. Replace it with a lookup object whose values are full literals, such as { ok: "bg-green-100", error: "bg-red-100" }, and read from it with statusClasses[status].
Exercise
You want a warning message with a pale amber background, a slightly darker amber border, and dark amber text. Write the classes, and say which shade role each one plays.
Show answer
bg-amber-50 border border-amber-200 text-amber-900. The 50 shade is the tinted background, the 200 shade is the border (the 200 to 300 range is for borders), and the 900 shade is strong, readable text on the pale fill. The border class sets the width, and border-amber-200 sets the color.