Re-theme an entire landing page with one class in Tailwind CSS v4
When I built Orbitra, a kit of 7 landing pages, I wanted each page to have its own brand color (violet for an AI startup, emerald for fintech, rose for a mobile appβ¦) without duplicating a single component. Tailwind CSS
When I built Orbitra, a kit of 7 landing pages, I wanted each page to have its own brand color (violet for an AI startup, emerald for fintech, rose for a mobile appβ¦) without duplicating a single component. Tailwind CSS v4 makes this surprisingly clean.
π Live demo
The idea: utilities that point at CSS variables
Instead of writing bg-indigo-600 everywhere, every component uses an accent scale: bg-accent-600, text-accent-500, ring-accent-200β¦ In v4, @theme inline lets those utilities read a CSS variable directly:
@theme inline {
--color-accent-50: var(--accent-50);
--color-accent-500: var(--accent-500);
--color-accent-600: var(--accent-600);
/* β¦every step from 50 to 950 */
}
The inline keyword is important: Tailwind writes var(--accent-600) into the generated utility instead of resolving it at build time, so the value can change at runtime.
Themes are just variable sets
@layer base {
:root, .theme-indigo {
--accent-500: var(--color-indigo-500);
--accent-600: var(--color-indigo-600);
}
.theme-emerald {
--accent-500: var(--color-emerald-500);
--accent-600: var(--color-emerald-600);
}
}
Now <body class="theme-emerald"> re-colors buttons, badges, icons, focus rings and gradients across the whole page, with no rebuild and no JavaScript. Orbitra ships six themes this way, and adding your exact brand color is just a few hex values in :root.
You can even use the variables outside Tailwind, for example accent-color on native range inputs:
<input type="range" class="accent-[var(--accent-600)]">
Scroll reveals that respect reduced motion
Every section fades in as you scroll, but only if JavaScript runs and the visitor hasn't asked for less motion:
@media (prefers-reduced-motion: no-preference) {
.js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .7s, transform .7s; }
.js [data-reveal].revealed { opacity: 1; transform: none; }
}
The .js class is added by the script itself, so if JavaScript fails, content is simply visible. An IntersectionObserver adds .revealed when a section enters the viewport.
Mockups without images
The phones, credit cards and dashboards in the hero sections are plain HTML and CSS: rounded borders for the phone frame, gradients for the card, flex boxes for chart bars. They scale perfectly, adapt to the theme color automatically, and there's nothing to license.
Sections you can move anywhere
Every block is wrapped in a comment like <!-- SECTION: Pricing with monthly/yearly switch -->. Because all sections share the same components and the same accent scale, a pricing table from the SaaS page drops into the agency page and immediately matches its colors.
Wrapping up
CSS variables plus @theme inline turn Tailwind into a real theming system with very little code. If you want to see it in action, switch between the demos: same components, six different personalities.
Live demo Β· Full kit on Codester
How do you handle multiple brand colors in your Tailwind projects?
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.