compacto-ui

Search documentation

Jump to a page or a component.

Theming

Twenty-three complete palettes across twelve hues. Pick one and every primitive below follows — this page is itself the reference implementation.

Palettes

Midnight
Ocean
Chocolate
Amethyst
Nature
Rose
Amber
Slate
Sunset
Coffee
Cyberpunk
Retro

Applying a palette

Write the palette's variables onto the root element. That is the whole mechanism — there is no provider to mount and no context to thread.

import { appThemeCssVars, COLOR_THEMES } from "@/lib/color-themes";

const theme = COLOR_THEMES.midnight;

for (const [name, value] of Object.entries(appThemeCssVars(theme))) {
  document.documentElement.style.setProperty(name, value);
}
document.documentElement.classList.toggle("dark", !theme.isLight);

Why there is no dark: variant

  • A palette here is complete — background, three surface elevations, one accent, text — not a light/dark pair layered over a fixed accent. light is simply the palette whose isLight flag is true.
  • So --app-* already resolves to the right value for whichever palette is active. A dark: clause would be a second, parallel answer to a question the palette has already answered, and the two would drift.
  • The .dark class still goes on the root element, but only so third-party CSS (Monaco, KaTeX, shiki) and the pre-hydration defaults in tokens.css can key off it.
  • A CI gate greps the library for dark: and fails the build on a hit.