Theming
Scoped light and dark themes plus runtime oklch brand accent overrides.
Every coatx component reads semantic oklch tokens from coatx/tokens.stylex. Hover states, focus rings, and subtle fills derive from those variables via color-mix(in oklab, ...), so overriding primary and ring updates interactive states automatically.
Workspace Preferences
Styled with coatx recipes over @ilha/ui-sdk headless primitives.
Scoped light & dark themes
Call theme(mode, overrides?) and spread the returned { class, style } onto any container. You can even nest a dark card inside a light page (or vice versa):
import { theme } from "coatx/themes.stylex";
export function BrandPanel() {
return (
<section
{...theme("dark", {
colors: {
primary: "oklch(0.62 0.21 255)",
primaryForeground: "oklch(0.985 0 0)",
ring: "oklch(0.62 0.21 255)",
},
})}
>
{/* Every coatx recipe inside inherits this scoped theme */}
</section>
);
}
Override groups
theme(mode, overrides?, extra?) accepts grouped overrides — one group per token family:
theme("dark", {
colors: { primary: "oklch(0.62 0.21 255)" }, // semantic palette + chart1–chart5
radii: { lg: "0.75rem" }, // xs, sm, md, lg, xl, full
radius: "0.625rem", // shadcn-style base: derives xs–xl unless radii is explicit
fonts: { sans: "Inter, sans-serif" }, // sans, mono
shadows: { md: "0 4px 12px rgb(0 0 0 / 0.15)" }, // xs, sm, md, lg
motion: { easeOut: "cubic-bezier(0.22, 1, 0.36, 1)" }, // easeOut, easeInOut, easeDrawer
});
radius mirrors shadcn’s --radius: lg equals the value, and xs / sm / md / xl derive from it (calc(r - 6px), calc(r - 4px), calc(r - 2px), calc(r + 4px)). Explicit radii entries win over the derived values.
The optional third argument merges extra class / style into the returned attributes, exactly like recipe options:
theme("dark", { colors: { primary: "brand" } }, { class: "my-panel" });
Token overrides helper
If you only want the inline CSS custom-property string without switching light/dark mode, call tokenOverrides(overrides) (or tokenOverrideVars(overrides) for the plain object):
import { tokenOverrides } from "coatx/themes.stylex";
const style = tokenOverrides({
colors: {
primary: "oklch(0.55 0.22 258)",
ring: "oklch(0.62 0.2 258)",
},
});
Available token groups
| Export | Tokens |
|---|---|
colors |
background, foreground, card, cardForeground, popover, popoverForeground, primary, primaryForeground, secondary, secondaryForeground, muted, mutedForeground, accent, accentForeground, destructive, destructiveForeground, border, input, inputBackground, ring, chart1, chart2, chart3, chart4, chart5 |
radii |
xs, sm, md, lg, xl, full |
fonts |
sans, mono |
shadows |
xs, sm, md, lg |
motion |
easeOut, easeInOut, easeDrawer |