Menu

How to add accent presets and flash-free dark mode in Next.js 16
πŸ“°

How to add accent presets and flash-free dark mode in Next.js 16

DEV Community: tailwindcssΒ·Junaid QureshiΒ·about 9 hours ago
#q9nEgiQj
#devtotailwindcss#devto#dev#accent#dark
Long article (1604 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Class-based dark mode in Next.js often flashes the wrong theme on first load. And if you've tried to let a product pick a brand color β€” indigo today, emerald tomorrow β€” you've probably chased utilities like bg-indigo-600 through a dozen files.

Here's a pattern that keeps all of that in one place, using Next.js 16 (App Router) and Tailwind CSS v4:

Design tokens live in a single CSS file, written in OKLCH

Tailwind reads those tokens through @theme inline , so utilities like bg-primary always follow the active theme

Accent presets are just a data-accent attribute on <html>

An inline script in the root layout applies the stored theme and accent before the first paint

A small React provider lets a toggle and a color picker update both at runtime

The snippets below are from Signal UI Kit, a Next.js 16 starter theme I built. The same structure works in any App Router project.

Keep tokens in one CSS file

Every color, radius, shadow, and motion token lives in styles/theme.css .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.