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

🌫️ feat: Shadow Scale Follows the Theme (#16341)

Marco Beretta33871c39be0d
diff --git a/client/src/style.css b/client/src/style.css
index a1fdc45b70..e939a7ee24 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -11,11 +11,13 @@
--color-green-*: initial;
}
-/* The plain radius and font utilities read theme-owned properties, so a theme definition reshapes
- * the 900-odd `rounded-*`, `font-sans` and `font-mono` 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. App-only: the published preset keeps its own `sm`, which differs from this
+/* The plain radius, font and shadow utilities read theme-owned properties, so a theme definition
+ * reshapes the existing `rounded-*`, `font-sans`, `font-mono` 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);
@@ -26,6 +28,14 @@
--radius-3xl: var(--theme-radius-3xl);
--font-sans: var(--theme-font-family);
--font-mono: var(--theme-mono-font-family);
+ --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
@@ -321,6 +331,13 @@ html {
'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;
diff --git a/e2e/specs/mock/scenarios/theme-shadow-scale.spec.ts b/e2e/specs/mock/scenarios/theme-shadow-scale.spec.ts
new file mode 100644
index 0000000000..221078c38c
--- /dev/null
+++ b/e2e/specs/mock/scenarios/theme-shadow-scale.spec.ts
@@ -0,0 +1,148 @@
+import { expect, test } from '@playwright/test';
+import type { Locator, Page } from '@playwright/test';
+import { NEW_CHAT_PATH } from '../helpers';
+import { probeStyle } from './style.helpers';
+
+/**
+ * The plain `shadow-*` utilities read `--theme-shadow-*`, so a theme's appearance reshapes the
+ * existing call sites. The mention menu carries `shadow-lg` and opens from the composer, which
+ * makes it the shortest path to a real element on that scale. Every theme here pins light mode
+ * so the desktop-dark project cannot pick a mode the definition does not carry.
+ */
+test.describe.configure({ timeout: 120_000 });
+
+const DEFAULT_LG = 'rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.1) 0px 4px 6px -4px';
+
+async function storeTheme(page: Page, definition: Record<string, unknown>) {
+ await page.addInitScript((theme) => {
+ localStorage.setItem('color-theme', 'light');
+ localStorage.setItem('theme-definition', JSON.stringify(theme));
+ localStorage.setItem('theme-source', 'definition');
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ }, definition);
+}
+
+async function openMentionMenu(page: Page): Promise<Locator> {
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ const composer = page.getByRole('textbox', { name: 'Message input' });
+ await expect(composer).toBeVisible({ timeout: 30000 });
+ await composer.click();
+ await composer.pressSequentially('@');
+ const search = page.getByPlaceholder('Mention an endpoint');
+ await expect(search).toBeVisible({ timeout: 15000 });
+ const menu = page.locator('div.popover').filter({ has: search });
+ await expect(menu).toBeVisible();
+ return menu;
+}
+
+const boxShadow = (element: Locator) =>
+ element.evaluate((node) => getComputedStyle(node).boxShadow);
+
+test.describe('theme shadow scale', () => {
+ test('the mention menu keeps its default large shadow without a theme @scenario:mention-menu-keeps-default-large-shadow', async ({
+ page,
+ }) => {
+ const menu = await openMentionMenu(page);
+
+ expect(await boxShadow(menu)).toContain(DEFAULT_LG);
+ });
+
+ test('a theme shadow step reshapes the mention menu @scenario:theme-shadow-step-reshapes-mention-menu', async ({
+ page,
+ }) => {
+ const theme = {
+ version: 1,
+ name: 'e2e-shadow-scale',
+ modes: { light: { appearance: { shadowLg: '0 8px 16px rgb(9 240 120)' } } },
+ };
+ await storeTheme(page, theme);
+
+ const menu = await openMentionMenu(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', theme.name);
+
+ await expect.poll(() => boxShadow(menu)).toContain('rgb(9, 240, 120) 0px 8px 16px 0px');
+ expect(await boxShadow(menu)).not.toContain(DEFAULT_LG);
+ });
+
+ test('a disabled shadow step keeps a ring on the same element @scenario:disabled-shadow-step-keeps-ring', async ({
+ page,
+ }) => {
+ const theme = {
+ version: 1,
+ name: 'e2e-flat-shadows',
+ modes: { light: { appearance: { shadow2xl: 'none' } } },
+ };
+ await storeTheme(page, theme);
+
+ await openMentionMenu(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', theme.name);
+
+ /** Tailwind lists the shadow after the ring layers; a bare `none` there would void both. */
+ const composed = await probeStyle(page, 'shadow-2xl ring-2', 'box-shadow');
+ expect(composed).not.toBe('none');
+ expect(composed).toContain('0px 0px 0px 2px');
+ expect(composed).not.toContain('25px 50px');
+ });
+
+ test('a theme with a malformed shadow is rejected and the default shadow stays @scenario:malformed-shadow-theme-keeps-default-shadow', async ({
+ page,
+ }) => {
+ const theme = {
+ version: 1,
+ name: 'e2e-malformed-shadow',
+ /** Well formed but for the color, which only the browser's own parser can reject. */
+ modes: { light: { appearance: { shadowLg: '0 8px 16px not-a-color' } } },
+ };
+ await storeTheme(page, theme);
+
+ const menu = await openMentionMenu(page);
+
+ await expect(page.locator('html')).not.toHaveAttribute('data-theme', theme.name);
+ expect(await boxShadow(menu)).toContain(DEFAULT_LG);
+ });
+
+ test('a shadow step naming an unknown environment variable is rejected and the default stays @scenario:env-shadow-step-keeps-default-shadow', async ({
+ page,
+ }) => {
+ const theme = {
+ version: 1,
+ name: 'e2e-env-shadow',
+ /** The browser cannot check `env()` before substitution, and this name does not exist. */
+ modes: { light: { appearance: { shadowLg: '0 env(safe-area-inset-tpo) 1px black' } } },
+ };
+ await storeTheme(page, theme);
+
+ const menu = await openMentionMenu(page);
+
+ await expect(page.locator('html')).not.toHaveAttribute('data-theme', theme.name);
+ expect(await boxShadow(menu)).toContain(DEFAULT_LG);
+ });
+
+ test('a released theme with a variable-backed surface elevation still loads @scenario:variable-surface-elevation-theme-still-loads', async ({
+ page,
+ }) => {
+ const theme = {
+ version: 1,
+ name: 'e2e-variable-elevation',
+ modes: {
+ light: { appearance: { elevationSurface: '0 8px 16px rgb(var(--e2e-shadow, 9 240 120))' } },
+ },
+ };
+ await storeTheme(page, theme);
+
+ await openMentionMenu(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', theme.name);
+
+ /** No app call site uses `shadow-theme-surface`, so the probe reads the role's property. */
+ const surface = await page.evaluate(() => {
+ const probe = document.createElement('div');
+ probe.style.boxShadow = 'var(--theme-elevation-surface)';
+ document.body.append(probe);
+ const value = getComputedStyle(probe).boxShadow;
+ probe.remove();
+ return value;
+ });
+ expect(surface).toContain('rgb(9, 240, 120) 0px 8px 16px 0px');
+ });
+});
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 0fb4a799dd..cf785bf3d0 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -27,14 +27,22 @@ const compactTheme: ThemeDefinition = {
```
The appearance registry covers shared control shape, surface shape, control height, compact/normal
-spacing, UI and code typography, surface elevation, fast/normal motion, and the radius scale.
+spacing, UI and code typography, surface elevation, fast/normal motion, and the radius and shadow
+scales.
In the LibreChat app the plain Tailwind utilities read theme-owned properties, so a theme reshapes
existing call sites without a migration: `rounded-sm` through `rounded-3xl` read `radiusSm`
through `radius3xl` (`--theme-radius-*`), `font-sans` reads `fontFamily` (`--theme-font-family`),
-and `font-mono` reads `monoFontFamily` (`--theme-mono-font-family`). 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`.
+`font-mono` reads `monoFontFamily` (`--theme-mono-font-family`), and `shadow-2xs` through
+`shadow-2xl` (and bare `shadow`, which matches `sm`) read `shadow2xs` through `shadow2xl`
+(`--theme-shadow-*`). A shadow step must be a concrete `box-shadow` list (no `var()`, `env()` or
+`attr()`) or `none`. `elevationSurface` stays the separate role behind `shadow-theme-surface` and
+keeps its original validation, so a released theme holding `var()` there still loads. On every
+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`.
`themeRGB`, `REACT_APP_THEME_*`, and the existing localStorage keys remain supported through legacy
adapters. Theme application removes only variables owned by the theme module when a theme is reset.
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index 05f4792596..f815ec24da 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -488,6 +488,13 @@ describe('theme registry', () => {
},
appearance: {
controlRadius: 'url(theme.css)',
+ shadowLg: '0 1px red; color: red',
+ shadowMd: 'not-a-shadow',
+ shadowXl: '1px red',
+ shadow2xl: 'not-a-shadow var(--missing)',
+ shadowXs: '0,',
+ shadowSm: '0 2px 4px var(--brand-shadow)',
+ shadow2xs: '0 env(safe-area-inset-tpo) 1px black',
unknownSpacing: '1rem',
},
},
@@ -498,6 +505,13 @@ describe('theme registry', () => {
'Invalid RGB value for rgb-text-primary: 999 0 0',
'Unknown color token: rgb-unknown',
'Invalid appearance value for controlRadius: url(theme.css)',
+ 'Invalid appearance value for shadowLg: 0 1px red; color: red',
+ 'Invalid appearance value for shadowMd: not-a-shadow',
+ 'Invalid appearance value for shadowXl: 1px red',
+ 'Invalid appearance value for shadow2xl: not-a-shadow var(--missing)',
+ 'Invalid appearance value for shadowXs: 0,',
+ 'Invalid appearance value for shadowSm: 0 2px 4px var(--brand-shadow)',
+ 'Invalid appearance value for shadow2xs: 0 env(safe-area-inset-tpo) 1px black',
'Unknown appearance token: unknownSpacing',
]);
expect(() => resolveTheme(invalidTheme, 'light')).toThrow(TypeError);
@@ -534,6 +548,46 @@ describe('theme registry', () => {
]);
});
+ it('accepts the box-shadow forms a theme is likely to write', () => {
+ const shadows = [
+ 'none',
+ '0 1px 2px 0 rgb(0 0 0 / 0.05)',
+ 'inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 8px 16px -4px #00000033',
+ '0 calc(0.25rem + 1px) 1ch -0.5vw rgb(0 0 0 / 0.1)',
+ '0 0 #0000',
+ ];
+
+ shadows.forEach((shadowLg) => {
+ expect(
+ validateThemeDefinition({
+ version: 1,
+ name: 'shadows',
+ modes: { light: { appearance: { shadowLg } } },
+ }),
+ ).toEqual([]);
+ });
+ });
+
+ it('keeps accepting variable-backed surface elevation that released themes may hold', () => {
+ const elevationSurface =
+ '0 8px 16px rgb(var(--shadow-rgb) / 0.2), 0 env(safe-area-inset-top) 1px black';
+
+ expect(
+ validateThemeDefinition({
+ version: 1,
+ name: 'elevation',
+ modes: { light: { appearance: { elevationSurface } } },
+ }),
+ ).toEqual([]);
+ expect(
+ validateThemeDefinition({
+ version: 1,
+ name: 'elevation',
+ modes: { light: { appearance: { shadowLg: elevationSurface } } },
+ }),
+ ).toEqual([`Invalid appearance value for shadowLg: ${elevationSurface}`]);
+ });
+
it('sanitizes malformed legacy colors without weakening definition validation', () => {
const legacyTheme = fromLegacyTheme(
{
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index 5d8f8e9c01..966b07dca0 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -65,6 +65,13 @@ export const themeAppearanceProperties: Readonly<
fontFamily: '--theme-font-family',
monoFontFamily: '--theme-mono-font-family',
elevationSurface: '--theme-elevation-surface',
+ shadow2xs: '--theme-shadow-2xs',
+ shadowXs: '--theme-shadow-xs',
+ shadowSm: '--theme-shadow-sm',
+ shadowMd: '--theme-shadow-md',
+ shadowLg: '--theme-shadow-lg',
+ shadowXl: '--theme-shadow-xl',
+ shadow2xl: '--theme-shadow-2xl',
motionFast: '--theme-motion-fast',
motionNormal: '--theme-motion-normal',
});
@@ -87,6 +94,13 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
monoFontFamily:
"'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono', Consolas, monospace",
elevationSurface: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
+ shadow2xs: '0 1px rgb(0 0 0 / 0.05)',
+ shadowXs: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
+ shadowSm: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
+ shadowMd: '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
+ shadowLg: '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
+ shadowXl: '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
+ shadow2xl: '0 25px 50px -12px rgb(0 0 0 / 0.25)',
motionFast: '150ms',
motionNormal: '200ms',
});
@@ -172,6 +186,10 @@ const cssLengthDifferencePattern =
/^calc\(\s*\d*\.?\d+(px|rem|em)\s+[-+]\s+\d*\.?\d+(px|rem|em)\s*\)$/;
const cssDurationPattern = /^\d*\.?\d+(ms|s)$/;
const hexColorPattern = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
+const shadowLengthPattern = /^(-?(0|\d*\.?\d+[a-z]+)|(calc|min|max|clamp)\(.*\))$/i;
+const shadowColorPattern = /^(#[0-9a-f]{3,8}|[a-z]+|[a-z-]+\(.*\))$/i;
+/** Tailwind composes `--tw-shadow` into one list with the ring layers, where `none` is invalid. */
+const disabledShadow = '0 0 #0000';
function isLinearGradient(value: string): boolean {
if (!value.startsWith('linear-gradient(') || /url\s*\(|image-set/i.test(value)) {
@@ -210,6 +228,64 @@ const isLength = (value: unknown): value is string =>
(cssLengthPattern.test(value) || cssLengthDifferencePattern.test(value));
const isFontFamily = (value: unknown): value is string =>
typeof value === 'string' && value.trim().length > 0 && !/[;{}]/.test(value);
+/** Splits on `separator` outside parentheses, so `rgb(0, 0, 0)` stays one part. Empty parts are
+ * kept, so a stray comma stays visible to the caller. */
+function splitTopLevel(value: string, separator: RegExp): string[] {
+ const parts: string[] = [];
+ let depth = 0;
+ let current = '';
+ for (const char of value) {
+ if (char === '(') {
+ depth += 1;
+ } else if (char === ')') {
+ depth -= 1;
+ }
+ if (depth === 0 && separator.test(char)) {
+ parts.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
+ }
+ parts.push(current);
+ return parts.map((part) => part.trim());
+}
+
+/** A named color is indistinguishable from any other word without the browser's color parser. */
+const isShadowColor = (token: string): boolean =>
+ globalThis.CSS?.supports?.('color', token) ?? shadowColorPattern.test(token);
+
+/** One layer: two to four lengths, optionally `inset` and one color, per the box-shadow grammar. */
+function isShadowLayer(layer: string): boolean {
+ const tokens = splitTopLevel(layer, /\s/).filter((token) => token.length > 0);
+ const lengths = tokens.filter((token) => shadowLengthPattern.test(token)).length;
+ const insets = tokens.filter((token) => token.toLowerCase() === 'inset').length;
+ const colors = tokens.filter(
+ (token) => !shadowLengthPattern.test(token) && token.toLowerCase() !== 'inset',
+ );
+ return (
+ lengths >= 2 && lengths <= 4 && insets <= 1 && colors.length <= 1 && colors.every(isShadowColor)
+ );
+}
+
+/**
+ * A shadow must be concrete: a browser defers its check of any value holding `var()`, `env()` or
+ * `attr()` until substitution, so such a value could never be validated before it reaches the
+ * ring layers.
+ */
+const isShadow = (value: unknown): value is string => {
+ if (typeof value !== 'string' || /[;{}]|url\s*\(|(var|env|attr)\s*\(/i.test(value)) {
+ return false;
+ }
+ if (value.trim().toLowerCase() === 'none') {
+ return true;
+ }
+ const layers = splitTopLevel(value, /,/);
+ if (layers.some((layer) => layer.length === 0) || !layers.every(isShadowLayer)) {
+ return false;
+ }
+ return globalThis.CSS?.supports?.('box-shadow', value) ?? true;
+};
const isDuration = (value: unknown): value is string =>
typeof value === 'string' && cssDurationPattern.test(value);
@@ -241,8 +317,16 @@ const appearanceValidators: Record<keyof IThemeAppearance, (value: unknown) => b
spaceNormal: isLength,
fontFamily: isFontFamily,
monoFontFamily: isFontFamily,
+ /** Released themes may hold `var()` here, so this role keeps its original, looser check. */
elevationSurface: (value) =>
typeof value === 'string' && value.trim().length > 0 && !/[;{}]|url\s*\(/i.test(value),
+ shadow2xs: isShadow,
+ shadowXs: isShadow,
+ shadowSm: isShadow,
+ shadowMd: isShadow,
+ shadowLg: isShadow,
+ shadowXl: isShadow,
+ shadow2xl: isShadow,
motionFast: isDuration,
motionNormal: isDuration,
};
@@ -362,19 +446,37 @@ export function validateThemeDefinition(theme: ThemeDefinition): string[] {
}
/**
- * A partial theme promises that an omitted value falls back, and
- * `Partial<IThemeBrands>` lets a key be present with `undefined`. Spreading
- * that would overwrite the inherited brand with nothing, and unlike colors,
- * which `mapColors` skips when undefined, every brand token is written to the
- * DOM unconditionally, so the avatar would lose its fill entirely.
+ * A partial theme promises that an omitted value falls back, and `Partial<T>` lets a key be
+ * present with `undefined`. Spreading that would overwrite the inherited value with nothing:
+ * every brand and appearance token is written to the DOM unconditionally, so an avatar would
+ * lose its fill and a shadow or radius step its value, unlike colors, which `mapColors` skips.
*/
-function definedBrands(brands?: Partial<IThemeBrands>): Partial<IThemeBrands> {
- if (!brands) {
+function definedEntries<T extends object>(values?: Partial<T>): Partial<T> {
+ if (!values) {
return {};
}
return Object.fromEntries(
- Object.entries(brands).filter(([, value]) => value !== undefined),
- ) as Partial<IThemeBrands>;
+ Object.entries(values).filter(([, value]) => value !== undefined),
+ ) as Partial<T>;
+}
+
+const shadowAppearanceKeys: ReadonlyArray<keyof IThemeAppearance> = [
+ 'elevationSurface',
+ 'shadow2xs',
+ 'shadowXs',
+ 'shadowSm',
+ 'shadowMd',
+ 'shadowLg',
+ 'shadowXl',
+ 'shadow2xl',
+];
+
+function withComposableShadows(appearance: IThemeAppearance): IThemeAppearance {
+ return shadowAppearanceKeys.reduce<IThemeAppearance>(
+ (result, key) =>
+ result[key].trim().toLowerCase() === 'none' ? { ...result, [key]: disabledShadow } : result,
+ appearance,
+ );
}
export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedThemeDefinition {
@@ -508,12 +610,15 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...seriesEightFallback,
...verifiedFallback,
} as Required<IThemeRGB>,
- appearance: { ...defaultAppearance, ...definition?.appearance },
+ appearance: withComposableShadows({
+ ...defaultAppearance,
+ ...definedEntries(definition?.appearance),
+ }),
/** Mode last: a mode override is more specific than the theme-wide set. */
brands: {
...defaultBrands,
- ...definedBrands(theme.brands),
- ...definedBrands(definition?.brands),
+ ...definedEntries(theme.brands),
+ ...definedEntries(definition?.brands),
},
};
}
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 26e0573a3b..886ad1021d 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -192,7 +192,7 @@ describe('LibreChat Tailwind preset', () => {
});
});
-describe('application radius and font scales', () => {
+describe('application radius, font and shadow scales', () => {
const scale = [
['rounded-sm', '--theme-radius-sm', 'radiusSm'],
['rounded-md', '--theme-radius-md', 'radiusMd'],
@@ -201,6 +201,15 @@ describe('application radius and font scales', () => {
['rounded-2xl', '--theme-radius-2xl', 'radius2xl'],
['rounded-3xl', '--theme-radius-3xl', 'radius3xl'],
];
+ const shadows = [
+ ['shadow-2xs', '--theme-shadow-2xs', 'shadow2xs', '--shadow-2xs'],
+ ['shadow-xs', '--theme-shadow-xs', 'shadowXs', '--shadow-xs'],
+ ['shadow-sm', '--theme-shadow-sm', 'shadowSm', '--shadow-sm'],
+ ['shadow-md', '--theme-shadow-md', 'shadowMd', '--shadow-md'],
+ ['shadow-lg', '--theme-shadow-lg', 'shadowLg', '--shadow-lg'],
+ ['shadow-xl', '--theme-shadow-xl', 'shadowXl', '--shadow-xl'],
+ ['shadow-2xl', '--theme-shadow-2xl', 'shadow2xl', '--shadow-2xl'],
+ ];
it('routes the plain radius and font utilities through theme-owned properties', async () => {
const css = await generateApplication([
@@ -208,8 +217,11 @@ describe('application radius and font scales', () => {
...scale.map(([candidate]) => candidate),
'font-sans',
'font-mono',
+ 'shadow',
+ ...shadows.map(([candidate]) => candidate),
'rounded-theme-control',
'font-theme-ui',
+ 'shadow-theme-surface',
]);
scale.forEach(([candidate, property]) => {
@@ -220,6 +232,11 @@ describe('application radius and font scales', () => {
expect(rule(css, 'rounded')).toBe('border-radius: 0.25rem;');
expect(rule(css, 'font-sans')).toBe('font-family: var(--theme-font-family);');
expect(rule(css, 'font-mono')).toBe('font-family: var(--theme-mono-font-family);');
+ shadows.forEach(([candidate, property]) => {
+ expect(rule(css, candidate)).toContain(`--tw-shadow: var(${property});`);
+ });
+ /** Bare `shadow` has always matched `sm`, and follows it. */
+ expect(rule(css, 'shadow')).toContain('--tw-shadow: var(--theme-shadow-sm);');
/** Preflight gives `html` and `code` the same families the utilities do. */
expect(css).toContain('--default-font-family: var(--theme-font-family);');
@@ -232,6 +249,9 @@ describe('application radius and font scales', () => {
expect(rule(css, 'font-theme-ui')).toBe(
`font-family: var(--theme-font-family, ${defaultAppearance.fontFamily});`,
);
+ expect(rule(css, 'shadow-theme-surface')).toContain(
+ `--tw-shadow: var(--theme-elevation-surface, ${defaultAppearance.elevationSurface});`,
+ );
});
it('defaults to the values the utilities resolved to before the remap', () => {
@@ -250,5 +270,12 @@ describe('application radius and font scales', () => {
expect(defaultAppearance.monoFontFamily).toBe(
"'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono', Consolas, monospace",
);
+
+ /** The shadow steps were Tailwind's own, read from the installed package. */
+ shadows.forEach(([, , key, variable]) => {
+ expect(defaultAppearance[key]).toBe(tailwindDefault(variable));
+ });
+ /** The surface elevation stays the alias it was, equal to `shadow-lg` by default. */
+ expect(defaultAppearance.elevationSurface).toBe(defaultAppearance.shadowLg);
});
});
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index caed5ad901..5e297eadb0 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -376,6 +376,13 @@ export interface IThemeAppearance {
fontFamily: string;
monoFontFamily: string;
elevationSurface: string;
+ shadow2xs: string;
+ shadowXs: string;
+ shadowSm: string;
+ shadowMd: string;
+ shadowLg: string;
+ shadowXl: string;
+ shadow2xl: string;
motionFast: string;
motionNormal: string;
}
diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.ts
index 8fd038fbe2..3c05b0ee0f 100644
--- a/packages/client/src/theme/utils/applyTheme.spec.ts
+++ b/packages/client/src/theme/utils/applyTheme.spec.ts
@@ -139,7 +139,7 @@ describe('applyTheme', () => {
/** The plain `rounded-*`, `font-sans` and `font-mono` utilities read these properties, so a
* theme reaches every call site only if the adapter writes them and a reset removes them. */
- it('applies and clears the radius scale and the mono family', () => {
+ it('applies and clears the radius and shadow scales and the mono family', () => {
const root = document.documentElement;
const scale = {
radiusSm: ['--theme-radius-sm', '0px'],
@@ -149,6 +149,13 @@ describe('applyTheme', () => {
radius2xl: ['--theme-radius-2xl', '0.75rem'],
radius3xl: ['--theme-radius-3xl', '1rem'],
monoFontFamily: ['--theme-mono-font-family', 'Inconsolata, monospace'],
+ shadow2xs: ['--theme-shadow-2xs', '0 1px rgb(0 0 0 / 0.1)'],
+ shadowXs: ['--theme-shadow-xs', '0 1px 2px rgb(0 0 0 / 0.15)'],
+ shadowSm: ['--theme-shadow-sm', '0 2px 4px rgb(0 0 0 / 0.15)'],
+ shadowMd: ['--theme-shadow-md', '0 4px 8px rgb(0 0 0 / 0.15)'],
+ shadowLg: ['--theme-shadow-lg', '0 8px 16px rgb(0 0 0 / 0.15)'],
+ shadowXl: ['--theme-shadow-xl', '0 12px 24px rgb(0 0 0 / 0.15)'],
+ shadow2xl: ['--theme-shadow-2xl', 'inset 0 0 0 1px rgb(0, 0, 0)'],
} as const;
const appearance = Object.fromEntries(
Object.entries(scale).map(([key, [, value]]) => [key, value]),
@@ -172,6 +179,7 @@ describe('applyTheme', () => {
expect(root.style.getPropertyValue('--theme-mono-font-family')).toBe(
defaultAppearance.monoFontFamily,
);
+ expect(root.style.getPropertyValue('--theme-shadow-lg')).toBe(defaultAppearance.shadowLg);
clearAppliedTheme(root);
Object.values(scale).forEach(([property]) => {
@@ -179,6 +187,49 @@ describe('applyTheme', () => {
});
});
+ /** Tailwind lists `--tw-shadow` after the ring layers, where a bare `none` voids the whole
+ * declaration and takes a focus ring with it, so a disabled step becomes a transparent layer. */
+ it('writes a disabled shadow step as a composable transparent layer', () => {
+ const root = document.documentElement;
+
+ applyResolvedTheme(
+ resolveTheme(
+ {
+ version: 1,
+ name: 'flat',
+ modes: { light: { appearance: { shadow2xl: 'none', elevationSurface: ' NONE ' } } },
+ },
+ 'light',
+ ),
+ root,
+ );
+
+ expect(root.style.getPropertyValue('--theme-shadow-2xl')).toBe('0 0 #0000');
+ expect(root.style.getPropertyValue('--theme-elevation-surface')).toBe('0 0 #0000');
+ expect(root.style.getPropertyValue('--theme-shadow-lg')).toBe(defaultAppearance.shadowLg);
+ clearAppliedTheme(root);
+ });
+
+ it('keeps the default for an appearance key that is present but undefined', () => {
+ const root = document.documentElement;
+
+ applyResolvedTheme(
+ resolveTheme(
+ {
+ version: 1,
+ name: 'sparse',
+ modes: { light: { appearance: { shadowLg: undefined, radiusSm: undefined } } },
+ },
+ 'light',
+ ),
+ root,
+ );
+
+ expect(root.style.getPropertyValue('--theme-shadow-lg')).toBe(defaultAppearance.shadowLg);
+ expect(root.style.getPropertyValue('--theme-radius-sm')).toBe(defaultAppearance.radiusSm);
+ clearAppliedTheme(root);
+ });
+
it('applies the resolved high-contrast code surface instead of the stock grey', () => {
const root = document.documentElement;