🎨 uicolors-generator
Generate a Tailwind CSS palette from a single color
Install
pnpm add uicolors-generator chroma-js
pnpm add -D @types/chroma-js
Usage
import { getTailwindColors, getTailwindHsl } from "uicolors-generator";
const palette = getTailwindColors("#ff4f00");
console.log(palette);
const hexPalette = getTailwindColors("#ff4f00", {
asHex: true,
});
console.log(hexPalette);
const paletteWithDefault = getTailwindColors("#ff4f00", {
includeDefault: true,
});
console.log(paletteWithDefault);
const paletteWithBW = getTailwindColors("#ff4f00", {
blackColor: "#27272a",
whiteColor: "#fafafa",
});
console.log(paletteWithBW);
const hsl = getTailwindHsl("#ff4f00");
console.log(hsl);
Tailwind config
You can use the getTailwindColors
function to generate a palette and then use it in your Tailwind config.
import { getTailwindColors } from "uicolors-generator";
export default {
theme: {
extend: {
colors: {
steel: getTailwindColors("#232425", { includeDefault: true }),
badass: getTailwindColors("#bada55", { includeDefault: true }),
},
},
},
};
Then in your code, you can use your palette and shades like so:
export default function HelloWorld() {
return (
<div className="bg-steel-800">
<h1 className="text-badass">Hello World</h1>
<p className="text-badass-300">Your palette at your fingertips.</p>
</div>
);
}