Tailwind CSS v4 colors from your brand color
A logo gives you one color. A button needs a hover color, and a banner needs a much lighter version of the same brand. Turn #0f766e into a Tailwind CSS v4 ramp so you can use bg-brand-500 for a button, hover:bg-brand-600 for hover, and bg-brand-50 for a pale surface.
In Tailwind CSS v4, custom colors are CSS variables in an @theme block. A variable named --color-brand-500 gives you bg-brand-500, text-brand-500 and the other color utilities (Tailwind CSS theme variables).
@theme {
--color-brand-500: #0f766e;
}
That's one shade. Colore generates all eleven from the same color, and the palette generator shows you the scale before you write any code.
npm install colore-js
yarn add colore-js
Build a 50–950 ramp
palette gives you the 11 shades in order from light to dark. It puts the brand at the step closest to its lightness. This teal lands at 500. A lighter brand can land earlier, so check the returned scale before naming a default shade.
import { palette } from 'colore-js/fn';
const shades = palette('#0f766e');
console.log(shades[0], shades[5], shades[6]);
// #d8fff9 #0f766e #0c6962
Check the button and hover colors
The shade number tells you where a color sits in the ramp. Measure the actual text and background with contrastRatio. White text on brand 500 or 600 clears the WCAG AA target of 4.5:1 for normal text. White on brand 400 falls below it. WCAG text contrast
import { contrastRatio, palette } from 'colore-js/fn';
const shades = palette('#0f766e');
for (const [step, index] of [[400, 4], [500, 5], [600, 6]]) {
console.log(step, contrastRatio('#ffffff', shades[index]).toFixed(2));
}
400 2.76
500 5.47
600 6.54
Generate the Tailwind stylesheet
Save this as generate-brand-colors.mjs. It pairs the ramp with Tailwind's shade numbers and prints the complete @theme block for your CSS build.
import { palette } from 'colore-js/fn';
const steps = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
const colors = palette('#0f766e');
const declarations = steps.map((step, index) => ` --color-brand-${step}: ${colors[index]};`);
console.log(['@theme {', ...declarations, '}'].join('\n'));
node generate-brand-colors.mjs > brand.css
@theme {
--color-brand-50: #d8fff9;
--color-brand-100: #a3fbf1;
--color-brand-200: #8fe7dd;
--color-brand-300: #72cac0;
--color-brand-400: #52aaa0;
--color-brand-500: #0f766e;
--color-brand-600: #0c6962;
--color-brand-700: #064a45;
--color-brand-800: #022d2a;
--color-brand-900: #011d1b;
--color-brand-950: #000a09;
}
Import brand.css after Tailwind in your main stylesheet. @theme goes at the top level. A token named --color-brand-500 becomes available to color utilities such as bg-brand-500, text-brand-500, and border-brand-500. Tailwind CSS theme variables
@import 'tailwindcss';
@import './brand.css';
Use the complete class names in your component so Tailwind can find them at build time. Tailwind source detection
<button class="bg-brand-500 text-white hover:bg-brand-600" type="button">
Save changes
</button>
Run the generator again when the brand changes, then review the CSS alongside the contrast checks. If you reuse a pale shade for a banner, check its copy against that shade. The button's passing ratio only covers white text on the two button backgrounds. For a single brand shared across the app, the generated CSS is all the browser needs.
Once a page needs named roles like primary, surface and on-primary, the .toTailwindCss() exporter can generate those tokens and their dark-mode overrides. The ramp above can stay in its own file if you want to keep the brand utilities alongside them.
What Colore checks for you
The generated ramp shades fit sRGB. The original seed stays at its assigned step, including when it is a wide-gamut color. Contrast depends on where you use each shade, so the button check measures both backgrounds against the text that sits on them.