How to Add Custom Brand Colors to Tailwind CSS (v3 and v4)

Turn one brand colour into a full Tailwind 50-950 scale, learn why OKLCH gives even steps, and add it with @theme in v4 or tailwind.config.js in v3.

Updated September 29, 2026 6 min read

Use the free Tailwind Color Palette GeneratorTurn one colour into a full Tailwind 50–950 scale built in OKLCH

The brand guidelines give you one colour: a purple hex code on the first page of a PDF. Tailwind, on the other hand, thinks in scales. Its built-in colours each come in eleven steps, from a near-white 50 to a near-black 950, and every component you build uses several of them: bg-brand-600 for a button, hover:bg-brand-700 for its hover state, bg-brand-50 for a highlighted row, text-brand-900 for a heading on that row. With only one hex value, you have nothing to put in those slots.

This guide explains how a Tailwind-style scale is built, why the lightness curve matters more than the exact hex codes, how to generate a scale from a single colour, and how to register it in both Tailwind v4 and v3.

How Tailwind colour scales are organised

Each colour name maps to a set of numbered shades. The numbers are not percentages; they are positions on a scale where 500 sits roughly in the middle, lower numbers are lighter and higher numbers are darker.

Shade Typical use
50-100 Page and card backgrounds, subtle highlights
200-300 Borders, dividers, disabled states
400-500 Icons, accents, decorative fills
600-700 Primary buttons, links, active states
800-950 Text on light backgrounds, dark-mode surfaces

Consistency across colour names is what makes the system work. Blue-600 and green-600 look roughly equally dark, so swapping blue for green in a class name changes the hue without breaking contrast. A custom brand scale should follow the same lightness steps, otherwise brand-600 might be noticeably lighter than gray-600 and your buttons will fail contrast checks where the default colours would pass.

Why OKLCH instead of HSL

The obvious way to make a scale is to take your colour in HSL and change the L value. The trouble is that HSL lightness is not how bright a colour looks. Yellow at 50% HSL lightness looks far brighter than blue at 50%. A scale built by stepping HSL lightness ends up with uneven jumps, and different hues don't line up.

OKLCH is a newer colour space designed to match perception. Its three values are:

  • L: perceived lightness, from 0 (black) to 1 or 100% (white);
  • C: chroma, roughly how colourful it is;
  • H: hue angle in degrees.

Tailwind v4's default palette is defined in OKLCH, and browsers support the oklch() function in CSS. A generator that follows the same OKLCH lightness curve produces a brand scale whose steps line up with Tailwind's own colours. If you want to explore the simpler HSL approach anyway, our guide on making lighter and darker shades with HSL covers it.

One more wrinkle: very saturated colours at extreme lightness can fall outside the sRGB range most screens display. A good generator reduces chroma slightly for those steps, keeping lightness and hue intact, rather than letting the colour clip unpredictably.

Generate the scale from one colour

The Tailwind Color Palette Generator builds all eleven steps in your browser.

  1. Open the Tailwind Color Palette Generator and enter your hex code in Base colour, or click the swatch to pick one. Random gives you a starting point if you are just exploring.
  2. Type a Colour name, such as brand or primary. It becomes part of the class names (bg-brand-600), so keep it short and lowercase.
  3. Leave Base colour sits at on Auto (closest lightness) to start. The tool places your exact colour at the step whose target lightness is closest, marks it with a "base" label and builds the other steps around it.
  4. If your brand colour must be a specific step, for example because designers already call it "brand 600", choose that step from the list instead. The other steps shift to fit.
  5. Optionally move Hue shift toward ends. Small values (a few degrees) make the light and dark ends drift slightly in hue, which can make a scale feel warmer or cooler, similar to how many hand-tuned palettes behave.
  6. Click any swatch to copy its hex. If the note under the swatches says some steps were desaturated to fit the sRGB gamut, that is the gamut adjustment described above.
  7. Choose an export tab: Tailwind v4 (@theme), Tailwind v3 config, CSS variables or JSON, then copy or download the code.

Add the scale to Tailwind v4

Tailwind v4 is configured in CSS. Paste the exported @theme block into your main stylesheet after the import:

@import "tailwindcss";

@theme {
  --color-brand-50: oklch(96.9% 0.016 292.6);
  --color-brand-100: oklch(93.2% 0.035 292.6);
  /* ...200 to 900... */
  --color-brand-950: oklch(27.6% 0.115 292.6);
}

These values come from the base colour #6d28d9, which the tool places at step 700; the middle steps are omitted here, so use the full block from the tool. Every --color-brand-* variable automatically creates utilities such as bg-brand-500, text-brand-900 and border-brand-200, and opacity modifiers like bg-brand-500/20 work as usual. If you want to remove Tailwind's default colours entirely, v4 lets you reset the namespace with --color-*: initial; at the top of the @theme block.

Add the scale to Tailwind v3

Tailwind v3 uses a JavaScript configuration file. The Tailwind v3 config tab outputs something like this:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      colors: {
        brand: {
          50: "#f5f3ff",
          100: "#e9e5ff",
          // ...200 to 900...
          950: "#2c155a",
          DEFAULT: "#6d28d9",
        },
      },
    },
  },
};

Putting it under extend keeps the default colours available alongside yours. The DEFAULT key lets you write bg-brand without a number, which maps to your original brand colour. If you place colors directly under theme instead of extend, you replace the whole default palette.

Other ways to build a scale

  • Use a built-in Tailwind colour. If your brand purple is close to Tailwind's violet, aliasing it is simpler and guaranteed to be well tuned.
  • Hand-tune in a design tool. Designers often adjust each step by eye. That gives the most control but takes time and is hard to repeat for new colours.
  • Mix with white and black. Simple tints and shades are fine for quick prototypes, and a Color Shades Generator does exactly that, but the steps won't match Tailwind's perceptual curve.
  • Convert existing values. If you already have a scale in hex and want OKLCH, a Color Converter handles individual values.

Check contrast before you ship

A good-looking scale can still fail accessibility. Test the pairs you actually use, such as white text on brand-600 and brand-700 text on brand-50, with the Color Contrast Checker. Body text needs a contrast ratio of at least 4.5:1 for WCAG AA; our explainer on WCAG contrast ratios goes into the details. If white text on 600 fails, use 700 for buttons instead.

Frequently asked questions

Which shade should my brand colour be?

Let the lightness decide. Mid-tone colours usually land around 500 or 600, light brand colours around 300 or 400, and dark ones around 700 or above. Forcing a light colour to 600 makes the darker steps crowd together.

Why don't my generated shades match Tailwind's built-in colours exactly?

Your hue and saturation are different, so the hex values differ. What should match is the lightness at each step, which is what keeps brand-600 and gray-600 visually comparable.

Do OKLCH colours work in all browsers?

Current versions of the major browsers support oklch(). If you must support older browsers, use the v3 config or CSS variables export, which are in hex.

Can I have more than one custom colour?

Yes. Generate a scale for each colour with a different name, such as brand and accent, and add each block to your theme.

What does the hue shift option do?

It rotates the hue gradually towards the lightest and darkest steps. Keeping it at 0 gives a pure single-hue scale; small shifts can make light tints look less washed out.

Try it now: Tailwind Color Palette Generator

Loading tool…