Skip to documentation
Design system / Sources & standards
Current repository source
tenantThemes.ts
src/theming/tenantThemes.ts
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
import type { CSSProperties } from "react";
export const tenantThemeIds = ["default", "ocean", "orchid", "ember", "ruby", "amber", "forest"] as const;
export const tenantDarkThemeIds = ["default-dark", "ocean-dark", "orchid-dark", "ember-dark", "ruby-dark", "amber-dark", "forest-dark"] as const;
export type TenantThemeId = (typeof tenantThemeIds)[number];
export type TenantDarkThemeId = (typeof tenantDarkThemeIds)[number];
export type TenantDarkThemeSelectionId = TenantDarkThemeId | "custom-dark";
export type ColorMode = "light" | "dark";
export type TenantThemeSelectionId = TenantThemeId | "custom";
export type TenantThemeSelections = { lightThemeId: TenantThemeSelectionId; darkThemeId: TenantDarkThemeSelectionId };
type TenantThemeTokens = Record<`--${string}`, string>;
export type TenantTheme = {
id: TenantThemeId | TenantDarkThemeId;
mode: ColorMode;
name: string;
description: string;
tokens: TenantThemeTokens;
};
const sharedTokens = {
// Redeclare aliases in each theme scope: inherited aliases resolve at their
// declaration site and otherwise retain the root palette's colors.
"--navigation-hover": "var(--muted)",
"--navigation-selected": "var(--primary)",
"--text-navigation": "var(--text-muted)",
"--text-navigation-hover": "var(--text-default)",
"--text-navigation-selected": "var(--primary-foreground)",
"--destructive": "oklch(0.577 0.245 27.325)",
"--destructive-foreground": "oklch(0.985 0 0)",
"--danger": "oklch(0.577 0.245 27.325)",
"--danger-foreground": "oklch(0.985 0 0)",
"--border-error": "oklch(0.704 0.191 22.216)",
"--success": "oklch(0.527 0.154 150.069)",
"--success-foreground": "oklch(0.985 0 0)",
"--success-muted": "oklch(0.962 0.044 156.743)",
"--success-muted-foreground": "oklch(0.393 0.095 152.535)",
"--warning": "oklch(0.666 0.179 58.318)",
"--warning-foreground": "oklch(0.205 0 0)",
"--warning-muted": "oklch(0.987 0.022 95.277)",
"--warning-muted-foreground": "oklch(0.473 0.124 46.2)",
} satisfies TenantThemeTokens;
export const tenantThemes: Record<TenantThemeId, TenantTheme> = {
default: {
id: "default",
mode: "light",
name: "Slate",
description: "The neutral CreativeXHub console palette.",
tokens: {
"--background": "oklch(1 0 0)",
"--foreground": "oklch(0.145 0 0)",
"--card": "oklch(1 0 0)",
"--card-foreground": "oklch(0.145 0 0)",
"--popover": "oklch(1 0 0)",
"--popover-foreground": "oklch(0.145 0 0)",
"--primary": "oklch(0.205 0 0)",
"--primary-foreground": "oklch(0.985 0 0)",
"--secondary": "oklch(0.97 0 0)",
"--secondary-foreground": "oklch(0.205 0 0)",
"--muted": "oklch(0.97 0 0)",
"--muted-foreground": "oklch(0.556 0 0)",
"--accent": "oklch(0.97 0 0)",
"--accent-foreground": "oklch(0.205 0 0)",
"--border": "oklch(0.922 0 0)",
"--input": "oklch(0.922 0 0)",
"--ring": "oklch(0.556 0 0)",
"--surface-default": "oklch(1 0 0)",
"--surface-raised": "oklch(0.985 0 0)",
"--surface-overlay": "oklch(1 0 0)",
"--surface-sunken": "oklch(0.97 0 0)",
"--text-default": "oklch(0.145 0 0)",
"--text-muted": "var(--cxh-color-neutral-600)",
"--text-placeholder": "oklch(0.708 0 0)",
"--text-link": "oklch(0.488 0.243 264.376)",
"--text-inverse": "oklch(0.985 0 0)",
"--border-default": "oklch(0.922 0 0)",
"--border-subtle": "oklch(0.97 0 0)",
"--border-focus": "oklch(0.623 0.214 259.815)",
"--focus-ring": "oklch(0.556 0 0)",
"--focus-ring-offset": "oklch(1 0 0)",
"--selected": "oklch(0.93 0.034 259.815)",
"--selected-foreground": "oklch(0.379 0.146 265.522)",
"--disabled": "oklch(0.97 0 0)",
"--disabled-foreground": "oklch(0.708 0 0)",
"--info": "oklch(0.623 0.214 259.815)",
"--info-foreground": "oklch(0.985 0 0)",
"--info-muted": "oklch(0.93 0.034 259.815)",
"--info-muted-foreground": "oklch(0.379 0.146 265.522)",
"--info-border": "oklch(0.707 0.165 254.624)",
"--chart-1": "oklch(0.623 0.214 259.815)",
"--chart-2": "oklch(0.527 0.154 150.069)",
"--chart-3": "oklch(0.666 0.179 58.318)",
"--chart-4": "oklch(0.577 0.245 27.325)",
"--chart-5": "oklch(0.546 0.245 262.881)",
"--sidebar": "oklch(0.985 0 0)",
"--sidebar-foreground": "oklch(0.145 0 0)",
"--sidebar-primary": "oklch(0.205 0 0)",
"--sidebar-primary-foreground": "oklch(0.985 0 0)",
"--sidebar-accent": "oklch(0.97 0 0)",
"--sidebar-accent-foreground": "oklch(0.205 0 0)",
"--sidebar-border": "oklch(0.922 0 0)",
"--sidebar-ring": "oklch(0.556 0 0)",
...sharedTokens,
},
},
ocean: {
id: "ocean",
mode: "light",
name: "Ocean",
description: "A high-contrast blue palette with cool supporting surfaces.",
tokens: {
"--background": "oklch(0.985 0.006 240)", "--foreground": "oklch(0.22 0.04 250)", "--card": "oklch(1 0 0)", "--card-foreground": "oklch(0.22 0.04 250)", "--popover": "oklch(1 0 0)", "--popover-foreground": "oklch(0.22 0.04 250)", "--primary": "oklch(0.42 0.16 250)", "--primary-foreground": "oklch(0.99 0.005 240)", "--secondary": "oklch(0.94 0.025 240)", "--secondary-foreground": "oklch(0.28 0.08 250)", "--muted": "oklch(0.94 0.025 240)", "--muted-foreground": "oklch(0.48 0.04 250)", "--accent": "oklch(0.91 0.045 220)", "--accent-foreground": "oklch(0.26 0.08 250)", "--border": "oklch(0.84 0.035 240)", "--input": "oklch(0.84 0.035 240)", "--ring": "oklch(0.56 0.16 245)", "--surface-default": "oklch(0.985 0.006 240)", "--surface-raised": "oklch(0.97 0.012 240)", "--surface-overlay": "oklch(1 0 0)", "--surface-sunken": "oklch(0.94 0.025 240)", "--text-default": "oklch(0.22 0.04 250)", "--text-muted": "oklch(0.48 0.04 250)", "--text-placeholder": "oklch(0.64 0.03 245)", "--text-link": "oklch(0.42 0.16 250)", "--text-inverse": "oklch(0.99 0.005 240)", "--border-default": "oklch(0.84 0.035 240)", "--border-subtle": "oklch(0.91 0.02 240)", "--border-focus": "oklch(0.56 0.16 245)", "--focus-ring": "oklch(0.56 0.16 245)", "--focus-ring-offset": "oklch(0.985 0.006 240)", "--selected": "oklch(0.89 0.055 230)", "--selected-foreground": "oklch(0.3 0.1 250)", "--disabled": "oklch(0.94 0.025 240)", "--disabled-foreground": "oklch(0.64 0.03 245)", "--info": "oklch(0.42 0.16 250)", "--info-foreground": "oklch(0.99 0.005 240)", "--info-muted": "oklch(0.89 0.055 230)", "--info-muted-foreground": "oklch(0.3 0.1 250)", "--info-border": "oklch(0.67 0.12 240)", "--chart-1": "oklch(0.42 0.16 250)", "--chart-2": "oklch(0.52 0.12 190)", "--chart-3": "oklch(0.62 0.14 215)", "--chart-4": "oklch(0.58 0.16 280)", "--chart-5": "oklch(0.7 0.13 170)", "--sidebar": "oklch(0.95 0.02 240)", "--sidebar-foreground": "oklch(0.22 0.04 250)", "--sidebar-primary": "oklch(0.42 0.16 250)", "--sidebar-primary-foreground": "oklch(0.99 0.005 240)", "--sidebar-accent": "oklch(0.89 0.055 230)", "--sidebar-accent-foreground": "oklch(0.3 0.1 250)", "--sidebar-border": "oklch(0.84 0.035 240)", "--sidebar-ring": "oklch(0.56 0.16 245)", ...sharedTokens,
},
},
orchid: {
id: "orchid",
mode: "light",
name: "Orchid",
description: "A high-contrast violet palette with warm, restrained accents.",
tokens: {
"--background": "oklch(0.99 0.008 320)", "--foreground": "oklch(0.23 0.05 310)", "--card": "oklch(1 0 0)", "--card-foreground": "oklch(0.23 0.05 310)", "--popover": "oklch(1 0 0)", "--popover-foreground": "oklch(0.23 0.05 310)", "--primary": "oklch(0.42 0.17 310)", "--primary-foreground": "oklch(0.99 0.008 320)", "--secondary": "oklch(0.95 0.025 320)", "--secondary-foreground": "oklch(0.29 0.09 310)", "--muted": "oklch(0.95 0.025 320)", "--muted-foreground": "oklch(0.49 0.045 310)", "--accent": "oklch(0.92 0.055 340)", "--accent-foreground": "oklch(0.29 0.09 310)", "--border": "oklch(0.85 0.035 320)", "--input": "oklch(0.85 0.035 320)", "--ring": "oklch(0.57 0.16 310)", "--surface-default": "oklch(0.99 0.008 320)", "--surface-raised": "oklch(0.975 0.014 320)", "--surface-overlay": "oklch(1 0 0)", "--surface-sunken": "oklch(0.95 0.025 320)", "--text-default": "oklch(0.23 0.05 310)", "--text-muted": "oklch(0.49 0.045 310)", "--text-placeholder": "oklch(0.65 0.035 315)", "--text-link": "oklch(0.42 0.17 310)", "--text-inverse": "oklch(0.99 0.008 320)", "--border-default": "oklch(0.85 0.035 320)", "--border-subtle": "oklch(0.92 0.02 320)", "--border-focus": "oklch(0.57 0.16 310)", "--focus-ring": "oklch(0.57 0.16 310)", "--focus-ring-offset": "oklch(0.99 0.008 320)", "--selected": "oklch(0.9 0.065 320)", "--selected-foreground": "oklch(0.31 0.11 310)", "--disabled": "oklch(0.95 0.025 320)", "--disabled-foreground": "oklch(0.65 0.035 315)", "--info": "oklch(0.42 0.17 310)", "--info-foreground": "oklch(0.99 0.008 320)", "--info-muted": "oklch(0.9 0.065 320)", "--info-muted-foreground": "oklch(0.31 0.11 310)", "--info-border": "oklch(0.66 0.13 315)", "--chart-1": "oklch(0.42 0.17 310)", "--chart-2": "oklch(0.58 0.15 350)", "--chart-3": "oklch(0.62 0.14 40)", "--chart-4": "oklch(0.54 0.15 270)", "--chart-5": "oklch(0.65 0.12 180)", "--sidebar": "oklch(0.96 0.02 320)", "--sidebar-foreground": "oklch(0.23 0.05 310)", "--sidebar-primary": "oklch(0.42 0.17 310)", "--sidebar-primary-foreground": "oklch(0.99 0.008 320)", "--sidebar-accent": "oklch(0.9 0.065 320)", "--sidebar-accent-foreground": "oklch(0.31 0.11 310)", "--sidebar-border": "oklch(0.85 0.035 320)", "--sidebar-ring": "oklch(0.57 0.16 310)", ...sharedTokens,
},
},
ember: createLightTheme("ember", "Ember", "orange", 45, 0.14),
ruby: createLightTheme("ruby", "Ruby", "red", 25, 0.17),
amber: createLightTheme("amber", "Amber", "yellow", 90, 0.10),
forest: createLightTheme("forest", "Forest", "green", 150, 0.12),
};
function color(lightness: number, chroma: number, hue: number) {
return `oklch(${lightness} ${chroma} ${hue})`;
}
/** Reviewed catalog recipes, not a tenant-accessible token generator. */
function createLightTheme(id: TenantThemeId, name: string, family: string, hue: number, chroma: number): TenantTheme {
const primary = color(0.43, chroma, hue);
const foreground = color(0.23, 0.025, hue);
const background = color(0.985, 0.006, hue);
const muted = color(0.94, 0.018, hue);
const mutedForeground = color(0.44, 0.025, hue);
const selected = color(0.91, 0.035, hue);
const border = color(0.78, 0.025, hue);
return {
id, mode: "light", name, description: `A restrained ${family} palette with softly tinted surfaces.`,
tokens: {
...sharedTokens,
"--background": background, "--foreground": foreground,
"--card": "oklch(1 0 0)", "--card-foreground": foreground,
"--popover": "oklch(1 0 0)", "--popover-foreground": foreground,
"--primary": primary, "--primary-foreground": "oklch(0.985 0 0)",
"--secondary": muted, "--secondary-foreground": foreground,
"--muted": muted, "--muted-foreground": mutedForeground,
"--accent": selected, "--accent-foreground": foreground,
"--border": border, "--input": border, "--ring": primary,
"--surface-default": background, "--surface-raised": color(0.97, 0.01, hue),
"--surface-overlay": "oklch(1 0 0)", "--surface-sunken": muted,
"--text-default": foreground, "--text-muted": mutedForeground,
"--text-placeholder": color(0.48, 0.025, hue), "--text-link": primary,
"--text-inverse": "oklch(0.985 0 0)", "--border-default": border,
"--border-subtle": color(0.91, 0.015, hue), "--border-focus": primary,
"--focus-ring": primary, "--focus-ring-offset": background,
"--selected": selected, "--selected-foreground": foreground,
"--disabled": muted, "--disabled-foreground": color(0.64, 0.02, hue),
"--info": primary, "--info-foreground": "oklch(0.985 0 0)",
"--info-muted": selected, "--info-muted-foreground": foreground, "--info-border": border,
"--chart-1": primary, "--chart-2": color(0.5, 0.12, 190),
"--chart-3": color(0.55, 0.14, 45), "--chart-4": color(0.5, 0.16, 310),
"--chart-5": color(0.55, 0.12, 250),
"--sidebar": color(0.96, 0.014, hue), "--sidebar-foreground": foreground,
"--sidebar-primary": primary, "--sidebar-primary-foreground": "oklch(0.985 0 0)",
"--sidebar-accent": selected, "--sidebar-accent-foreground": foreground,
"--sidebar-border": border, "--sidebar-ring": primary,
},
};
}
function createDarkTheme(id: TenantDarkThemeId, name: string, hue: number, chroma: number): TenantTheme {
const background = color(0.225, Math.min(chroma, 0.008), hue);
const surface = color(0.27, Math.min(chroma, 0.012), hue);
const muted = color(0.31, Math.min(chroma, 0.02), hue);
const foreground = color(0.95, Math.min(chroma, 0.008), hue);
const mutedForeground = color(0.78, Math.min(chroma, 0.025), hue);
const primary = color(0.79, chroma, hue);
const primaryForeground = color(0.18, Math.min(chroma, 0.025), hue);
const border = color(0.45, Math.min(chroma, 0.025), hue);
const selected = color(0.36, Math.min(chroma, 0.06), hue);
return {
id, mode: "dark", name, description: `${name.replace(/ Dark$/, "")} accents over layered charcoal surfaces.`,
tokens: {
...sharedTokens,
"--background": background, "--foreground": foreground,
"--card": surface, "--card-foreground": foreground,
"--popover": surface, "--popover-foreground": foreground,
"--primary": primary, "--primary-foreground": primaryForeground,
"--secondary": muted, "--secondary-foreground": foreground,
"--muted": muted, "--muted-foreground": mutedForeground,
"--accent": selected, "--accent-foreground": foreground,
"--border": border, "--input": color(0.57, Math.min(chroma, 0.025), hue), "--ring": primary,
"--surface-default": background, "--surface-raised": surface,
"--surface-overlay": surface, "--surface-sunken": color(0.205, Math.min(chroma, 0.008), hue),
"--text-default": foreground, "--text-muted": mutedForeground,
"--text-placeholder": color(0.73, Math.min(chroma, 0.025), hue), "--text-link": primary,
"--text-inverse": primaryForeground, "--border-default": border,
"--border-subtle": color(0.37, Math.min(chroma, 0.015), hue), "--border-focus": primary,
"--focus-ring": primary, "--focus-ring-offset": background,
"--selected": selected, "--selected-foreground": foreground,
"--disabled": muted, "--disabled-foreground": color(0.6, Math.min(chroma, 0.02), hue),
"--destructive": color(0.76, 0.14, 25), "--destructive-foreground": "oklch(0.18 0 0)",
"--danger": color(0.76, 0.14, 25), "--danger-foreground": "oklch(0.18 0 0)",
"--border-error": color(0.76, 0.14, 25),
"--success": color(0.79, 0.12, 150), "--success-foreground": "oklch(0.18 0 0)",
"--success-muted": color(0.29, 0.035, 150), "--success-muted-foreground": color(0.86, 0.08, 150),
"--warning": color(0.84, 0.12, 85), "--warning-foreground": "oklch(0.18 0 0)",
"--warning-muted": color(0.29, 0.035, 85), "--warning-muted-foreground": color(0.89, 0.08, 85),
"--info": primary, "--info-foreground": primaryForeground,
"--info-muted": selected, "--info-muted-foreground": foreground, "--info-border": primary,
"--chart-1": primary, "--chart-2": color(0.79, 0.10, 190),
"--chart-3": color(0.8, 0.12, 45), "--chart-4": color(0.76, 0.12, 310),
"--chart-5": color(0.8, 0.10, 250),
"--sidebar": surface, "--sidebar-foreground": foreground,
"--sidebar-primary": primary, "--sidebar-primary-foreground": primaryForeground,
"--sidebar-accent": selected, "--sidebar-accent-foreground": foreground,
"--sidebar-border": border, "--sidebar-ring": primary,
},
};
}
export const tenantDarkThemes: Record<TenantDarkThemeId, TenantTheme> = {
"default-dark": createDarkTheme("default-dark", "Slate Dark", 255, 0),
"ocean-dark": createDarkTheme("ocean-dark", "Ocean Dark", 250, 0.12),
"orchid-dark": createDarkTheme("orchid-dark", "Orchid Dark", 310, 0.12),
"ember-dark": createDarkTheme("ember-dark", "Ember Dark", 45, 0.12),
"ruby-dark": createDarkTheme("ruby-dark", "Ruby Dark", 25, 0.14),
"amber-dark": createDarkTheme("amber-dark", "Amber Dark", 90, 0.12),
"forest-dark": createDarkTheme("forest-dark", "Forest Dark", 150, 0.12),
};
export function isTenantThemeId(value: unknown): value is TenantThemeId {
return typeof value === "string" && tenantThemeIds.includes(value as TenantThemeId);
}
export function isTenantThemeSelectionId(value: unknown): value is TenantThemeSelectionId {
return value === "custom" || isTenantThemeId(value);
}
export function isTenantDarkThemeId(value: unknown): value is TenantDarkThemeId {
return typeof value === "string" && tenantDarkThemeIds.includes(value as TenantDarkThemeId);
}
export function isTenantDarkThemeSelectionId(value: unknown): value is TenantDarkThemeSelectionId {
return value === "custom-dark" || isTenantDarkThemeId(value);
}
export function getTenantThemeStyle(themeId: TenantThemeId | TenantDarkThemeId): CSSProperties {
return (isTenantDarkThemeId(themeId) ? tenantDarkThemes[themeId] : tenantThemes[themeId]).tokens as CSSProperties;
}
All sources and standards