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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🔠 feat: Add 10, 11, 13 and 15px Steps to the Theme Type Scale (#16827)
Marco Beretta8b9a7c521d86
diff --git a/client/src/utils/cn.ts b/client/src/utils/cn.tsindex de809354c8..0967abe9f6 100644--- a/client/src/utils/cn.ts+++ b/client/src/utils/cn.ts@@ -1,5 +1,10 @@-import { twMerge } from 'tailwind-merge';import { type ClassValue, clsx } from 'clsx';+import { extendTailwindMerge } from 'tailwind-merge';++/** Mirrors `TYPE_STEPS` in `@librechat/client`; imported values there are mocked away in specs. */+const twMerge = extendTailwindMerge({+ extend: { classGroups: { 'font-size': [{ text: ['3xs', '2xs', '1xs', '1sm'] }] } },+});/*** Merges the tailwind clases (using twMerge). Conditionally removes false valuesdiff --git a/e2e/specs/mock/scenarios/type-steps.spec.ts b/e2e/specs/mock/scenarios/type-steps.spec.tsnew file mode 100644index 0000000000..766b939b71--- /dev/null+++ b/e2e/specs/mock/scenarios/type-steps.spec.ts@@ -0,0 +1,110 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';+import { NEW_CHAT_PATH } from '../helpers';++/**+ * The 10, 11, 13 and 15px steps of the type scale. Tailwind emits a `text-*` utility only for a+ * class some source file uses, and no call site uses these yet, so the probes read the theme role+ * variables the utilities are wired to (`--text-3xs: var(--theme-text-3xs)`) through a font size.+ */++type Mode = 'light' | 'dark';+type Sizes = Record<'3xs' | '2xs' | '1xs' | '1sm', string>;++const DEFAULT_SIZES: Sizes = { '3xs': '10px', '2xs': '11px', '1xs': '13px', '1sm': '15px' };++const REFERENCE_THEME = {+ version: 1,+ name: 'e2e-type-steps',+ modes: {+ light: {+ appearance: {+ text3xs: '0.5rem',+ text2xs: '0.5625rem',+ text1xs: '0.875rem',+ text1sm: '1rem',+ },+ },+ },+} as const;++async function openChat(page: Page, mode: Mode, definition?: { name: string }) {+ await page.addInitScript(+ ([appearance, stored]) => {+ localStorage.setItem('color-theme', appearance as string);+ localStorage.removeItem('theme-colors');+ localStorage.removeItem('theme-name');+ if (stored) {+ localStorage.setItem('theme-definition', JSON.stringify(stored));+ localStorage.setItem('theme-source', 'definition');+ } else {+ localStorage.removeItem('theme-definition');+ localStorage.removeItem('theme-source');+ }+ },+ [mode, definition ?? null] as [string, unknown],+ );+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({+ timeout: 30000,+ });+}++/** Sizes a probe with each step's role variable and reads what the browser computed. */+async function measure(page: Page) {+ return page.evaluate((steps) => {+ return Object.fromEntries(+ steps.map((step) => {+ const node = document.createElement('p');+ node.style.fontSize = `var(--theme-text-${step})`;+ node.textContent = 'Type probe';+ document.body.append(node);+ const size = getComputedStyle(node).fontSize;+ node.remove();+ return [step, size];+ }),+ );+ }, Object.keys(DEFAULT_SIZES));+}++const CASES: Array<{+ title: string;+ mode: Mode;+ definition?: { name: string };+ sizes: Sizes;+}> = [+ {+ title:+ 'the default theme sizes the 10, 11, 13 and 15px steps exactly @scenario:type-steps-default-exact',+ mode: 'light',+ sizes: DEFAULT_SIZES,+ },+ {+ title:+ 'the ClickHouse dark theme keeps the default sizes for the off-scale steps @scenario:type-steps-clickhouse-unchanged',+ mode: 'dark',+ definition: clickHouseTheme,+ sizes: DEFAULT_SIZES,+ },+ {+ title:+ 'a theme that names the step roles resizes the steps @scenario:type-steps-follow-reference-theme',+ mode: 'light',+ definition: REFERENCE_THEME,+ sizes: { '3xs': '8px', '2xs': '9px', '1xs': '14px', '1sm': '16px' },+ },+];++test.describe('off-scale type steps', () => {+ for (const { title, mode, definition, sizes } of CASES) {+ test(title, async ({ page }) => {+ await openChat(page, mode, definition);+ const metrics = await measure(page);++ for (const [step, size] of Object.entries(sizes)) {+ expect(metrics[step]).toBe(size);+ }+ });+ }+});diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex 2c23ec6def..bfe9de15b4 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -434,6 +434,7 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a`font-theme-dialog-title` (`dialogTitleFontFamily`). The title size and familyfollow `textLg` and `displayFontFamily` when a theme omits them, and a caller'sown padding, size or weight class replaces the role.+- `text-3xs`, `text-2xs`, `text-1xs`, `text-1sm` - The 10, 11, 13 and 15px steps (`text3xs`, `text2xs`, `text1xs`, `text1sm`); they set a size only, never a line height.- `text-xs` to `text-2xl` - Sizes and line heights read `textXs`..`text2xl` and`leadingXs`..`leading2xl`, in the app and in a consumer alike; the defaults areTailwind's own values.diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex e92392bdf3..d4d145cc46 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -310,6 +310,10 @@ html {--theme-text-xl: 1.25rem;--theme-text-xl-leading: calc(1.75 / 1.25);--theme-text-2xl: 1.5rem;+ --theme-text-3xs: 0.625rem;+ --theme-text-2xs: 0.6875rem;+ --theme-text-1xs: 0.8125rem;+ --theme-text-1sm: 0.9375rem;--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 itdiff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.tsindex f937ea9974..2d5f9c283c 100644--- a/packages/client/src/theme/registry.ts+++ b/packages/client/src/theme/registry.ts@@ -272,6 +272,10 @@ export const themeAppearanceProperties: Readonly<textLg: '--theme-text-lg',textXl: '--theme-text-xl',text2xl: '--theme-text-2xl',+ text3xs: '--theme-text-3xs',+ text2xs: '--theme-text-2xs',+ text1xs: '--theme-text-1xs',+ text1sm: '--theme-text-1sm',leadingXs: '--theme-text-xs-leading',leadingSm: '--theme-text-sm-leading',leadingBase: '--theme-text-base-leading',@@ -370,6 +374,10 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({textLg: '1.125rem',textXl: '1.25rem',text2xl: '1.5rem',+ text3xs: '0.625rem',+ text2xs: '0.6875rem',+ text1xs: '0.8125rem',+ text1sm: '0.9375rem',leadingXs: 'calc(1 / 0.75)',leadingSm: 'calc(1.25 / 0.875)',leadingBase: 'calc(1.5 / 1)',diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.cssindex 0b4a7405ff..7e41010148 100644--- a/packages/client/src/theme/tokens.css+++ b/packages/client/src/theme/tokens.css@@ -230,6 +230,10 @@--text-xl--line-height: var(--theme-text-xl-leading);--text-2xl: var(--theme-text-2xl);--text-2xl--line-height: var(--theme-text-2xl-leading);+ --text-3xs: var(--theme-text-3xs);+ --text-2xs: var(--theme-text-2xs);+ --text-1xs: var(--theme-text-1xs);+ --text-1sm: var(--theme-text-1sm);--shadow: var(--theme-shadow-sm);--shadow-2xs: var(--theme-shadow-2xs);--shadow-xs: var(--theme-shadow-xs);diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.tsindex 5f1ba66388..86d23988f2 100644--- a/packages/client/src/theme/types/index.ts+++ b/packages/client/src/theme/types/index.ts@@ -677,6 +677,11 @@ export interface IThemeAppearance {textLg: string;textXl: string;text2xl: string;+ /** Sizes between and below the scale (10, 11, 13 and 15px) that carry no line height of their own. */+ text3xs: string;+ text2xs: string;+ text1xs: string;+ text1sm: string;leadingXs: string;leadingSm: string;leadingBase: string;diff --git a/packages/client/src/utils/utils.spec.ts b/packages/client/src/utils/utils.spec.tsindex 72d9da0b65..9cac8b3bb8 100644--- a/packages/client/src/utils/utils.spec.ts+++ b/packages/client/src/utils/utils.spec.ts@@ -15,4 +15,13 @@ describe('cn', () => {])('lets a caller size replace %s', (role, caller) => {expect(cn(role, caller)).toBe(caller);});++ it.each(['3xs', '2xs', '1xs', '1sm'])('keeps a color beside text-%s', (step) => {+ expect(cn('text-text-primary', `text-${step}`)).toBe(`text-text-primary text-${step}`);+ });++ it('lets a caller size replace an off-scale step', () => {+ expect(cn('text-2xs', 'text-sm')).toBe('text-sm');+ expect(cn('text-sm', 'text-1xs')).toBe('text-1xs');+ });});diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.tsindex 486081019c..4441c5398f 100644--- a/packages/client/src/utils/utils.ts+++ b/packages/client/src/utils/utils.ts@@ -2,6 +2,9 @@import { type ClassValue, clsx } from 'clsx';import { extendTailwindMerge } from 'tailwind-merge';+/** `text-*` steps off Tailwind's scale; unregistered, twMerge reads them as colors and drops a real one. */+export const TYPE_STEPS = ['3xs', '2xs', '1xs', '1sm'] as const;+/*** Theme utilities whose names Tailwind Merge cannot classify, registered so a caller's own* padding or height still replaces the primitive's default instead of both surviving@@ -59,6 +62,7 @@ const twMerge = extendTailwindMerge({'space-y': [{ 'space-y': ['theme-dialog-header'] }],'font-weight': [{ font: ['theme-control', 'theme-dialog-title-weight', 'theme-label'] }],'font-family': [{ font: ['theme-dialog-title'] }],+ 'font-size': [{ text: [...TYPE_STEPS] }],},},});diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex 047fd7af61..3c7c7b970f 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -452,6 +452,10 @@ const appearanceValidators = {textLg: isLength,textXl: isLength,text2xl: isLength,+ text3xs: isLength,+ text2xs: isLength,+ text1xs: isLength,+ text1sm: isLength,leadingXs: isLineHeight,leadingSm: isLineHeight,leadingBase: isLineHeight,