Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🪞 fix: Publish the Theme Defaults and Scale Mapping to Package Consumers (#16479)

Marco Beretta01f3e52eeea9
diff --git a/client/src/style.css b/client/src/style.css
index 80789a03df..f10918ce0e 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -11,45 +11,6 @@
--color-green-*: initial;
}
-/* The plain radius, font and shadow utilities read theme-owned properties, so a theme definition
- * reshapes the existing `rounded-*`, `font-sans`, `font-mono`, `text-*` and `shadow-*` call sites without a
- * migration. The defaults in the `html` block reproduce the scale these utilities resolved to
- * before. Bare `rounded` stays Tailwind's fixed 0.25rem: `sm` keeps its px offset, so the two part
- * at a non-16px root. Bare `shadow` reads `--shadow`, which has always equalled `sm`, and follows
- * it. A shadow held in a variable cannot be recolored by a `shadow-<color>` modifier; nothing here
- * uses one. App-only: the published preset keeps its own `sm` radius, which differs from this
- * scale, so consumers' corners do not move. */
-@theme inline {
- --radius-sm: var(--theme-radius-sm);
- --radius-md: var(--theme-radius-md);
- --radius-lg: var(--theme-radius-lg);
- --radius-xl: var(--theme-radius-xl);
- --radius-2xl: var(--theme-radius-2xl);
- --radius-3xl: var(--theme-radius-3xl);
- --font-sans: var(--theme-font-family);
- --font-mono: var(--theme-mono-font-family);
- --text-xs: var(--theme-text-xs);
- --text-xs--line-height: var(--theme-text-xs-leading);
- --text-sm: var(--theme-text-sm);
- --text-sm--line-height: var(--theme-text-sm-leading);
- --text-base: var(--theme-text-base);
- --text-base--line-height: var(--theme-text-base-leading);
- --text-lg: var(--theme-text-lg);
- --text-lg--line-height: var(--theme-text-lg-leading);
- --text-xl: var(--theme-text-xl);
- --text-xl--line-height: var(--theme-text-xl-leading);
- --text-2xl: var(--theme-text-2xl);
- --text-2xl--line-height: var(--theme-text-2xl-leading);
- --shadow: var(--theme-shadow-sm);
- --shadow-2xs: var(--theme-shadow-2xs);
- --shadow-xs: var(--theme-shadow-xs);
- --shadow-sm: var(--theme-shadow-sm);
- --shadow-md: var(--theme-shadow-md);
- --shadow-lg: var(--theme-shadow-lg);
- --shadow-xl: var(--theme-shadow-xl);
- --shadow-2xl: var(--theme-shadow-2xl);
-}
-
/* Tailwind v4 changed two preflight defaults this app was built against. Each rule below
* restores the v3 default rather than adopting the new one, so the upgrade carries no visual
* change; drop one only as a deliberate design decision.
@@ -78,67 +39,6 @@
/* Custom Variables */
:root {
- --white: 255 255 255;
- --black: 0 0 0;
- --gray-20: 236 236 241;
- --gray-50: 247 247 248;
- --gray-100: 236 236 236;
- --gray-200: 227 227 227;
- --gray-300: 205 205 205;
- --gray-400: 153 150 150;
- --gray-500: 89 89 89;
- --gray-600: 66 66 66;
- --gray-650: 57 57 57;
- --gray-700: 47 47 47;
- --gray-800: 33 33 33;
- --gray-850: 23 23 23;
- --gray-875: 18 18 18;
- --gray-900: 13 13 13;
- --green-50: 236 253 245;
- --green-100: 209 250 229;
- --green-200: 167 243 208;
- --green-300: 110 231 183;
- --green-400: 52 211 153;
- --green-500: 16 185 129;
- --green-600: 5 150 105;
- --green-700: 4 120 87;
- --green-800: 6 95 70;
- --green-900: 6 78 59;
- --green-950: 2 44 34;
- --red-50: 254 242 242;
- --red-100: 254 226 226;
- --red-200: 254 202 202;
- --red-300: 252 165 165;
- --red-400: 248 113 113;
- --red-500: 239 68 68;
- --red-600: 220 38 38;
- --red-700: 185 28 28;
- --red-800: 153 27 27;
- --red-900: 127 29 29;
- --red-950: 69 10 10;
- --amber-50: 255 251 235;
- --amber-100: 254 243 199;
- --amber-200: 253 230 138;
- --amber-300: 252 211 77;
- --amber-400: 251 191 36;
- --amber-500: 245 158 11;
- --amber-600: 217 119 6;
- --amber-700: 180 83 9;
- --amber-800: 146 64 14;
- --amber-900: 120 53 15;
- --amber-950: 69 26 3;
- --blue-50: 239 246 255;
- --blue-100: 219 234 254;
- --blue-200: 191 219 254;
- --blue-300: 147 197 253;
- --blue-400: 96 165 250;
- --blue-500: 59 130 246;
- --blue-600: 37 99 235;
- --blue-700: 29 78 216;
- --blue-800: 30 64 175;
- --blue-900: 30 58 138;
- --blue-950: 23 37 84;
- --brand-purple: 126 34 206;
--gizmo-gray-500: 153 153 153;
--gizmo-gray-600: 102 102 102;
--gizmo-gray-950: 15 15 15;
@@ -216,284 +116,6 @@
}
}
-html {
- --brand-purple: 126 34 206;
- --presentation: var(--white);
- --text-primary: var(--gray-800);
- --text-secondary: var(--gray-600);
- --text-secondary-alt: var(--gray-500);
- --text-tertiary: var(--gray-500);
- --text-muted: 105 110 121; /* Click UI global.color.text.muted #696e79 */
- --shimmer-dip: 129 130 134;
- --shimmer-dip-alpha: 0.18;
- --text-warning: var(--amber-700);
- --text-destructive: var(--red-600);
- --link: var(--blue-600);
- --link-hover: var(--blue-700);
- --link-visited: 147 51 234;
- --link-prose: var(--link);
- --accent-primary: 18 110 107;
- --accent-primary-hover: 10 79 83;
- --ring-primary: var(--gray-500);
- --focus-outline: 0 0 0;
- --header-primary: var(--white);
- --header-hover: var(--gray-50);
- --header-button-hover: var(--gray-50);
- --surface-active: var(--gray-100);
- --surface-active-alt: var(--gray-200);
- --surface-hover: var(--gray-200);
- --surface-hover-alt: var(--gray-300);
- --surface-composer-hover: var(--gray-200);
- --surface-primary: var(--white);
- --chart-widget-surface: 255 255 255; /* Click UI dashboards.chartWidget.color.background.default #ffffff */
- --chart-widget-stroke: 230 231 233; /* Click UI dashboards.chartWidget.color.stroke.default #e6e7e9 */
- --surface-primary-alt: var(--gray-50);
- --surface-primary-contrast: var(--gray-100);
- --surface-secondary: var(--gray-50);
- --surface-secondary-alt: var(--gray-200);
- --surface-tertiary: var(--gray-100);
- --surface-tertiary-alt: var(--white);
- --surface-dialog: var(--white);
- --surface-overlay: var(--gray-500);
- --surface-submit: var(--green-700);
- --surface-submit-hover: var(--green-800);
- --surface-destructive: var(--red-700);
- --surface-destructive-hover: var(--red-800);
- --surface-chat: var(--white);
- --surface-code: var(--surface-primary-alt);
- --surface-code-body: var(--surface-chat);
- --surface-qr: var(--white);
- --border-light: var(--gray-200);
- --border-light-alpha: 1;
- --border-medium-alt: var(--gray-300);
- --border-medium: var(--gray-300);
- --border-medium-alpha: 1;
- --border-heavy: var(--gray-400);
- --border-heavy-alpha: 1;
- --border-xheavy: var(--gray-500);
- --border-xheavy-alpha: 1;
- --border-destructive: var(--red-600);
- --status-success: var(--green-700);
- --status-success-subtle: var(--green-50);
- --status-success-border: var(--green-300);
- --status-success-strong: 2 133 94;
- --status-info: var(--blue-600);
- --status-info-subtle: var(--blue-50);
- --status-info-border: var(--blue-300);
- --status-info-strong: var(--gray-500);
- --status-warning: var(--amber-700);
- --status-warning-subtle: var(--amber-50);
- --status-warning-border: var(--amber-300);
- --status-warning-strong: 199 82 9;
- --status-error: var(--red-700);
- --status-error-subtle: var(--red-50);
- --status-error-border: var(--red-300);
- --status-error-strong: 224 47 31;
- --status-neutral: var(--gray-600);
- --status-neutral-subtle: var(--gray-100);
- --status-neutral-border: var(--gray-300);
- --status-verified: 37 99 235;
- --text-on-status: var(--white);
-
- /* Categorical series scale — slot order is the CVD-safety mechanism */
- --series-1: 5 110 189;
- --series-2: 233 86 13;
- --series-3: 0 148 142;
- --series-4: 182 123 5;
- --series-5: 216 90 142;
- --series-6: 126 35 205;
- --series-7: 1 131 1;
- --series-8: 63 81 181;
-
- /* Code syntax highlighting */
- --syntax-text: var(--gray-800);
- --syntax-comment: var(--gray-500);
- --syntax-meta: var(--gray-600);
- --syntax-builtin: 154 103 0;
- --syntax-keyword: 5 80 174;
- --syntax-string: 10 123 98;
- --syntax-attr: 154 47 106;
- --syntax-title: 180 35 24;
-
- --surface-inverted: var(--gray-850);
- --surface-inverted-hover: var(--gray-700);
- --text-inverted: var(--white);
- --surface-fixed: var(--white);
- --surface-fixed-hover: var(--gray-100);
- --text-fixed: var(--gray-800);
- --theme-control-radius: 0.75rem;
- --theme-round-control-radius: 9999px;
- --theme-surface-radius: 1rem;
- --theme-large-surface-radius: 1.5rem;
- --theme-radius-sm: calc(0.5rem - 4px);
- --theme-radius-md: calc(0.5rem - 2px);
- --theme-radius-lg: 0.5rem;
- --theme-radius-xl: 0.75rem;
- --theme-radius-2xl: 1rem;
- --theme-radius-3xl: 1.5rem;
- --theme-control-height: 2.25rem;
- --theme-space-compact: 0.375rem;
- --theme-space-normal: 0.75rem;
- --theme-disabled-style: dim;
- --theme-scrim-opacity: 0.8;
- --theme-alert-scrim-opacity: 0.9;
- --theme-modal-scrim-opacity: 0.65;
- --theme-font-family: Inter, sans-serif;
- --theme-display-font-family: Inter, sans-serif;
- --theme-text-xs: 0.75rem;
- --theme-text-xs-leading: calc(1 / 0.75);
- --theme-text-sm: 0.875rem;
- --theme-text-sm-leading: calc(1.25 / 0.875);
- --theme-text-base: 1rem;
- --theme-text-base-leading: calc(1.5 / 1);
- --theme-text-lg: 1.125rem;
- --theme-text-lg-leading: calc(1.75 / 1.125);
- --theme-text-xl: 1.25rem;
- --theme-text-xl-leading: calc(1.75 / 1.25);
- --theme-text-2xl: 1.5rem;
- --theme-text-2xl-leading: calc(2 / 1.5);
- /* Roboto Mono is self-hosted (the `@font-face` block below), so code renders the same on every
- * platform with real bold and italic faces. The tail is reached while the font loads, if it
- * fails, and per glyph for what the bundled latin subset omits (box drawing in terminal output
- * most visibly), ordered so those glyphs keep Roboto Mono's advance width: `ui-monospace` is SF
- * Mono on macOS, Cascadia Mono ships with Windows Terminal, and Consolas is last because it is
- * narrower than the rest. */
- --theme-mono-font-family:
- 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono',
- Consolas, monospace;
- --theme-elevation-surface: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
- --theme-shadow-2xs: 0 1px rgb(0 0 0 / 0.05);
- --theme-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
- --theme-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
- --theme-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
- --theme-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
- --theme-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
- --theme-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
- --theme-motion-fast: 150ms;
- --theme-motion-normal: 200ms;
- --switch-unchecked: 148 148 148;
- --provider-openai: #19c37d;
- --provider-openai-gpt4: #ab68ff;
- --provider-openai-reasoning: #000000;
- --provider-anthropic: #d09a74;
- --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0);
- --provider-bedrock: #268672;
- --provider-foreground: #ffffff;
-}
-.dark {
- --brand-purple: 171 104 255;
- --presentation: var(--gray-800);
- --text-primary: var(--gray-100);
- --focus-outline: 255 255 255;
- --text-secondary: var(--gray-300);
- --text-secondary-alt: var(--gray-400);
- --text-tertiary: var(--gray-400);
- --text-muted: 179 182 189; /* Click UI global.color.text.muted #b3b6bd */
- --shimmer-base: 255 255 255;
- --shimmer-base-alpha: 0.8;
- --shimmer-dip: 179 179 179;
- --shimmer-dip-alpha: 0.25;
- --text-warning: var(--amber-500);
- --text-destructive: var(--red-400);
- --link: var(--blue-400);
- --link-hover: var(--blue-300);
- --link-visited: 192 132 252;
- --link-prose: var(--text-primary);
- --accent-primary: 65 167 157;
- --accent-primary-hover: 109 200 185;
- --header-primary: var(--gray-700);
- --header-hover: var(--gray-600);
- --header-button-hover: var(--gray-700);
- --surface-active: var(--gray-500);
- --surface-active-alt: var(--gray-700);
- --surface-hover: var(--gray-650);
- --surface-hover-alt: var(--gray-600);
- --surface-composer-hover: var(--gray-600);
- --surface-primary: var(--gray-900);
- --chart-widget-surface: 40 40 40; /* Click UI dashboards.chartWidget.color.background.default #282828 */
- --chart-widget-stroke: 50 50 50; /* Click UI dashboards.chartWidget.color.stroke.default #323232 */
- --surface-primary-alt: var(--gray-850);
- --surface-primary-contrast: var(--gray-850);
- --surface-secondary: var(--gray-800);
- --surface-secondary-alt: var(--gray-800);
- --surface-tertiary: var(--gray-700);
- --surface-tertiary-alt: var(--gray-700);
- --surface-dialog: var(--gray-875);
- --surface-overlay: 0 0 0;
- --surface-submit: var(--green-700);
- --surface-submit-hover: var(--green-800);
- --surface-destructive: var(--red-800);
- --surface-destructive-hover: var(--red-900);
- --surface-chat: var(--gray-700);
- --surface-code: var(--presentation);
- --surface-code-body: var(--surface-primary-alt);
- --surface-qr: var(--white);
- /* One step off the page instead of two: in dark the edge only has to separate
- a surface from the one behind it, and a brighter line reads as a seam. */
- --border-light: var(--gray-800);
- --border-medium-alt: var(--gray-650);
- --border-medium: var(--gray-650);
- --border-heavy: var(--gray-500);
- --border-xheavy: var(--gray-400);
- --border-destructive: var(--red-500);
- --status-success: var(--green-300);
- --status-success-subtle: var(--green-950);
- --status-success-border: var(--green-800);
- --status-success-strong: 8 135 89;
- --status-info: var(--blue-300);
- --status-info-subtle: var(--blue-950);
- --status-info-border: var(--blue-800);
- --status-info-strong: var(--gray-600);
- --status-warning: var(--amber-300);
- --status-warning-subtle: var(--amber-950);
- --status-warning-border: var(--amber-800);
- --status-warning-strong: var(--amber-800);
- --status-error: var(--red-300);
- --status-error-subtle: var(--red-950);
- --status-error-border: var(--red-800);
- --status-error-strong: var(--red-800);
- --status-neutral: var(--gray-300);
- --status-neutral-subtle: var(--gray-800);
- --status-neutral-border: var(--gray-700);
- --status-verified: 26 127 216;
- --text-on-status: var(--white);
-
- /* Categorical series scale — same hues, stepped for the dark surface */
- --series-1: 9 140 238;
- --series-2: 217 87 35;
- --series-3: 6 158 152;
- --series-4: 200 133 12;
- --series-5: 213 82 130;
- --series-6: 171 104 254;
- --series-7: 80 167 49;
- --series-8: 120 130 190;
-
- /* Code syntax highlighting. Comment and meta are the flattened equivalents of
- the 50% and 60% alpha whites this palette used before it was tokenized. */
- --syntax-text: var(--white);
- --syntax-comment: 144 144 144;
- --syntax-meta: 166 166 166;
- --syntax-builtin: 233 149 12;
- --syntax-keyword: 46 149 211;
- --syntax-string: 0 166 125;
- --syntax-attr: 223 48 121;
- --syntax-title: 242 44 61;
-
- --surface-inverted: var(--white);
- --surface-inverted-hover: var(--gray-100);
- --text-inverted: var(--gray-850);
- --surface-fixed: var(--white);
- --surface-fixed-hover: var(--gray-100);
- --text-fixed: var(--gray-800);
- --switch-unchecked: 102 102 102;
- --provider-openai: #19c37d;
- --provider-openai-gpt4: #ab68ff;
- --provider-openai-reasoning: #000000;
- --provider-anthropic: #d09a74;
- --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0);
- --provider-bedrock: #268672;
- --provider-foreground: #ffffff;
-}
.gizmo {
--text-primary: var(--gizmo-gray-950);
--text-secondary: var(--gizmo-gray-600);
diff --git a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts
index e04ddb2b5e..96406b927f 100644
--- a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts
+++ b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts
@@ -12,8 +12,8 @@ import { repoRoot, run } from './lint.helpers';
* - an uncoloured `border-b` is painted with `currentColor`, so a divider
* drawn by a primitive follows the text ink unless the primitive names a
* role.
- * - the radius scale is Tailwind's, not ours, so `rounded-sm` means whatever
- * the current major says it means.
+ * - the radius scale is Tailwind's unless the package states its own, so
+ * `rounded-sm` would mean whatever the current major says it means.
*
* The scenario builds what a consumer actually installs: the package's own
* stylesheet and its published preset, compiled by Tailwind through the
@@ -121,10 +121,10 @@ Promise.all(${JSON.stringify([
expect(compile.status, `the consumer stylesheet did not compile:\n${compile.output}`).toBe(0);
const consumerCss = readFileSync(compiled, 'utf8');
- /** The consumer's own page sets no `--radius`: the setup in the theme README
- * never mentions one, so this is what a consumer following it gets. The
- * border token is set because the ThemeProvider writes those as channel
- * triplets. */
+ /** The consumer's own page restates two roles as channel triplets, the way
+ * the ThemeProvider writes them, so the probe can tell them from the stock
+ * values `theme.css` ships. Everything else is what a consumer following
+ * the theme README gets. */
await page.setContent(
`<!doctype html><html><head><style>
:root { --border-light: 10 20 30; --text-secondary: 40 50 60; }
@@ -155,25 +155,24 @@ Promise.all(${JSON.stringify([
defaultPalette,
);
- /** Tailwind 4 renamed the radius steps — the old `sm` is `xs`, and `sm` is
- * 0.25rem — so a checkbox that says `rounded-sm` doubles its corners unless
- * the preset states the step. 2px is what this preset produced under
- * Tailwind 3; 4px would mean Tailwind's scale won. */
+ /** Tailwind 4 renamed the radius steps (the old `sm` is `xs`, and `sm` is
+ * 0.25rem), so the package states its own: `rounded-sm` reads the theme's
+ * `--theme-radius-sm`, which ships at the app's `calc(0.5rem - 4px)`. */
const box = await read('box', ['border-radius']);
- expect(box['border-radius']).toBe('2px');
+ expect(box['border-radius']).toBe('4px');
- /** And the step is still a variable, so a theme retunes the whole family:
- * at `--radius: 1rem` the small step is 1rem - 0.375rem. (The SPA's own 4px
- * comes from its config restating the family in `px`, not from here.) */
- await page.evaluate(() => document.documentElement.style.setProperty('--radius', '1rem'));
+ /** And the step is a theme property, so a theme retunes it the way the
+ * ThemeProvider does, by writing the property on the root. */
+ await page.evaluate(() =>
+ document.documentElement.style.setProperty('--theme-radius-sm', '10px'),
+ );
expect((await read('box', ['border-radius']))['border-radius']).toBe('10px');
- await page.evaluate(() => document.documentElement.style.removeProperty('--radius'));
+ await page.evaluate(() => document.documentElement.style.removeProperty('--theme-radius-sm'));
- /** The scale is in `rem` on both sides of the subtraction, so a host that
- * moves the root font size keeps the proportions instead of collapsing the
- * small step to a square corner. */
+ /** The px offset holds the corner the app draws at any root font size: at a
+ * 10px root the step is 5px - 4px, exactly as in the app. */
await page.evaluate(() => document.documentElement.style.setProperty('font-size', '10px'));
- expect((await read('box', ['border-radius']))['border-radius']).toBe('1.25px');
+ expect((await read('box', ['border-radius']))['border-radius']).toBe('1px');
await page.evaluate(() => document.documentElement.style.removeProperty('font-size'));
/** A search field's placeholder reads as secondary text, not as the field's
diff --git a/e2e/specs/mock/scenarios/published-theme-parity.spec.ts b/e2e/specs/mock/scenarios/published-theme-parity.spec.ts
new file mode 100644
index 0000000000..90be10f77c
--- /dev/null
+++ b/e2e/specs/mock/scenarios/published-theme-parity.spec.ts
@@ -0,0 +1,252 @@
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { dirname, join, relative, resolve } from 'node:path';
+import { expect, test } from '@playwright/test';
+import type { Page } from '@playwright/test';
+import { inOneProject, repoRoot, run } from './lint.helpers';
+
+/**
+ * The app and a consumer of `@librechat/client` are meant to render the same
+ * theme contract: the same radius, font, type and shadow scales, the same color
+ * roles, and the same stock value behind each. The app compiles the package's
+ * theme sources directly, while a consumer compiles what the build copies into
+ * `dist` through the `./theme.css` export and the published preset, so the two
+ * drift apart the moment one of them grows a mapping or a default the other
+ * lacks, or the build stops shipping a file the export imports.
+ *
+ * This scenario compiles both from what each actually loads, renders the same
+ * probe under each in a browser, and compares what the browser computes, in
+ * light and in dark.
+ */
+
+type ClientManifest = { exports: Record<string, string>; files: string[] };
+
+const PROBE_DIR = resolve(repoRoot, 'e2e/specs/.test-results/published-theme-parity');
+const PACKAGE_ROOT = resolve(repoRoot, 'packages/client');
+const APP_STYLESHEET = resolve(repoRoot, 'client/src/style.css');
+const DIST_STYLESHEET = resolve(PACKAGE_ROOT, 'dist/style.css');
+
+/** The theme sources the build copies, each of which must ship unchanged. */
+const THEME_SOURCES = ['tokens.css', 'defaults.css'];
+
+const SCALE = [
+ 'rounded',
+ 'rounded-sm',
+ 'rounded-md',
+ 'rounded-lg',
+ 'rounded-xl',
+ 'rounded-2xl',
+ 'rounded-3xl',
+ 'rounded-theme-control',
+ 'rounded-theme-control-round',
+ 'rounded-theme-surface',
+ 'rounded-theme-surface-lg',
+ 'font-sans',
+ 'font-mono',
+ 'font-theme-ui',
+ 'font-display',
+ 'text-xs',
+ 'text-sm',
+ 'text-base',
+ 'text-lg',
+ 'text-xl',
+ 'text-2xl',
+ 'shadow',
+ 'shadow-2xs',
+ 'shadow-xs',
+ 'shadow-sm',
+ 'shadow-md',
+ 'shadow-lg',
+ 'shadow-xl',
+ 'shadow-2xl',
+ 'shadow-theme-surface',
+];
+const COMPUTED = [
+ 'border-top-left-radius',
+ 'font-family',
+ 'font-size',
+ 'line-height',
+ 'box-shadow',
+ 'background-color',
+];
+
+/** Every custom property a rule in `stylesheet` declares. */
+function declaredProperties(stylesheet: string): string[] {
+ return [...new Set(Array.from(stylesheet.matchAll(/^\s+(--[\w-]+):/gm), (match) => match[1]))];
+}
+
+function compile(entries: Array<[string, string]>): void {
+ const compiler = join(PROBE_DIR, 'compile.cjs');
+ writeFileSync(
+ compiler,
+ `const postcss = require('postcss');
+const tailwind = require('@tailwindcss/postcss');
+const { readFileSync, writeFileSync } = require('node:fs');
+Promise.all(${JSON.stringify(entries)}.map(async ([input, output]) => {
+ const result = await postcss([tailwind()]).process(readFileSync(input, 'utf8'), { from: input });
+ writeFileSync(output, result.css);
+}))
+ .catch((error) => {
+ console.error(error.message);
+ process.exit(1);
+ });
+`,
+ );
+ const compiled = run(process.execPath, [compiler]);
+ expect(compiled.status, `a stylesheet did not compile:\n${compiled.output}`).toBe(0);
+}
+
+type Snapshot = Record<string, Record<string, string>>;
+
+/** What the browser computes for every probe element and every root property, per mode. */
+async function snapshot(
+ page: Page,
+ css: string,
+ markup: string,
+ properties: string[],
+): Promise<Record<'light' | 'dark', Snapshot>> {
+ await page.setContent(`<!doctype html><html><head></head><body>${markup}</body></html>`);
+ await page.addStyleTag({ content: css });
+ const read = () =>
+ page.evaluate(
+ ([computed, rootProperties]) => {
+ const result: Record<string, Record<string, string>> = {};
+ const rootStyles = getComputedStyle(document.documentElement);
+ result[':root'] = Object.fromEntries(
+ rootProperties.map((name) => [name, rootStyles.getPropertyValue(name).trim()]),
+ );
+ document.querySelectorAll<HTMLElement>('[data-probe]').forEach((element) => {
+ const styles = getComputedStyle(element);
+ result[element.dataset.probe!] = Object.fromEntries(
+ computed.map((name) => [name, styles.getPropertyValue(name)]),
+ );
+ });
+ return result;
+ },
+ [COMPUTED, properties] as const,
+ );
+
+ const light = await read();
+ await page.evaluate(() => document.documentElement.classList.add('dark'));
+ const dark = await read();
+ return { light, dark };
+}
+
+test.describe('the published theme contract', () => {
+ test('a consumer renders the scales, roles and defaults the app renders @scenario:a-consumer-renders-the-theme-contract-the-app-renders', async ({
+ page,
+ }) => {
+ inOneProject();
+ test.setTimeout(300_000);
+ mkdirSync(PROBE_DIR, { recursive: true });
+
+ const manifest = JSON.parse(
+ readFileSync(resolve(PACKAGE_ROOT, 'package.json'), 'utf8'),
+ ) as ClientManifest;
+ const tokenStylesheet = resolve(PACKAGE_ROOT, manifest.exports['./theme.css']);
+ const distDirectory = dirname(tokenStylesheet);
+ const shipped = THEME_SOURCES.map((name) => join(distDirectory, name));
+ if (![DIST_STYLESHEET, ...shipped].every((file) => existsSync(file))) {
+ const built = run('npm', ['run', 'build', '--prefix', PACKAGE_ROOT]);
+ expect(built.status, `the component library did not build:\n${built.output}`).toBe(0);
+ }
+
+ /** The build output is the contract: every theme source ships byte for byte, so a
+ * stale `dist` fails here instead of comparing the app against an older package. */
+ THEME_SOURCES.forEach((name) => {
+ const source = readFileSync(resolve(PACKAGE_ROOT, 'src/theme', name), 'utf8');
+ expect(
+ readFileSync(join(distDirectory, name), 'utf8'),
+ `dist/${name} differs from src/theme/${name}; rebuild the package`,
+ ).toBe(source);
+ });
+
+ /** Every stylesheet the export imports has to resolve inside the published files, or
+ * it resolves in the monorepo and fails in the consumer's install. */
+ const exported = readFileSync(tokenStylesheet, 'utf8');
+ const imports = Array.from(exported.matchAll(/@import '([^']+)'/g), (match) => match[1]);
+ expect(imports).toContain('./defaults.css');
+ imports.forEach((specifier) => {
+ const target = resolve(distDirectory, specifier);
+ expect(existsSync(target), `${specifier} is missing from the build output`).toBe(true);
+ const path = relative(PACKAGE_ROOT, target);
+ expect(
+ manifest.files.some((entry) => path === entry || path.startsWith(`${entry}/`)),
+ `${path} is not inside the published files: ${manifest.files.join(', ')}`,
+ ).toBe(true);
+ });
+
+ const colors = Array.from(exported.matchAll(/--color-([\w-]+):/g), (match) => `bg-${match[1]}`);
+ expect(colors.length).toBeGreaterThan(80);
+ const candidates = [...SCALE, ...colors];
+ const markup = candidates
+ .map((candidate) => `<div data-probe="${candidate}" class="${candidate}">probe</div>`)
+ .join('\n');
+ const probeMarkup = join(PROBE_DIR, 'probe.html');
+ writeFileSync(probeMarkup, markup);
+
+ /** The consumer compiles the documented setup, pointed at the build output. */
+ const readme = readFileSync(resolve(PACKAGE_ROOT, 'src/theme/README.md'), 'utf8');
+ const documentedStylesheet = [...readme.matchAll(/```css\n([\s\S]*?)```/g)]
+ .map((match) => match[1])
+ .find((stylesheet) => stylesheet.includes("@import '@librechat/client/style.css';"));
+ const documentedConfig = [...readme.matchAll(/```js\n([\s\S]*?)```/g)]
+ .map((match) => match[1])
+ .find((config) => config.includes("require('@librechat/client/tailwind-preset')"));
+ expect(documentedStylesheet, 'the complete consumer stylesheet is documented').toBeDefined();
+ expect(documentedConfig, 'the consumer preset configuration is documented').toBeDefined();
+ const consumerConfig = join(PROBE_DIR, 'tailwind.config.cjs');
+ writeFileSync(
+ consumerConfig,
+ documentedConfig!.replace(
+ "require('@librechat/client/tailwind-preset')",
+ `require(${JSON.stringify(resolve(PACKAGE_ROOT, manifest.exports['./tailwind-preset']))})`,
+ ),
+ );
+ const consumerEntry = join(PROBE_DIR, 'consumer.css');
+ writeFileSync(
+ consumerEntry,
+ [
+ documentedStylesheet!
+ .replace("@import '@librechat/client/theme.css';", `@import '${tokenStylesheet}';`)
+ .replace("@import '@librechat/client/style.css';", `@import '${DIST_STYLESHEET}';`)
+ .replace(/@config '[^']+';/, `@config '${consumerConfig}';`),
+ `@source '${probeMarkup}';`,
+ '',
+ ].join('\n'),
+ );
+
+ /** The app compiles its own entry, exactly as its build does. */
+ const appEntry = join(PROBE_DIR, 'app.css');
+ writeFileSync(appEntry, `@import '${APP_STYLESHEET}';\n@source '${probeMarkup}';\n`);
+
+ const consumerCompiled = join(PROBE_DIR, 'consumer.out.css');
+ const appCompiled = join(PROBE_DIR, 'app.out.css');
+ compile([
+ [consumerEntry, consumerCompiled],
+ [appEntry, appCompiled],
+ ]);
+
+ const defaults = readFileSync(join(distDirectory, 'defaults.css'), 'utf8');
+ const properties = declaredProperties(defaults);
+ expect(properties).toEqual(expect.arrayContaining(['--border-control', '--theme-radius-sm']));
+
+ const app = await snapshot(page, readFileSync(appCompiled, 'utf8'), markup, properties);
+ const consumer = await snapshot(
+ page,
+ readFileSync(consumerCompiled, 'utf8'),
+ markup,
+ properties,
+ );
+
+ /** Guard against a vacuous match: the probe has to render something in both. */
+ expect(app.light['rounded-sm']['border-top-left-radius']).toBe('4px');
+ expect(app.light['text-sm']['font-size']).toBe('14px');
+ expect(app.light['bg-surface-primary']['background-color']).toBe('rgb(255, 255, 255)');
+ expect(app.dark[':root']['--surface-primary']).not.toBe(
+ app.light[':root']['--surface-primary'],
+ );
+
+ expect(consumer.light).toEqual(app.light);
+ expect(consumer.dark).toEqual(app.dark);
+ });
+});
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 9f150d90fb..a9526f6648 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -41,8 +41,20 @@ keeps its original validation, so a released theme holding `var()` there still l
shadow role, `none` is written as a transparent layer so Tailwind can still compose it with ring
utilities.
The defaults reproduce the scale those utilities had before, so a theme that names none of them
-changes nothing. The mapping lives in the app stylesheet (`client/src/style.css`), not the
-published `theme.css`, whose preset keeps its own `rounded-sm`.
+changes nothing. The mapping lives in `tokens.css`, which the app stylesheet imports and
+`@librechat/client/theme.css` publishes, so a consumer's utilities are the app's.
+
+The stock families name Inter (`font-sans`, `font-theme-ui`) and Roboto Mono (`font-mono`), which
+the LibreChat app self-hosts with its own `@font-face` rules; the package does not ship the font
+files. A consumer that does not load them renders the next family in each stack (`sans-serif`, then
+`ui-monospace` and the platform monospace fonts), or sets `fontFamily` and `monoFontFamily`, or the
+`--theme-font-family` and `--theme-mono-font-family` properties, to families it does load.
+
+> **Breaking change:** the preset used to pin `rounded-sm`, `rounded-md` and `rounded-lg` to
+> `--radius` (0.125rem, 0.375rem and 0.5rem by default). They now read `--theme-radius-sm`,
+> `--theme-radius-md` and `--theme-radius-lg` like the app's, so `rounded-sm` renders at
+> `calc(0.5rem - 4px)` and `--radius` no longer retunes them. Set the `radiusSm` through
+> `radius3xl` appearance roles, or the properties behind them, to reshape the scale.
The bundled ClickHouse theme (`themes/clickhouse.ts`) is the reference for a theme that changes
shape as well as color: it tightens the radius scale to Click UI's `border.radii` steps, sets the
@@ -82,13 +94,14 @@ The theme system provides:
The theme system operates in three layers:
-1. **CSS Variables Layer**: Default colors defined in your app's CSS
+1. **CSS Variables Layer**: Default colors, shape, type and elevation shipped by the package
2. **ThemeProvider Layer**: React context that manages theme state and applies CSS variables
3. **Tailwind Layer**: Maps CSS variables to Tailwind utility classes
### Default Behavior (No Custom Theme)
-- CSS variables cascade from your app's `style.css` definitions
+- CSS variables cascade from the stock values `@librechat/client/theme.css` ships
+ (`defaults.css`), which the LibreChat app reads through the same import
- Light mode uses variables under `html` selector
- Dark mode uses variables under `.dark` selector
- No JavaScript intervention in color values
@@ -124,39 +137,34 @@ function App() {
### 3. Set Up Your Base CSS
-Import the published token stylesheet and define the variables it resolves. Every theme
-variable must hold a **bare `R G B` channel triplet**, not a complete CSS color, because
-each token wraps them as `rgb(var(--x))` so that opacity modifiers such as
-`bg-surface-primary/50` work:
+Import the published token stylesheet. It declares every token and the stock value of every
+property the tokens read, for light (`html`) and dark (`.dark`), so the components render the
+LibreChat palette with nothing else defined. Restate only what you change, after the import.
+Every theme color must hold a **bare `R G B` channel triplet**, not a complete CSS color,
+because each token wraps them as `rgb(var(--x))` so that opacity modifiers such as
+`bg-surface-primary/50` work. The stock roles are written against primitive scales under
+`:root` (`--white`, `--gray-*`, `--green-*`, `--red-*`, `--amber-*`, `--blue-*`), so
+redefining a step retints every role that reads it:
```css
/* style.css */
@import 'tailwindcss';
/* Declares --color-text-primary, --color-surface-primary and the rest of the tokens as
- * `@theme inline`, so every utility resolves the custom property below at runtime. */
+ * `@theme inline`, so every utility resolves its custom property at runtime, along with the
+ * stock value of each property. */
@import '@librechat/client/theme.css';
/* v4 reads no config by default: this is what loads the preset, the content globs and
* class-based dark mode from step 4. This app's own entry does the same
* (`client/src/style.css`), and so does the library's (`src/theme/theme.css`). */
@config './tailwind.config.js';
-:root {
- --white: 255 255 255;
- --gray-800: 33 33 33;
- --gray-100: 236 236 236;
- /* ... other color definitions */
-}
-
+/* Optional: only what differs from the stock palette. */
html {
- --text-primary: var(--gray-800);
- --surface-primary: var(--white);
- /* ... other theme variables */
+ --surface-primary: 250 250 249;
}
.dark {
- --text-primary: var(--gray-100);
- --surface-primary: var(--gray-900);
- /* ... other dark theme variables */
+ --surface-primary: 12 10 9;
}
```
@@ -322,7 +330,7 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
- `font-display` - Headings and dialog titles (`displayFontFamily`). Follows the
theme's `fontFamily` when it names no display family.
- `text-xs` to `text-2xl` - Sizes and line heights read `textXs`..`text2xl` and
- `leadingXs`..`leading2xl` (app only, like the radius scale); the defaults are
+ `leadingXs`..`leading2xl`, in the app and in a consumer alike; the defaults are
Tailwind's own values.
- `bg-scrim` / `bg-scrim-alert` / `bg-scrim-modal` - The OGDialog, AlertDialog
and Dialog scrims: `surface-overlay` at the `scrimOpacity`,
diff --git a/packages/client/src/theme/context/ThemeProvider.tsx b/packages/client/src/theme/context/ThemeProvider.tsx
index 50ba666874..57ac39edc5 100644
--- a/packages/client/src/theme/context/ThemeProvider.tsx
+++ b/packages/client/src/theme/context/ThemeProvider.tsx
@@ -26,7 +26,6 @@ import { defaultTheme } from '../themes/default';
import { darkTheme } from '../themes/dark';
import '../highContrast.css';
import '../preflight.css';
-import '../controls.css';
const THEME_KEY = 'color-theme';
const THEME_COLORS_KEY = 'theme-colors';
diff --git a/packages/client/src/theme/controls.css b/packages/client/src/theme/controls.css
deleted file mode 100644
index 6da3479ce5..0000000000
--- a/packages/client/src/theme/controls.css
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Stylesheet defaults for the roles the package's own primitives paint:
- * `--border-control`, the form-control boundary, `--focus-control`, the
- * keyboard focus ring of `Checkbox`, `Switch`, `Field` and their siblings, the
- * pressed fills `IconButton` takes while held (the hover fills, which a pointer
- * press has always shown), and the disabled roles a `fill` theme paints.
- *
- * Every other color role is declared by the app stylesheet, but these ship
- * with the package so a consumer rendering `Input`, `Select` or `Checkbox` gets
- * an outline and a focus ring without restating them. The stock boundary
- * matches `border-light`, and the stock ring matches `text-primary`, the ink
- * the primitives drew their ring in before the role existed.
- * `ThemeProvider` paints the registry value inline whenever a theme is active,
- * which outranks these; they only cover the stock palette before and without a
- * theme definition, and `semanticTokens.spec.ts` keeps them in step with
- * `themes/default.ts` and `themes/dark.ts`.
- */
-html {
- --border-control: 227 227 227;
- --focus-control: 33 33 33;
- --surface-pressed: 227 227 227;
- --surface-inverted-pressed: 47 47 47;
- --surface-disabled: 236 236 236;
- --text-disabled: 153 150 150;
- --border-disabled: 227 227 227;
-}
-
-.dark {
- --border-control: 33 33 33;
- --focus-control: 236 236 236;
- --surface-pressed: 57 57 57;
- --surface-inverted-pressed: 236 236 236;
- --surface-disabled: 47 47 47;
- --text-disabled: 153 150 150;
- --border-disabled: 57 57 57;
-}
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
new file mode 100644
index 0000000000..e4edb13a48
--- /dev/null
+++ b/packages/client/src/theme/defaults.css
@@ -0,0 +1,367 @@
+/**
+ * The stock value of every theme-owned property, and the single source for them.
+ *
+ * `tokens.css` maps the Tailwind utilities onto these properties and imports this file, so a
+ * consumer of `@librechat/client/theme.css` renders the stock palette, shape, type and elevation
+ * without restating any of it, and the LibreChat app reads the same declarations through the same
+ * import. `ThemeProvider` paints a resolved theme inline on the root, which outranks every rule
+ * here; these cover the page before and without a theme definition.
+ *
+ * The roles are written against the primitive scales under `:root`, so a host that redefines a
+ * step after this import retints every role that reads it. `themes/default.ts`, `themes/dark.ts`
+ * and `registry.ts` carry the same values for the runtime, and `defaults.spec.ts` holds them equal.
+ */
+:root {
+ --white: 255 255 255;
+ --black: 0 0 0;
+ --gray-20: 236 236 241;
+ --gray-50: 247 247 248;
+ --gray-100: 236 236 236;
+ --gray-200: 227 227 227;
+ --gray-300: 205 205 205;
+ --gray-400: 153 150 150;
+ --gray-500: 89 89 89;
+ --gray-600: 66 66 66;
+ --gray-650: 57 57 57;
+ --gray-700: 47 47 47;
+ --gray-800: 33 33 33;
+ --gray-850: 23 23 23;
+ --gray-875: 18 18 18;
+ --gray-900: 13 13 13;
+ --green-50: 236 253 245;
+ --green-100: 209 250 229;
+ --green-200: 167 243 208;
+ --green-300: 110 231 183;
+ --green-400: 52 211 153;
+ --green-500: 16 185 129;
+ --green-600: 5 150 105;
+ --green-700: 4 120 87;
+ --green-800: 6 95 70;
+ --green-900: 6 78 59;
+ --green-950: 2 44 34;
+ --red-50: 254 242 242;
+ --red-100: 254 226 226;
+ --red-200: 254 202 202;
+ --red-300: 252 165 165;
+ --red-400: 248 113 113;
+ --red-500: 239 68 68;
+ --red-600: 220 38 38;
+ --red-700: 185 28 28;
+ --red-800: 153 27 27;
+ --red-900: 127 29 29;
+ --red-950: 69 10 10;
+ --amber-50: 255 251 235;
+ --amber-100: 254 243 199;
+ --amber-200: 253 230 138;
+ --amber-300: 252 211 77;
+ --amber-400: 251 191 36;
+ --amber-500: 245 158 11;
+ --amber-600: 217 119 6;
+ --amber-700: 180 83 9;
+ --amber-800: 146 64 14;
+ --amber-900: 120 53 15;
+ --amber-950: 69 26 3;
+ --blue-50: 239 246 255;
+ --blue-100: 219 234 254;
+ --blue-200: 191 219 254;
+ --blue-300: 147 197 253;
+ --blue-400: 96 165 250;
+ --blue-500: 59 130 246;
+ --blue-600: 37 99 235;
+ --blue-700: 29 78 216;
+ --blue-800: 30 64 175;
+ --blue-900: 30 58 138;
+ --blue-950: 23 37 84;
+}
+
+html {
+ --brand-purple: 126 34 206;
+ --presentation: var(--white);
+ --text-primary: var(--gray-800);
+ --text-secondary: var(--gray-600);
+ --text-secondary-alt: var(--gray-500);
+ --text-tertiary: var(--gray-500);
+ --text-muted: 105 110 121; /* Click UI global.color.text.muted #696e79 */
+ --shimmer-dip: 129 130 134;
+ --shimmer-dip-alpha: 0.18;
+ --text-warning: var(--amber-700);
+ --text-destructive: var(--red-600);
+ --link: var(--blue-600);
+ --link-hover: var(--blue-700);
+ --link-visited: 147 51 234;
+ --link-prose: var(--link);
+ --accent-primary: 18 110 107;
+ --accent-primary-hover: 10 79 83;
+ --ring-primary: var(--gray-500);
+ --focus-outline: 0 0 0;
+ --header-primary: var(--white);
+ --header-hover: var(--gray-50);
+ --header-button-hover: var(--gray-50);
+ --surface-active: var(--gray-100);
+ --surface-active-alt: var(--gray-200);
+ --surface-hover: var(--gray-200);
+ --surface-hover-alt: var(--gray-300);
+ --surface-pressed: var(--gray-200);
+ --surface-composer-hover: var(--gray-200);
+ --surface-primary: var(--white);
+ --chart-widget-surface: 255 255 255; /* Click UI dashboards.chartWidget.color.background.default #ffffff */
+ --chart-widget-stroke: 230 231 233; /* Click UI dashboards.chartWidget.color.stroke.default #e6e7e9 */
+ --surface-primary-alt: var(--gray-50);
+ --surface-primary-contrast: var(--gray-100);
+ --surface-secondary: var(--gray-50);
+ --surface-secondary-alt: var(--gray-200);
+ --surface-tertiary: var(--gray-100);
+ --surface-tertiary-alt: var(--white);
+ --surface-dialog: var(--white);
+ --surface-overlay: var(--gray-500);
+ --surface-submit: var(--green-700);
+ --surface-submit-hover: var(--green-800);
+ --surface-destructive: var(--red-700);
+ --surface-destructive-hover: var(--red-800);
+ --surface-chat: var(--white);
+ --surface-code: var(--surface-primary-alt);
+ --surface-code-body: var(--surface-chat);
+ --surface-qr: var(--white);
+ --border-light: var(--gray-200);
+ --border-light-alpha: 1;
+ --border-medium-alt: var(--gray-300);
+ --border-medium: var(--gray-300);
+ --border-medium-alpha: 1;
+ --border-heavy: var(--gray-400);
+ --border-heavy-alpha: 1;
+ --border-xheavy: var(--gray-500);
+ --border-xheavy-alpha: 1;
+ --border-destructive: var(--red-600);
+ --border-control: var(--gray-200);
+ --focus-control: var(--gray-800);
+ --border-disabled: var(--gray-200);
+ --status-success: var(--green-700);
+ --status-success-subtle: var(--green-50);
+ --status-success-border: var(--green-300);
+ --status-success-strong: 2 133 94;
+ --status-info: var(--blue-600);
+ --status-info-subtle: var(--blue-50);
+ --status-info-border: var(--blue-300);
+ --status-info-strong: var(--gray-500);
+ --status-warning: var(--amber-700);
+ --status-warning-subtle: var(--amber-50);
+ --status-warning-border: var(--amber-300);
+ --status-warning-strong: 199 82 9;
+ --status-error: var(--red-700);
+ --status-error-subtle: var(--red-50);
+ --status-error-border: var(--red-300);
+ --status-error-strong: 224 47 31;
+ --status-neutral: var(--gray-600);
+ --status-neutral-subtle: var(--gray-100);
+ --status-neutral-border: var(--gray-300);
+ --status-verified: 37 99 235;
+ --text-on-status: var(--white);
+ --text-disabled: var(--gray-400);
+
+ /* Categorical series scale: slot order is the CVD-safety mechanism */
+ --series-1: 5 110 189;
+ --series-2: 233 86 13;
+ --series-3: 0 148 142;
+ --series-4: 182 123 5;
+ --series-5: 216 90 142;
+ --series-6: 126 35 205;
+ --series-7: 1 131 1;
+ --series-8: 63 81 181;
+
+ /* Code syntax highlighting */
+ --syntax-text: var(--gray-800);
+ --syntax-comment: var(--gray-500);
+ --syntax-meta: var(--gray-600);
+ --syntax-builtin: 154 103 0;
+ --syntax-keyword: 5 80 174;
+ --syntax-string: 10 123 98;
+ --syntax-attr: 154 47 106;
+ --syntax-title: 180 35 24;
+
+ --surface-inverted: var(--gray-850);
+ --surface-inverted-hover: var(--gray-700);
+ --surface-inverted-pressed: var(--gray-700);
+ --surface-disabled: var(--gray-100);
+ --text-inverted: var(--white);
+ --surface-fixed: var(--white);
+ --surface-fixed-hover: var(--gray-100);
+ --text-fixed: var(--gray-800);
+ --theme-control-radius: 0.75rem;
+ --theme-round-control-radius: 9999px;
+ --theme-surface-radius: 1rem;
+ --theme-large-surface-radius: 1.5rem;
+ --theme-radius-sm: calc(0.5rem - 4px);
+ --theme-radius-md: calc(0.5rem - 2px);
+ --theme-radius-lg: 0.5rem;
+ --theme-radius-xl: 0.75rem;
+ --theme-radius-2xl: 1rem;
+ --theme-radius-3xl: 1.5rem;
+ --theme-control-height: 2.25rem;
+ --theme-space-compact: 0.375rem;
+ --theme-space-normal: 0.75rem;
+ --theme-disabled-style: dim;
+ --theme-scrim-opacity: 0.8;
+ --theme-alert-scrim-opacity: 0.9;
+ --theme-modal-scrim-opacity: 0.65;
+ --theme-font-family: Inter, sans-serif;
+ --theme-display-font-family: Inter, sans-serif;
+ --theme-text-xs: 0.75rem;
+ --theme-text-xs-leading: calc(1 / 0.75);
+ --theme-text-sm: 0.875rem;
+ --theme-text-sm-leading: calc(1.25 / 0.875);
+ --theme-text-base: 1rem;
+ --theme-text-base-leading: calc(1.5 / 1);
+ --theme-text-lg: 1.125rem;
+ --theme-text-lg-leading: calc(1.75 / 1.125);
+ --theme-text-xl: 1.25rem;
+ --theme-text-xl-leading: calc(1.75 / 1.25);
+ --theme-text-2xl: 1.5rem;
+ --theme-text-2xl-leading: calc(2 / 1.5);
+ /* Roboto Mono is self-hosted (the `@font-face` block below), so code renders the same on every
+ * platform with real bold and italic faces. The tail is reached while the font loads, if it
+ * fails, and per glyph for what the bundled latin subset omits (box drawing in terminal output
+ * most visibly), ordered so those glyphs keep Roboto Mono's advance width: `ui-monospace` is SF
+ * Mono on macOS, Cascadia Mono ships with Windows Terminal, and Consolas is last because it is
+ * narrower than the rest. */
+ --theme-mono-font-family:
+ 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono',
+ Consolas, monospace;
+ --theme-elevation-surface: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
+ --theme-shadow-2xs: 0 1px rgb(0 0 0 / 0.05);
+ --theme-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+ --theme-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
+ --theme-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
+ --theme-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
+ --theme-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
+ --theme-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
+ --theme-motion-fast: 150ms;
+ --theme-motion-normal: 200ms;
+ --switch-unchecked: 148 148 148;
+ --provider-openai: #19c37d;
+ --provider-openai-gpt4: #ab68ff;
+ --provider-openai-reasoning: #000000;
+ --provider-anthropic: #d09a74;
+ --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0);
+ --provider-bedrock: #268672;
+ --provider-foreground: #ffffff;
+}
+.dark {
+ --brand-purple: 171 104 255;
+ --presentation: var(--gray-800);
+ --text-primary: var(--gray-100);
+ --focus-outline: 255 255 255;
+ --text-secondary: var(--gray-300);
+ --text-secondary-alt: var(--gray-400);
+ --text-tertiary: var(--gray-400);
+ --text-muted: 179 182 189; /* Click UI global.color.text.muted #b3b6bd */
+ --shimmer-base: 255 255 255;
+ --shimmer-base-alpha: 0.8;
+ --shimmer-dip: 179 179 179;
+ --shimmer-dip-alpha: 0.25;
+ --text-warning: var(--amber-500);
+ --text-destructive: var(--red-400);
+ --link: var(--blue-400);
+ --link-hover: var(--blue-300);
+ --link-visited: 192 132 252;
+ --link-prose: var(--text-primary);
+ --accent-primary: 65 167 157;
+ --accent-primary-hover: 109 200 185;
+ --header-primary: var(--gray-700);
+ --header-hover: var(--gray-600);
+ --header-button-hover: var(--gray-700);
+ --surface-active: var(--gray-500);
+ --surface-active-alt: var(--gray-700);
+ --surface-hover: var(--gray-650);
+ --surface-hover-alt: var(--gray-600);
+ --surface-pressed: var(--gray-650);
+ --surface-composer-hover: var(--gray-600);
+ --surface-primary: var(--gray-900);
+ --chart-widget-surface: 40 40 40; /* Click UI dashboards.chartWidget.color.background.default #282828 */
+ --chart-widget-stroke: 50 50 50; /* Click UI dashboards.chartWidget.color.stroke.default #323232 */
+ --surface-primary-alt: var(--gray-850);
+ --surface-primary-contrast: var(--gray-850);
+ --surface-secondary: var(--gray-800);
+ --surface-secondary-alt: var(--gray-800);
+ --surface-tertiary: var(--gray-700);
+ --surface-tertiary-alt: var(--gray-700);
+ --surface-dialog: var(--gray-875);
+ --surface-overlay: 0 0 0;
+ --surface-submit: var(--green-700);
+ --surface-submit-hover: var(--green-800);
+ --surface-destructive: var(--red-800);
+ --surface-destructive-hover: var(--red-900);
+ --surface-chat: var(--gray-700);
+ --surface-code: var(--presentation);
+ --surface-code-body: var(--surface-primary-alt);
+ --surface-qr: var(--white);
+ /* One step off the page instead of two: in dark the edge only has to separate
+ a surface from the one behind it, and a brighter line reads as a seam. */
+ --border-light: var(--gray-800);
+ --border-medium-alt: var(--gray-650);
+ --border-medium: var(--gray-650);
+ --border-heavy: var(--gray-500);
+ --border-xheavy: var(--gray-400);
+ --border-destructive: var(--red-500);
+ --border-control: var(--gray-800);
+ --focus-control: var(--gray-100);
+ --border-disabled: var(--gray-650);
+ --status-success: var(--green-300);
+ --status-success-subtle: var(--green-950);
+ --status-success-border: var(--green-800);
+ --status-success-strong: 8 135 89;
+ --status-info: var(--blue-300);
+ --status-info-subtle: var(--blue-950);
+ --status-info-border: var(--blue-800);
+ --status-info-strong: var(--gray-600);
+ --status-warning: var(--amber-300);
+ --status-warning-subtle: var(--amber-950);
+ --status-warning-border: var(--amber-800);
+ --status-warning-strong: var(--amber-800);
+ --status-error: var(--red-300);
+ --status-error-subtle: var(--red-950);
+ --status-error-border: var(--red-800);
+ --status-error-strong: var(--red-800);
+ --status-neutral: var(--gray-300);
+ --status-neutral-subtle: var(--gray-800);
+ --status-neutral-border: var(--gray-700);
+ --status-verified: 26 127 216;
+ --text-on-status: var(--white);
+
+ /* Categorical series scale: same hues, stepped for the dark surface */
+ --series-1: 9 140 238;
+ --series-2: 217 87 35;
+ --series-3: 6 158 152;
+ --series-4: 200 133 12;
+ --series-5: 213 82 130;
+ --series-6: 171 104 254;
+ --series-7: 80 167 49;
+ --series-8: 120 130 190;
+
+ /* Code syntax highlighting. Comment and meta are the flattened equivalents of
+ the 50% and 60% alpha whites this palette used before it was tokenized. */
+ --syntax-text: var(--white);
+ --syntax-comment: 144 144 144;
+ --syntax-meta: 166 166 166;
+ --syntax-builtin: 233 149 12;
+ --syntax-keyword: 46 149 211;
+ --syntax-string: 0 166 125;
+ --syntax-attr: 223 48 121;
+ --syntax-title: 242 44 61;
+
+ --surface-inverted: var(--white);
+ --surface-inverted-hover: var(--gray-100);
+ --surface-inverted-pressed: var(--gray-100);
+ --surface-disabled: var(--gray-700);
+ --text-inverted: var(--gray-850);
+ --surface-fixed: var(--white);
+ --surface-fixed-hover: var(--gray-100);
+ --text-fixed: var(--gray-800);
+ --switch-unchecked: 102 102 102;
+ --provider-openai: #19c37d;
+ --provider-openai-gpt4: #ab68ff;
+ --provider-openai-reasoning: #000000;
+ --provider-anthropic: #d09a74;
+ --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0);
+ --provider-bedrock: #268672;
+ --provider-foreground: #ffffff;
+}
diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts
new file mode 100644
index 0000000000..c946d6af3c
--- /dev/null
+++ b/packages/client/src/theme/defaults.spec.ts
@@ -0,0 +1,101 @@
+import fs from 'fs';
+import path from 'path';
+import type { IThemeRGB } from './types';
+import { defaultAppearance, defaultBrands, themeAppearanceProperties } from './registry';
+import { defaultTheme } from './themes/default';
+import { darkTheme } from './themes/dark';
+
+const stylesheet = fs.readFileSync(path.resolve(__dirname, 'defaults.css'), 'utf8');
+
+/** The declarations of the one top-level rule for `selector`, whitespace collapsed. */
+function declarations(selector: string): Map<string, string> {
+ const body = stylesheet.match(new RegExp(`^${selector.replace('.', '\\.')} \\{([^}]*)\\}`, 'm'));
+ if (!body) {
+ throw new Error(`defaults.css has no ${selector} rule`);
+ }
+ const withoutComments = body[1].replace(/\/\*[\s\S]*?\*\//g, '');
+ return new Map(
+ Array.from(withoutComments.matchAll(/(--[\w-]+):\s*([^;]+);/g), (match) => [
+ match[1],
+ match[2].replace(/\s+/g, ' ').trim(),
+ ]),
+ );
+}
+
+const root = declarations(':root');
+const light = declarations('html');
+const dark = declarations('.dark');
+
+/**
+ * Tokens the stylesheet leaves undeclared on purpose, and the property the one rule that reads
+ * each falls back to. The shimmer's bright stop follows the primary text color at the use site
+ * in light mode, so a theme that sets only the text color still moves it.
+ */
+const useSiteFallbacks: Partial<Record<string, string>> = {
+ '--shimmer-base': '--text-primary',
+};
+
+/** What `property` computes to on the root in a mode: `.dark` sits on the same element as `html`,
+ * so it inherits every declaration it does not restate. */
+function resolve(property: string, isDark: boolean, seen: string[] = []): string | undefined {
+ if (seen.includes(property)) {
+ throw new Error(`defaults.css has a var() cycle: ${[...seen, property].join(' -> ')}`);
+ }
+ const value =
+ (isDark ? dark.get(property) : undefined) ?? light.get(property) ?? root.get(property);
+ if (value === undefined) {
+ const fallback = useSiteFallbacks[property];
+ return fallback === undefined ? undefined : resolve(fallback, isDark, [...seen, property]);
+ }
+ return value.replace(/var\((--[\w-]+)\)/g, (_match, reference: string) => {
+ const resolved = resolve(reference, isDark, [...seen, property]);
+ if (resolved === undefined) {
+ throw new Error(`${property} reads ${reference}, which defaults.css never declares`);
+ }
+ return resolved;
+ });
+}
+
+describe.each([
+ ['light', defaultTheme, false],
+ ['dark', darkTheme, true],
+])('the %s stock palette', (_mode, theme: IThemeRGB, isDark: boolean) => {
+ const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
+
+ it('covers every registry color', () => {
+ expect(tokens).toHaveLength(103);
+ });
+
+ it('resolves every registry color to the runtime theme value', () => {
+ const drift = tokens.flatMap((token) => {
+ const property = `--${token.slice(4)}`;
+ const actual = resolve(property, isDark);
+ return actual === theme[token] ? [] : [`${property}: css ${actual}, runtime ${theme[token]}`];
+ });
+
+ expect(drift).toEqual([]);
+ });
+});
+
+describe('the stock appearance and brands', () => {
+ it('declares every appearance property with the registry default', () => {
+ Object.entries(themeAppearanceProperties).forEach(([key, property]) => {
+ expect([property, light.get(property)]).toEqual([
+ property,
+ defaultAppearance[key as keyof typeof defaultAppearance].replace(/\s+/g, ' '),
+ ]);
+ });
+ });
+
+ it.each([
+ ['light', false],
+ ['dark', true],
+ ])('declares every brand color with the registry default in %s', (_mode, isDark) => {
+ Object.entries(defaultBrands).forEach(([token, value]) => {
+ expect([token, resolve(`--${token}`, isDark)?.toLowerCase()]).toEqual([
+ token,
+ value.toLowerCase(),
+ ]);
+ });
+ });
+});
diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.ts
index c6308f1f2c..14d8d6c664 100644
--- a/packages/client/src/theme/semanticTokens.spec.ts
+++ b/packages/client/src/theme/semanticTokens.spec.ts
@@ -71,39 +71,30 @@ describe('shared component color guardrail', () => {
describe('dark dialog surface', () => {
it('matches the legacy rendered background in CSS and the runtime theme', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- expect(appStyles).toMatch(/--gray-875:\s*18 18 18;/);
- expect(appStyles).toMatch(/--surface-dialog:\s*var\(--gray-875\);/);
+ expect(stockStyles).toMatch(/--gray-875:\s*18 18 18;/);
+ expect(stockStyles).toMatch(/--surface-dialog:\s*var\(--gray-875\);/);
expect(darkTheme['rgb-surface-dialog']).toBe('18 18 18');
});
});
describe('dark hover surface', () => {
it('uses the gray-650 midpoint in both CSS and the runtime theme', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- expect(appStyles).toMatch(/--gray-650:\s*57 57 57;/);
- expect(appStyles).toMatch(/--surface-hover:\s*var\(--gray-650\);/);
+ expect(stockStyles).toMatch(/--gray-650:\s*57 57 57;/);
+ expect(stockStyles).toMatch(/--surface-hover:\s*var\(--gray-650\);/);
expect(darkTheme['rgb-surface-hover']).toBe('57 57 57');
});
});
describe('composer hover surface', () => {
it('keeps light hover unchanged and uses the lighter dark hover surface', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- expect(appStyles).toMatch(/--surface-composer-hover:\s*var\(--gray-200\);/);
- expect(appStyles).toMatch(/--surface-composer-hover:\s*var\(--gray-600\);/);
+ expect(stockStyles).toMatch(/--surface-composer-hover:\s*var\(--gray-200\);/);
+ expect(stockStyles).toMatch(/--surface-composer-hover:\s*var\(--gray-600\);/);
expect(defaultTheme['rgb-surface-composer-hover']).toBe('227 227 227');
expect(darkTheme['rgb-surface-composer-hover']).toBe('66 66 66');
});
@@ -111,12 +102,9 @@ describe('composer hover surface', () => {
describe('dark destructive text', () => {
it('uses red-400 without changing the status error token', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- expect(appStyles).toMatch(/--text-destructive:\s*var\(--red-400\);/);
+ expect(stockStyles).toMatch(/--text-destructive:\s*var\(--red-400\);/);
expect(darkTheme['rgb-text-destructive']).toBe('248 113 113');
expect(darkTheme['rgb-status-error']).toBe('252 165 165');
});
@@ -307,15 +295,12 @@ describe('categorical series scale', () => {
});
});
- it('keeps the app CSS defaults in step with the runtime themes', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS defaults in step with the runtime themes', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
seriesTokens.forEach((token) => {
const property = token.slice(4);
- const declared = [...appStyles.matchAll(new RegExp(`--${property}:\\s*([^;]+);`, 'g'))].map(
+ const declared = [...stockStyles.matchAll(new RegExp(`--${property}:\\s*([^;]+);`, 'g'))].map(
(match) => match[1].trim(),
);
@@ -446,14 +431,11 @@ describe.each([
describe('success fill defaults', () => {
/** Both copies have to move together: the value is a tuned hex rather than a
* palette step, so the stylesheet cannot alias it to a `--green-*` step. */
- it('keeps the app CSS in step with the runtime themes', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS in step with the runtime themes', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- const declared = [...appStyles.matchAll(/--status-success-strong:\s*([^;]+);/g)].map((match) =>
- match[1].trim(),
+ const declared = [...stockStyles.matchAll(/--status-success-strong:\s*([^;]+);/g)].map(
+ (match) => match[1].trim(),
);
/** One declaration for `html`, one for `.dark`, and both must match. */
@@ -509,13 +491,10 @@ describe.each([
describe('verified fill defaults', () => {
/** Tuned values rather than palette steps in either mode, so the stylesheet
* cannot alias them to a `--blue-*` step and both copies move together. */
- it('keeps the app CSS in step with the runtime themes', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS in step with the runtime themes', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- const declared = [...appStyles.matchAll(/--status-verified:\s*([^;]+);/g)].map((match) =>
+ const declared = [...stockStyles.matchAll(/--status-verified:\s*([^;]+);/g)].map((match) =>
match[1].trim(),
);
@@ -555,13 +534,10 @@ describe('switch track defaults', () => {
/** The app stylesheet only restates the registry now: the contrast modes used
* to carry their own `html.high-contrast` overrides here, which the published
* package never shipped. */
- it('keeps the app CSS in step with the runtime themes', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS in step with the runtime themes', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
- const declared = [...appStyles.matchAll(/--switch-unchecked:\s*([^;]+);/g)].map((match) =>
+ const declared = [...stockStyles.matchAll(/--switch-unchecked:\s*([^;]+);/g)].map((match) =>
match[1].trim(),
);
@@ -587,15 +563,12 @@ describe('syntax highlighting palette', () => {
});
});
- it('keeps the app CSS defaults in step with the runtime themes', () => {
- const appStyles = readFileSync(
- join(__dirname, '..', '..', '..', '..', 'client', 'src', 'style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS defaults in step with the runtime themes', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
syntaxTokens.forEach((token) => {
const property = token.slice(4);
- const declared = [...appStyles.matchAll(new RegExp(`--${property}:\\s*([^;]+);`, 'g'))].map(
+ const declared = [...stockStyles.matchAll(new RegExp(`--${property}:\\s*([^;]+);`, 'g'))].map(
(match) => match[1].trim(),
);
@@ -640,20 +613,6 @@ describe.each([
});
});
-describe('control border defaults', () => {
- /** The app stylesheet does not declare this role; the package does, so the
- * stock palette has an outline before and without a theme definition. */
- it('keeps the package CSS in step with the runtime themes', () => {
- const controls = readFileSync(join(__dirname, 'controls.css'), 'utf8');
- const declared = [...controls.matchAll(/--border-control:\s*([^;]+);/g)].map((match) =>
- match[1].trim(),
- );
-
- /** One declaration for `html`, one for `.dark`, and both must match. */
- expect(declared).toEqual([defaultTheme['rgb-border-control'], darkTheme['rgb-border-control']]);
- });
-});
-
/** WCAG 2.4.13 holds a focus indicator to 3:1 against what it is drawn on. The
* global outline and the primitives' ring are theme roles, so every bundled
* palette carries both at that floor on its canvases. */
@@ -692,15 +651,6 @@ describe('focus role defaults', () => {
darkTheme['rgb-text-primary'],
]);
});
-
- it('keeps the package CSS in step with the runtime themes', () => {
- const controls = readFileSync(join(__dirname, 'controls.css'), 'utf8');
- const declared = [...controls.matchAll(/--focus-control:\s*([^;]+);/g)].map((match) =>
- match[1].trim(),
- );
-
- expect(declared).toEqual([defaultTheme['rgb-focus-control'], darkTheme['rgb-focus-control']]);
- });
});
describe('state role defaults', () => {
@@ -715,25 +665,6 @@ describe('state role defaults', () => {
expect(theme['rgb-surface-pressed']).toBe(theme['rgb-surface-hover']);
expect(theme['rgb-surface-inverted-pressed']).toBe(theme['rgb-surface-inverted-hover']);
});
-
- it('keeps the package CSS in step with the runtime themes', () => {
- const controls = readFileSync(join(__dirname, 'controls.css'), 'utf8');
- const roles = [
- 'rgb-surface-pressed',
- 'rgb-surface-inverted-pressed',
- 'rgb-surface-disabled',
- 'rgb-text-disabled',
- 'rgb-border-disabled',
- ] as const;
-
- roles.forEach((role) => {
- const declared = [
- ...controls.matchAll(new RegExp(`--${role.slice(4)}:\\s*([^;]+);`, 'g')),
- ].map((match) => match[1].trim());
-
- expect(declared).toEqual([defaultTheme[role], darkTheme[role]]);
- });
- });
});
/**
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 886ad1021d..dea1604ab1 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -178,21 +178,18 @@ describe('LibreChat Tailwind preset', () => {
expect(packageJson.exports['./tailwind-preset']).toBe('./tailwind.preset.cjs');
});
- it('keeps application CSS defaults aligned with the appearance registry', () => {
- const applicationStyles = fs.readFileSync(
- path.resolve(__dirname, '../../../../client/src/style.css'),
- 'utf8',
- );
+ it('keeps the stock CSS defaults aligned with the appearance registry', () => {
+ const stockStyles = fs.readFileSync(path.resolve(__dirname, 'defaults.css'), 'utf8');
/** Prettier wraps a long font stack, so declarations compare with whitespace collapsed. */
- const collapsed = applicationStyles.replace(/\s+/g, ' ');
+ const collapsed = stockStyles.replace(/\s+/g, ' ');
Object.entries(themeAppearanceProperties).forEach(([key, property]) => {
expect(collapsed).toContain(`${property}: ${defaultAppearance[key]};`);
});
});
});
-describe('application radius, font and shadow scales', () => {
+describe('radius, font and shadow scales', () => {
const scale = [
['rounded-sm', '--theme-radius-sm', 'radiusSm'],
['rounded-md', '--theme-radius-md', 'radiusMd'],
@@ -254,6 +251,39 @@ describe('application radius, font and shadow scales', () => {
);
});
+ /** The app and the library compile the same `tokens.css`, so every scale utility, and every
+ * color role, must come out of both entries as the same declarations. */
+ it('publishes the same scale and color utilities the application compiles', async () => {
+ const tokens = fs.readFileSync(path.resolve(__dirname, 'tokens.css'), 'utf8');
+ const colors = Array.from(tokens.matchAll(/--color-([\w-]+):/g), (match) => `bg-${match[1]}`);
+ const candidates = [
+ 'rounded',
+ ...scale.map(([candidate]) => candidate),
+ 'font-sans',
+ 'font-mono',
+ 'shadow',
+ ...shadows.map(([candidate]) => candidate),
+ 'rounded-theme-control',
+ 'font-theme-ui',
+ 'shadow-theme-surface',
+ ...colors,
+ ];
+ const [application, library] = await Promise.all([
+ generateApplication(candidates),
+ generate(candidates),
+ ]);
+
+ candidates.forEach((candidate) => {
+ expect(rule(library, candidate)).toBeDefined();
+ expect([candidate, rule(library, candidate)]).toEqual([
+ candidate,
+ rule(application, candidate),
+ ]);
+ });
+ /** `rounded-sm` is the step the preset used to pin to 0.125rem for consumers. */
+ expect(rule(library, 'rounded-sm')).toBe('border-radius: var(--theme-radius-sm);');
+ });
+
it('defaults to the values the utilities resolved to before the remap', () => {
/** `sm`, `md` and `lg` were `calc(var(--radius) - 4px)`, `calc(var(--radius) - 2px)` and
* `var(--radius)` over `--radius: 0.5rem`. The px offsets stay, so the corners match at
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index e5fddf6aee..f7448dca3a 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -5,15 +5,18 @@
* rewrites at runtime, which is what `@theme inline` is for: the value is inlined into each
* utility instead of being frozen into a `--color-*` variable, so switching a theme
* re-colors the app without regenerating CSS. Those properties hold bare `R G B` triplets
- * (see client/src/style.css), hence the `rgb()` wrapper; a token with an intrinsic alpha
+ * (see `defaults.css`), hence the `rgb()` wrapper; a token with an intrinsic alpha
* multiplies in its companion `--x-alpha` property, and Tailwind composes any `/50`
* modifier on top through color-mix.
*
- * client/src/style.css imports this file, and `@librechat/client/theme.css` publishes it.
+ * client/src/style.css imports this file, and `@librechat/client/theme.css` publishes it, with the
+ * stock value of every property it reads (`defaults.css`, imported below).
* Declaring a token here is what makes `bg-<token>` exist; @shadcn/lint reads these
* declarations, so a name that is not here is reported rather than silently rendering
* nothing.
*/
+@import './defaults.css';
+
@theme inline {
/* brand and surfaces */
--color-brand-purple: rgb(var(--brand-purple));
@@ -129,10 +132,47 @@
--color-switch-unchecked: rgb(var(--switch-unchecked));
}
-/* The display family the shared dialog titles compose as `font-display`. A
- * theme definition paints `--theme-display-font-family`; without one a title
- * keeps the family it inherits, so a consumer that never sets the role sees no
- * change. */
+/* The plain radius, font, type scale and shadow utilities read theme-owned properties, so a theme
+ * definition reshapes the existing `rounded-*`, `font-sans`, `font-mono`, `text-*` and `shadow-*`
+ * call sites without a migration, in the app and in a consumer alike. The defaults in `defaults.css` reproduce the scale
+ * the app's utilities resolved to before. Bare `rounded` stays Tailwind's fixed 0.25rem: `sm` keeps
+ * its px offset, so the two part at a non-16px root. Bare `shadow` reads `--shadow`, which has
+ * always equalled `sm`, and follows it. A shadow held in a variable cannot be recolored by a
+ * `shadow-<color>` modifier; nothing in the app or the package uses one. */
+@theme inline {
+ --radius-sm: var(--theme-radius-sm);
+ --radius-md: var(--theme-radius-md);
+ --radius-lg: var(--theme-radius-lg);
+ --radius-xl: var(--theme-radius-xl);
+ --radius-2xl: var(--theme-radius-2xl);
+ --radius-3xl: var(--theme-radius-3xl);
+ --font-sans: var(--theme-font-family);
+ --font-mono: var(--theme-mono-font-family);
+ --text-xs: var(--theme-text-xs);
+ --text-xs--line-height: var(--theme-text-xs-leading);
+ --text-sm: var(--theme-text-sm);
+ --text-sm--line-height: var(--theme-text-sm-leading);
+ --text-base: var(--theme-text-base);
+ --text-base--line-height: var(--theme-text-base-leading);
+ --text-lg: var(--theme-text-lg);
+ --text-lg--line-height: var(--theme-text-lg-leading);
+ --text-xl: var(--theme-text-xl);
+ --text-xl--line-height: var(--theme-text-xl-leading);
+ --text-2xl: var(--theme-text-2xl);
+ --text-2xl--line-height: var(--theme-text-2xl-leading);
+ --shadow: var(--theme-shadow-sm);
+ --shadow-2xs: var(--theme-shadow-2xs);
+ --shadow-xs: var(--theme-shadow-xs);
+ --shadow-sm: var(--theme-shadow-sm);
+ --shadow-md: var(--theme-shadow-md);
+ --shadow-lg: var(--theme-shadow-lg);
+ --shadow-xl: var(--theme-shadow-xl);
+ --shadow-2xl: var(--theme-shadow-2xl);
+}
+
+/* The display family the shared dialog titles compose as `font-display`.
+ * `defaults.css` sets it to the stock family and a theme definition repaints
+ * it; a host that unsets it lets a title keep the family it inherits. */
@theme inline {
--font-display: var(--theme-display-font-family, inherit);
}
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index fe6c9545d7..903bbbd716 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -47,22 +47,12 @@ module.exports = {
'accordion-up': 'accordion-up 0.2s ease-out',
'caret-blink': 'caret-blink 1.25s ease-out infinite',
},
+ /**
+ * `rounded-sm` through `rounded-3xl` are not restated here: `@librechat/client/theme.css`
+ * maps them onto `--theme-radius-*` as `@theme inline`, the same declarations the app
+ * compiles, so a consumer's corners are the app's and follow the same theme.
+ */
borderRadius: {
- /**
- * Tailwind 4 renamed the radius steps: the old `sm` (0.125rem) is now
- * `xs`, and `sm` means 0.25rem. Every published primitive that says
- * `rounded-sm` — the checkbox, the menu items, the resize grips — would
- * double its corners for a consumer who upgrades Tailwind under it, so
- * the three named steps are pinned to what this preset produced before.
- * The fallbacks stay in `rem`, and so does what is subtracted from
- * them: mixing in `px` would only reproduce the old scale at a 16px
- * root font size, and `sm` would go negative below it. Setting
- * `--radius` retunes all three; the SPA sets 0.5rem and restates the
- * same family in its own config, so nothing there moves either.
- */
- lg: 'var(--radius, 0.5rem)',
- md: 'calc(var(--radius, 0.5rem) - 0.125rem)',
- sm: 'calc(var(--radius, 0.5rem) - 0.375rem)',
'theme-control': 'var(--theme-control-radius, 0.75rem)',
'theme-control-round': 'var(--theme-round-control-radius, 9999px)',
'theme-surface': 'var(--theme-surface-radius, 1rem)',
diff --git a/packages/client/tsdown.config.mjs b/packages/client/tsdown.config.mjs
index aa453a80f3..adc14f6eb6 100644
--- a/packages/client/tsdown.config.mjs
+++ b/packages/client/tsdown.config.mjs
@@ -29,8 +29,10 @@ export default defineConfig({
// stylesheet that imports Tailwind, and gets `bg-surface-primary` and the rest. `to` names
// the destination directory, not the file, pointing it at `dist/theme.css` produced a
// directory of that name holding `tokens.css`, and the export resolved to a folder, so the
- // file keeps its name in `dist` and the export maps `./theme.css` onto it.
+ // file keeps its name in `dist` and the export maps `./theme.css` onto it. It imports the stock
+ // values beside it by relative path, so the two ship side by side.
{ from: 'src/theme/tokens.css', to: 'dist' },
+ { from: 'src/theme/defaults.css', to: 'dist' },
],
// Extract all component CSS into a single `dist/style.css` (no import left in the JS, so the
// CJS output stays valid CommonJS). Consumers import `@librechat/client/style.css` once.