hexcolors

Learn / Tutorials

How to generate a Tailwind color scale from one hex code

Turn a single brand color into a full 50 to 950 scale and use it in Tailwind v4.

November 20, 20261 min readBy the hexcolors team

Key takeaways

  • A 500 step plus lighter and darker steps covers most UI needs.
  • Paste the generated block into @theme in Tailwind v4.
  • Always test contrast for text on mid-tones.

Tailwind projects work best with a full scale of each brand color. You can get one from a single hex code in a minute.

Step 1: Pick your base color

This will become the 500 step. Choose the color you use most for buttons and links.

Step 2: Generate the scale

Open the shade scale generator, enter your hex code, name the color (for example brand) and choose the Tailwind v4 format.

Step 3: Paste it into your CSS

Add the generated block to your main stylesheet.

@import "tailwindcss";

@theme {
  --color-brand-50: #eef3ff;
  --color-brand-500: #3b6cff;
  --color-brand-950: #0a1a4d;
  /* ...the other steps */
}

Step 4: Use the classes

Tailwind now generates utilities for every step.

<button class="bg-brand-500 hover:bg-brand-600 text-white">
  Get started
</button>

Step 5: Check contrast

Mid-tones like 400 to 600 often fail with white text. Test your button colors before you ship them.

Wrap up

On Tailwind v3, the same values go under theme.extend.colors in tailwind.config.js.

The hexcolors teamWe build free color tools and write practical guides. Follow us on X, Instagram and LinkedIn.