2025-02-01Bruno Fernandes

Tailwind Nearest Colors

TailwindCSS V4 has just been released, and it comes with a host of really cool improvements, including a new, vibrant color palette.

Unfortunately, this means that really useful tools such as the "Nearest Tailwind CSS Colors" web app no longer work very well. Given any arbitrary color, this app finds the closest colors in the TailwindCSS color palette. This tool has saved me a lot of time when I needed to find a color in the Tailwind color palette without messing with the default theme.

I decided to take it upon myself to create tailwind-nearest-colors, a new utility function and CLI that does exactly that, and supports the Tailwind V4 color palette and the OKLCH formats.

It uses the Euclidean distance (implemented using chroma-js) to determine the proximity between colors, in multiple color spaces (LAB by default).

To use it, you can follow the instructions in the GitHub repository README. Give the CLI a shot, it's been really handy for me!

You can also use this live demo app if that's more convenient for you.

I hope you find this useful!