Designers hand you a brand hex like #3B82F6-ish, and your Tailwind config has 11 shades per color. Which one is "closest"? Eyeballing it leads to inconsistent UIs.

Why simple RGB distance misleads

Euclidean distance in RGB treats all channels equally, but human vision doesn't. Two colors can be numerically close and look different (especially in greens). A better approach is to compare in a perceptual space such as CIELAB (deltaE).

A quick recipe

  1. Convert your hex to sRGB, then to linear RGB, then to Lab.
  2. Do the same for every Tailwind shade (50-950 across all families).
  3. Pick the smallest deltaE.
  4. If deltaE is under ~2, it's visually the same; between 2 and 10 it's a close match; above that, consider extending your config with a custom shade.

Don't forget contrast

Nearest shade is only half the story. Check the text/background pair against WCAG 4.5:1 for body text. A shade that matches the brand but fails contrast needs a darker neighbor for text.

Try it without writing code

I built a free, client-side tool that does the matching in your browser (nothing uploaded): Colors to Tailwind. Pair it with the contrast checker to validate accessibility.

*Disclosure: I'm the author of WebDevToolbox.*tailwindcss,css,webdev,design,