= ({
>
{item.icon != null && (
-
+ svg]:size-full', iconClassName)}
+ aria-hidden="true"
+ >
{item.icon}
)}
@@ -174,7 +177,10 @@ const Menu: React.FC = ({
}}
>
{item.icon != null && (
-
+ svg]:size-full', iconClassName)}
+ aria-hidden="true"
+ >
{item.icon}
)}
diff --git a/packages/client/src/components/Input.tsx b/packages/client/src/components/Input.tsx
index d7d9abfa7c..e57d9be873 100644
--- a/packages/client/src/components/Input.tsx
+++ b/packages/client/src/components/Input.tsx
@@ -3,10 +3,13 @@ import { fieldControl } from './Field';
import { cn } from '~/utils';
import './Field.css';
-/** `title` edits a heading in place, so the field takes the heading's type scale. */
+/** `title` edits a heading in place, so the field takes the heading's type scale. `inline` shares
+ * a row with icon Buttons, so it takes their height role and the row stays one height when a
+ * theme sizes fields and buttons apart. */
const INPUT_VARIANTS = {
default: '',
- title: 'h-12 text-2xl font-semibold tracking-tight',
+ inline: 'h-theme-button',
+ title: 'h-theme-field-lg text-2xl font-semibold tracking-tight',
'title-sm': 'text-base font-semibold tracking-tight',
} as const;
diff --git a/packages/client/src/components/OGDialogTemplate.tsx b/packages/client/src/components/OGDialogTemplate.tsx
index 02d278ac88..5a14384145 100644
--- a/packages/client/src/components/OGDialogTemplate.tsx
+++ b/packages/client/src/components/OGDialogTemplate.tsx
@@ -116,7 +116,11 @@ const OGDialogTemplate: ForwardRefExoticComponent<
selectClasses ?? defaultSelect
} h-theme-button flex items-center justify-center rounded-lg border-none px-4 py-2 text-sm disabled:opacity-80 max-sm:order-first max-sm:w-full sm:order-none`}
>
- {isLoading === true ? : (selectText as React.JSX.Element)}
+ {isLoading === true ? (
+
+ ) : (
+ (selectText as React.JSX.Element)
+ )}
);
} else if (selection) {
diff --git a/packages/client/src/components/OriginalDialog.tsx b/packages/client/src/components/OriginalDialog.tsx
index 74844f2cae..9c86624814 100644
--- a/packages/client/src/components/OriginalDialog.tsx
+++ b/packages/client/src/components/OriginalDialog.tsx
@@ -372,8 +372,8 @@ const DialogContent: React.ForwardRefExoticComponent<
aria-hidden="true"
/>
{showCloseButton && (
-
-
+
+
Close
)}
diff --git a/packages/client/src/components/Select.tsx b/packages/client/src/components/Select.tsx
index 3d2a5edd5b..ea1e02c21e 100644
--- a/packages/client/src/components/Select.tsx
+++ b/packages/client/src/components/Select.tsx
@@ -27,7 +27,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<
span]:line-clamp-1',
+ 'border-border-control ring-offset-surface-primary placeholder:text-text-secondary focus-visible:ring-focus-control h-theme-control flex w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:ring-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
disabledFillClasses,
'hover:bg-surface-hover rounded-lg',
className,
@@ -36,7 +36,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<
>
{children}
-
+
));
@@ -151,7 +151,7 @@ const SelectItem: React.ForwardRefExoticComponent<
>
-
+
{children}
diff --git a/packages/client/src/components/Switch.tsx b/packages/client/src/components/Switch.tsx
index 9a2f7a0dd8..bbed41918f 100644
--- a/packages/client/src/components/Switch.tsx
+++ b/packages/client/src/components/Switch.tsx
@@ -26,7 +26,7 @@ const Switch: React.ForwardRefExoticComponent<
/** A compact theme track can be smaller than a usable target, so an invisible layer
* centered on it keeps the hit area at least 24px tall, and 44px each way on a coarse
* pointer; a track larger than that still takes taps on its own box. */
- 'touch:before:h-theme-control-touch touch:before:w-theme-control-touch relative before:absolute before:top-1/2 before:left-1/2 before:h-6 before:w-full before:-translate-x-1/2 before:-translate-y-1/2',
+ 'touch:before:h-theme-control-touch touch:before:w-theme-control-touch before:h-theme-target before:min-w-theme-target relative before:absolute before:top-1/2 before:left-1/2 before:w-full before:-translate-x-1/2 before:-translate-y-1/2',
'peer focus-visible:ring-focus-control focus-visible:ring-offset-surface-primary data-[state=checked]:bg-surface-inverted data-[state=unchecked]:bg-switch-unchecked h-theme-switch w-theme-switch inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
disabledFillClasses,
className,
diff --git a/packages/client/src/components/Tabs.tsx b/packages/client/src/components/Tabs.tsx
index 651308702b..e7adc427e0 100644
--- a/packages/client/src/components/Tabs.tsx
+++ b/packages/client/src/components/Tabs.tsx
@@ -33,7 +33,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<
>(({ className = '', ...props }, ref) => (
{
modes: {
light: {
colors: { 'rgb-accent-primary': '4 5 6' },
- appearance: { controlRadius: '2px', futureSpacing: '3rem' },
+ appearance: { controlRadius: '2px', futureSpacing: '3.3125rem' },
},
},
};
@@ -851,7 +851,7 @@ describe('ThemeProvider', () => {
expect(root.dataset.theme).toBe('newer');
expect(root.style.getPropertyValue('--accent-primary')).toBe('4 5 6');
expect(root.style.getPropertyValue('--theme-control-radius')).toBe('2px');
- expect(root.getAttribute('style')).not.toContain('3rem');
+ expect(root.getAttribute('style')).not.toContain('3.3125rem');
expect(warn).toHaveBeenCalledWith(
'[ThemeProvider] Unknown light appearance token ignored: futureSpacing',
);
@@ -890,7 +890,7 @@ describe('ThemeProvider', () => {
it('still discards a stored definition whose known key has an invalid value', async () => {
const invalid = {
...newerDefinition,
- modes: { light: { appearance: { controlRadius: 'huge', futureSpacing: '3rem' } } },
+ modes: { light: { appearance: { controlRadius: 'huge', futureSpacing: '3.3125rem' } } },
};
localStorage.setItem('theme-definition', JSON.stringify(invalid));
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index d8b13fdd2c..82ce064711 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -218,6 +218,7 @@ html {
--theme-menu-radius: 0.7rem;
--theme-tooltip-radius: 0.275rem;
--theme-tab-radius: 0.185rem;
+ --theme-tab-min-width: 100px;
--theme-radius-sm: calc(0.5rem - 4px);
--theme-radius-md: calc(0.5rem - 2px);
--theme-radius-lg: 0.5rem;
@@ -227,10 +228,18 @@ html {
--theme-control-height: 2.25rem;
--theme-control-padding-x: var(--theme-space-normal, 0.75rem);
--theme-control-gap: var(--theme-space-compact, 0.375rem);
+ --theme-icon-size: 1rem;
+ --theme-icon-size-md: 1.25rem;
+ --theme-icon-size-lg: 1.5rem;
--theme-control-font-weight: 500;
--theme-button-height: 2.5rem;
--theme-button-height-sm: 2.25rem;
+ --theme-button-height-xs: 1.75rem;
+ --theme-button-height-lg: 2.75rem;
+ --theme-button-height-compact: 2rem;
+ --theme-icon-button-size-sm: 2rem;
--theme-field-height: 2.5rem;
+ --theme-field-height-lg: 3rem;
--theme-field-padding-y: 0.5rem;
--theme-field-focus-style: ring;
--theme-field-fill-style: transparent;
@@ -241,6 +250,7 @@ html {
--theme-label-font-weight: inherit;
--theme-switch-width: 2.75rem;
--theme-switch-height: 1.5rem;
+ --theme-checkbox-size: 1rem;
--theme-table-cell-space-y: 1rem;
--theme-table-row-stroke: 0px;
--theme-space-compact: 0.375rem;
diff --git a/packages/client/src/theme/primitives.spec.ts b/packages/client/src/theme/primitives.spec.ts
new file mode 100644
index 0000000000..bebb126a0c
--- /dev/null
+++ b/packages/client/src/theme/primitives.spec.ts
@@ -0,0 +1,190 @@
+import { join } from 'path';
+import { readFileSync } from 'fs';
+
+/**
+ * The ten named primitives, read the strict way: a primitive is theme-driven only when its files
+ * paint color, radius, border, shadow and size from theme roles alone. Each file is checked for
+ * raw palette utilities, hex/rgb/hsl literals, arbitrary corners and shadows, fixed size
+ * utilities (`h-4`, `size-10`, `min-w-[8rem]`; a fraction such as `w-11/12`, a viewport unit or a
+ * value read from the component library is relative, and a `0` is a reset, not a size), literal
+ * corners and shadows in its stylesheet, and design-rule suppressions. Move a primitive into
+ * `themeDriven` when a change clears it; the remaining values of the others are pinned so a new
+ * literal fails by name.
+ */
+
+const components = join(__dirname, '../components');
+const repoRoot = join(__dirname, '../../../..');
+
+const primitives: Record = {
+ Button: ['Button.tsx'],
+ Input: ['Input.tsx', 'Field.ts'],
+ Select: ['Select.tsx', 'Dropdown.tsx', 'Dropdown.css'],
+ Dialog: ['OriginalDialog.tsx', 'OGDialogTemplate.tsx', 'Dialog.tsx'],
+ Menu: ['DropdownPopup.tsx', 'Dropdown.css'],
+ Tabs: ['Tabs.tsx'],
+ Switch: ['Switch.tsx'],
+ Checkbox: ['Checkbox.tsx'],
+ Table: ['Table.tsx'],
+ Tooltip: ['Tooltip.tsx', 'Tooltip.css'],
+};
+
+const themeDriven = ['Button', 'Input', 'Dialog', 'Tabs', 'Switch', 'Checkbox', 'Table', 'Tooltip'];
+
+/** What the two others still hard-code, and why it stays. */
+const remaining: Record = {
+ /** The content's nested-popover layering is a runtime style; the item indicator box, the list's
+ * scroll cap and its minimum width have no role. */
+ Select: [
+ 'Select.tsx: arbitrary size min-w-[8rem]',
+ 'Select.tsx: fixed size h-3.5',
+ 'Select.tsx: fixed size h-96',
+ 'Select.tsx: fixed size w-3.5',
+ 'Select.tsx: suppression shadcn/no-inline-styles',
+ ],
+ /** The menu's z-index comes from the popover stack at runtime. */
+ Menu: ['DropdownPopup.tsx: suppression shadcn/no-inline-styles'],
+};
+
+const suppressions: Record> = JSON.parse(
+ readFileSync(join(repoRoot, 'eslint-suppressions.json'), 'utf8'),
+);
+
+/** Every Tailwind palette hue, black and white, under any color utility. */
+const rawPalette = new RegExp(
+ `\\b(?:bg|text|border(?:-[xytblrse])?|ring(?:-offset)?|outline|fill|stroke|divide|accent|caret|decoration|placeholder|from|via|to|shadow)-(?:${[
+ 'black',
+ 'white',
+ 'slate',
+ 'gray',
+ 'zinc',
+ 'neutral',
+ 'stone',
+ 'red',
+ 'orange',
+ 'amber',
+ 'yellow',
+ 'lime',
+ 'green',
+ 'emerald',
+ 'teal',
+ 'cyan',
+ 'sky',
+ 'blue',
+ 'indigo',
+ 'violet',
+ 'purple',
+ 'fuchsia',
+ 'pink',
+ 'rose',
+ ].join('|')})(?:-[0-9]+)?\\b`,
+ 'g',
+);
+
+/** A 3, 4, 6 or 8 digit hex color, or an rgb/hsl function with literal channels. */
+const hexOrRgb =
+ /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b|rgba?\(\s*[0-9]|hsla?\(/g;
+
+const isComment = (line: string) => /^\s*(\*|\/\/|\/\*)/.test(line);
+
+/** A stylesheet with every theme role's `var(--theme-*, fallback)` reduced to `var(--theme-*)`;
+ * any other custom property keeps its fallback, which is then scanned like any literal. */
+function withoutVarFallbacks(css: string): string {
+ let result = '';
+ let index = 0;
+ for (let start = css.indexOf('var(', index); start !== -1; start = css.indexOf('var(', index)) {
+ let depth = 0;
+ let end = start + 3;
+ for (; end < css.length; end++) {
+ if (css[end] === '(') {
+ depth += 1;
+ } else if (css[end] === ')') {
+ depth -= 1;
+ }
+ if (depth === 0) {
+ break;
+ }
+ }
+ const call = css.slice(start, end + 1);
+ const name = /^var\(\s*(--[\w-]+)/.exec(call)?.[1] ?? '';
+ result += css.slice(index, start) + (name.startsWith('--theme-') ? `var(${name})` : call);
+ index = end + 1;
+ }
+ return result + css.slice(index);
+}
+
+function hardCoded(file: string): string[] {
+ const source = readFileSync(join(components, file), 'utf8');
+ const code = source.split('\n').filter((line) => !isComment(line));
+ const found = new Set();
+ if (file.endsWith('.css')) {
+ /** A role's `var()` fallback restates the default for a host without the stock stylesheet;
+ * it is not a value the rule paints while the role is set, so it is set aside first. */
+ const rules = withoutVarFallbacks(source.replace(/\/\*[\s\S]*?\*\//g, ''));
+ for (const match of rules.matchAll(/(border-radius|box-shadow):\s*[0-9][^;]*/g)) {
+ found.add(`${file}: literal ${match[0]}`);
+ }
+ for (const match of rules.matchAll(hexOrRgb)) {
+ found.add(`${file}: color literal ${match[0]}`);
+ }
+ } else {
+ const text = code.join('\n');
+ for (const match of text.matchAll(rawPalette)) {
+ found.add(`${file}: raw palette ${match[0]}`);
+ }
+ for (const match of text.matchAll(hexOrRgb)) {
+ found.add(`${file}: color literal ${match[0]}`);
+ }
+ for (const match of text.matchAll(/\b(?:rounded|shadow)(?:-[a-z]{1,2})?-\[[^\]]*\]/g)) {
+ found.add(`${file}: arbitrary ${match[0]}`);
+ }
+ for (const match of text.matchAll(/\b(?:h|w|size|min-h)-(?:[1-9][0-9.]*|0\.[0-9]+)\b(?!\/)/g)) {
+ found.add(`${file}: fixed size ${match[0]}`);
+ }
+ for (const match of text.matchAll(
+ /\b(?:h|w|size|min-h|min-w|max-h|max-w)-\[[0-9.]+(?:px|rem|em)\]/g,
+ )) {
+ found.add(`${file}: arbitrary size ${match[0]}`);
+ }
+ }
+ Object.keys(suppressions[`packages/client/src/components/${file}`] ?? {})
+ .filter((rule) => rule.startsWith('shadcn/'))
+ .forEach((rule) => found.add(`${file}: suppression ${rule}`));
+ return [...found].sort();
+}
+
+const values = Object.fromEntries(
+ Object.entries(primitives).map(([name, files]) => [name, files.flatMap(hardCoded).sort()]),
+);
+
+describe('the ten named primitives', () => {
+ it('draws at least eight of them from theme roles alone', () => {
+ const driven = Object.keys(primitives).filter((name) => values[name].length === 0);
+
+ expect(driven).toEqual(themeDriven);
+ expect(driven.length).toBeGreaterThanOrEqual(8);
+ });
+
+ it('reads any raw palette hue under any color utility', () => {
+ const hits = (classes: string) => classes.match(rawPalette) ?? [];
+ expect(
+ hits('bg-orange-500 text-pink-600 border-emerald-500 fill-white ring-offset-red-500'),
+ ).toHaveLength(5);
+ expect('text-[#00000080] bg-[#fff]'.match(hexOrRgb)).toEqual(['#00000080', '#fff']);
+ expect(hits('bg-surface-primary text-text-secondary border-border-light')).toEqual([]);
+ });
+
+ it('sets aside a role fallback in a stylesheet but keeps a painted literal', () => {
+ expect(
+ withoutVarFallbacks(
+ '.a { box-shadow: var(--theme-menu-shadow, 0 1px rgb(0 0 0 / 0.1)); color: #fff; }',
+ ),
+ ).toBe('.a { box-shadow: var(--theme-menu-shadow); color: #fff; }');
+ expect(withoutVarFallbacks('.a { box-shadow: var(--local-shadow, 0 1px #000); }')).toBe(
+ '.a { box-shadow: var(--local-shadow, 0 1px #000); }',
+ );
+ });
+
+ it.each(Object.keys(remaining))('pins what %s still hard-codes', (name) => {
+ expect(values[name]).toEqual(remaining[name]);
+ });
+});
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index fa6029108c..ce188228be 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -1109,6 +1109,54 @@ describe('theme registry', () => {
expect(appearance).toMatchObject({ focusRingWidth: '0.25rem', focusRingOffset: '-1px' });
});
+ it('keeps every control and icon size on the size it drew before it had a role', () => {
+ expect(defaultAppearance).toMatchObject({
+ iconSize: '1rem',
+ iconSizeLg: '1.5rem',
+ buttonHeightXs: '1.75rem',
+ buttonHeightLg: '2.75rem',
+ iconButtonSizeSm: '2rem',
+ fieldHeightLg: '3rem',
+ checkboxSize: '1rem',
+ });
+ });
+
+ it('rejects a pointer target under 24px and a size that is not a positive length', () => {
+ const issues = (appearance: Record) =>
+ validateThemeDefinition({
+ version: 1,
+ name: 'size-values',
+ modes: { light: { appearance } },
+ });
+
+ expect(
+ issues({
+ fieldHeightLg: '24px',
+ checkboxSize: '1.5rem',
+ iconSize: '20px',
+ iconSizeLg: '2rem',
+ }),
+ ).toEqual([]);
+ [
+ { fieldHeightLg: '20px' },
+ { fieldHeightLg: '1rem' },
+ { fieldHeightLg: '1.5em' },
+ { iconSize: '0' },
+ { iconSize: '1.5rem' },
+ { iconSize: '10px' },
+ { iconSizeLg: '0.75rem' },
+ { iconSizeLg: '40px' },
+ { checkboxSize: '8px' },
+ { checkboxSize: '2rem' },
+ { checkboxSize: 'auto' },
+ { buttonHeightLg: '-2rem' },
+ { buttonHeightXs: '1px' },
+ { iconSizeMd: '1rem' },
+ { iconButtonSizeSm: '20px' },
+ { iconButtonSizeSm: 'calc(2rem + 2px)' },
+ ].forEach((appearance) => expect(issues(appearance)).toHaveLength(1));
+ });
+
it('rejects a focus outline that would vanish or is not a fixed length', () => {
const issues = (appearance: Record) =>
validateThemeDefinition({
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index a8a391f51e..390b032fcb 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -166,6 +166,7 @@ export const themeAppearanceProperties: Readonly<
menuRadius: '--theme-menu-radius',
tooltipRadius: '--theme-tooltip-radius',
tabRadius: '--theme-tab-radius',
+ tabMinWidth: '--theme-tab-min-width',
radiusSm: '--theme-radius-sm',
radiusMd: '--theme-radius-md',
radiusLg: '--theme-radius-lg',
@@ -175,10 +176,18 @@ export const themeAppearanceProperties: Readonly<
controlHeight: '--theme-control-height',
controlPaddingX: '--theme-control-padding-x',
controlGap: '--theme-control-gap',
+ iconSize: '--theme-icon-size',
+ iconSizeMd: '--theme-icon-size-md',
+ iconSizeLg: '--theme-icon-size-lg',
controlFontWeight: '--theme-control-font-weight',
buttonHeight: '--theme-button-height',
buttonHeightSm: '--theme-button-height-sm',
+ buttonHeightXs: '--theme-button-height-xs',
+ buttonHeightLg: '--theme-button-height-lg',
+ buttonHeightCompact: '--theme-button-height-compact',
+ iconButtonSizeSm: '--theme-icon-button-size-sm',
fieldHeight: '--theme-field-height',
+ fieldHeightLg: '--theme-field-height-lg',
fieldPaddingY: '--theme-field-padding-y',
fieldFocusStyle: '--theme-field-focus-style',
fieldFillStyle: '--theme-field-fill-style',
@@ -189,6 +198,7 @@ export const themeAppearanceProperties: Readonly<
labelFontWeight: '--theme-label-font-weight',
switchWidth: '--theme-switch-width',
switchHeight: '--theme-switch-height',
+ checkboxSize: '--theme-checkbox-size',
tableCellSpaceY: '--theme-table-cell-space-y',
tableRowStroke: '--theme-table-row-stroke',
spaceCompact: '--theme-space-compact',
@@ -242,6 +252,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
menuRadius: '0.7rem',
tooltipRadius: '0.275rem',
tabRadius: '0.185rem',
+ tabMinWidth: '100px',
radiusSm: 'calc(0.5rem - 4px)',
radiusMd: 'calc(0.5rem - 2px)',
radiusLg: '0.5rem',
@@ -251,10 +262,18 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
controlHeight: '2.25rem',
controlPaddingX: '0.75rem',
controlGap: '0.375rem',
+ iconSize: '1rem',
+ iconSizeMd: '1.25rem',
+ iconSizeLg: '1.5rem',
controlFontWeight: '500',
buttonHeight: '2.5rem',
buttonHeightSm: '2.25rem',
+ buttonHeightXs: '1.75rem',
+ buttonHeightLg: '2.75rem',
+ buttonHeightCompact: '2rem',
+ iconButtonSizeSm: '2rem',
fieldHeight: '2.5rem',
+ fieldHeightLg: '3rem',
fieldPaddingY: '0.5rem',
fieldFocusStyle: 'ring',
fieldFillStyle: 'transparent',
@@ -264,6 +283,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
labelLeading: '1',
labelFontWeight: 'inherit',
...defaultSwitchSize,
+ checkboxSize: '1rem',
tableCellSpaceY: '1rem',
tableRowStroke: '0px',
spaceCompact: '0.375rem',
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 1af2f218e0..696348e9a9 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -158,6 +158,25 @@ describe('LibreChat Tailwind preset', () => {
defaultAppearance.largeSurfaceRadius,
],
['rounded-theme-tab', '--theme-tab-radius', defaultAppearance.tabRadius],
+ ['min-w-theme-tab', '--theme-tab-min-width', defaultAppearance.tabMinWidth],
+ ['h-theme-button-xs', '--theme-button-height-xs', defaultAppearance.buttonHeightXs],
+ ['h-theme-button-lg', '--theme-button-height-lg', defaultAppearance.buttonHeightLg],
+ [
+ 'h-theme-button-compact',
+ '--theme-button-height-compact',
+ defaultAppearance.buttonHeightCompact,
+ ],
+ ['h-theme-field-lg', '--theme-field-height-lg', defaultAppearance.fieldHeightLg],
+ ['size-theme-button', '--theme-button-height', defaultAppearance.buttonHeight],
+ [
+ 'size-theme-icon-button-sm',
+ '--theme-icon-button-size-sm',
+ defaultAppearance.iconButtonSizeSm,
+ ],
+ ['size-theme-checkbox', '--theme-checkbox-size', defaultAppearance.checkboxSize],
+ ['size-theme-icon', '--theme-icon-size', defaultAppearance.iconSize],
+ ['size-theme-icon-md', '--theme-icon-size-md', defaultAppearance.iconSizeMd],
+ ['size-theme-icon-lg', '--theme-icon-size-lg', defaultAppearance.iconSizeLg],
['shadow-theme-surface', '--theme-elevation-surface', defaultAppearance.elevationSurface],
['duration-theme-fast', '--theme-motion-fast', defaultAppearance.motionFast],
['duration-theme-normal', '--theme-motion-normal', defaultAppearance.motionNormal],
@@ -184,6 +203,13 @@ describe('LibreChat Tailwind preset', () => {
`max(var(--theme-control-height, ${defaultAppearance.controlHeight}), 2.75rem)`,
);
+ /** The target floor is WCAG 2.5.8's 24px, not a role a theme could lower. */
+ const target = await generate(['h-theme-target', 'min-h-theme-target', 'min-w-theme-target']);
+ ['height', 'min-height', 'min-width'].forEach((property) =>
+ expect(target).toContain(`${property}: 24px`),
+ );
+ expect(target).not.toContain('--theme-min-target-size');
+
/** A stylesheet that predates the control spacing roles pads controls with the shared
* spacing they read before. */
expect(rule(css, 'px-theme-control-x')).toContain(
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index 992877c78e..f3a80fcd1c 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -382,6 +382,8 @@ const clickHouseShape = {
menuRadius: '0.25rem', // genericMenu.panel.radii.all
tooltipRadius: '0.25rem', // tooltip.radii.all
tabRadius: '0.25rem', // tabs.radii.all
+ /** Click UI sizes a tab trigger by its label, in `tabs.space.x` on each side. */
+ tabMinWidth: '0',
radiusSm: '0.25rem', // border.radii.1
radiusMd: '0.25rem', // border.radii.1
radiusLg: '0.25rem', // border.radii.1
@@ -416,6 +418,15 @@ const clickHouseShape = {
* 0.875rem/1.5 label and a 1px stroke, 32px in all. */
buttonHeight: '2rem',
buttonHeightSm: '2rem',
+ /** Click UI draws one button size, so the `lg` step matches the default too. Its icon button is
+ * a 1rem icon in 0.25rem of `iconButton.sm` space on each side, 1.5rem in all, which still meets
+ * the 24px target minimum; its `xs` (no space) would not, so `icon-xs` keeps LibreChat's. */
+ buttonHeightLg: '2rem',
+ buttonHeightCompact: '2rem',
+ iconButtonSizeSm: '1.5rem',
+ iconSize: '1rem', // image.sm.size.width
+ iconSizeMd: '1.25rem', // image.md.size.width
+ iconSizeLg: '1.5rem', // image.lg.size.width, the dialog close icon
/** Click UI's field is sized by its content, like its button: 0.2813rem of space.y on both
* sides of a 0.875rem/1.5 value and a 1px stroke, 32px in all. On focus it swaps its stroke to
* `field.color.stroke.active` and draws no ring (InputWrapper); LibreChat adds a 1px ring in
@@ -450,6 +461,7 @@ const clickHouseShape = {
disabledStyle: 'fill' as const,
switchWidth: '2rem', // switch.size.width
switchHeight: '1rem', // switch.size.height
+ checkboxSize: '1rem', // checkbox.size.all
/** Click UI's own sizes halve like LibreChat's: `md` is this full space, and the compact tables
* every in-repo consumer draws land on `sm` (0.5rem), the size Click UI tables default to. */
/** The shared spacing takes two steps of Click UI's `spaces` scale: its 0.5rem gap step, the
diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json
index 34700a82d5..dc03cddb42 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -27,6 +27,7 @@
"click.button.basic.space.x": "1rem",
"click.button.basic.typography.label.default": "400 0.875rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.button.iconButton.color.primary.background.active": "rgb(86.824% 87.176% 88.235%)",
+ "click.checkbox.size.all": "1rem",
"click.codeblock.lightMode.color.background.default": "#f6f7fa",
"click.codeblock.lightMode.color.text.default": "#282828",
"click.dialog.color.background.default": "#ffffff",
@@ -49,6 +50,9 @@
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#c10000",
"click.global.color.text.warning": "#a33c00",
+ "click.image.lg.size.width": "1.5rem",
+ "click.image.md.size.width": "1.25rem",
+ "click.image.sm.size.width": "1rem",
"click.switch.color.background.active": "#151515",
"click.switch.color.background.default": "#cccfd3",
"click.switch.color.indicator.default": "#ffffff",
@@ -169,6 +173,7 @@
"click.button.basic.space.x": "1rem",
"click.button.basic.typography.label.default": "400 0.875rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.button.iconButton.color.primary.background.active": "rgb(14.118% 14.118% 14.118%)",
+ "click.checkbox.size.all": "1rem",
"click.codeblock.darkMode.color.background.default": "#282828",
"click.codeblock.darkMode.color.text.default": "#ffffff",
"click.dialog.color.background.default": "#1f1f1c",
@@ -191,6 +196,9 @@
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#ffbaba",
"click.global.color.text.warning": "#ffb88f",
+ "click.image.lg.size.width": "1.5rem",
+ "click.image.md.size.width": "1.25rem",
+ "click.image.sm.size.width": "1rem",
"click.switch.color.background.active": "#faff69",
"click.switch.color.background.default": "#606060",
"click.switch.color.indicator.default": "#151515",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index bf8f3e8d9b..7902188b95 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -511,6 +511,27 @@ const appearanceDecisions: Partial> = {
modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',
switchWidth: 'click.switch.size.width',
switchHeight: 'click.switch.size.height',
+ checkboxSize: 'click.checkbox.size.all',
+ iconSize: 'click.image.sm.size.width',
+ iconSizeMd: 'click.image.md.size.width',
+ iconSizeLg: 'click.image.lg.size.width',
tableCellSpaceY: 'click.table.body.cell.space.md.y',
tableRowStroke: 'click.table.cell.stroke',
motionFast: 'transition.duration.medium',
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index 05bba00ed0..892ad9df8e 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -511,6 +511,8 @@ export interface IThemeAppearance {
menuRadius: string;
tooltipRadius: string;
tabRadius: string;
+ /** The narrowest a tab trigger draws; `0` sizes it by its label. */
+ tabMinWidth: string;
radiusSm: string;
radiusMd: string;
radiusLg: string;
@@ -522,16 +524,31 @@ export interface IThemeAppearance {
* `spaceCompact` when a theme names those and not these. */
controlPaddingX: string;
controlGap: string;
+ /** An icon beside a label or in a menu row (0.75 to 1.25rem), and the larger one a dialog's
+ * close button draws (1 to 2rem). */
+ iconSize: string;
+ /** The medium icon (1.25 to 1.5rem), such as the exported Dialog's close glyph. */
+ iconSizeMd: string;
+ iconSizeLg: string;
/** A theme-sized control's label weight, and the Button's default and `sm` heights. */
controlFontWeight: string;
buttonHeight: string;
buttonHeightSm: string;
+ /** The Button's `xs` and `lg` heights; `icon-xs` is as wide as `xs` is tall, `icon` as the
+ * default, and `icon-sm` takes its own size. */
+ buttonHeightXs: string;
+ buttonHeightLg: string;
+ /** The compact toolbar step the Button and Dropdown `compact` recipes share. */
+ buttonHeightCompact: string;
+ iconButtonSizeSm: string;
/**
* A form field's height, and its focus treatment: `ring` draws the keyboard-only focus ring,
* `border` swaps the field's edge to `border-field-focus` on any focus, and keyboard focus adds
* a 1px ring in that color so the indicator keeps a 2px perimeter.
*/
fieldHeight: string;
+ /** The height of the large `title` field. */
+ fieldHeightLg: string;
/** The field's vertical padding, which has to leave its line room inside `fieldHeight`. */
fieldPaddingY: string;
fieldFocusStyle: 'ring' | 'border';
@@ -548,6 +565,8 @@ export interface IThemeAppearance {
labelFontWeight: string;
switchWidth: string;
switchHeight: string;
+ /** A checkbox's box and the check inside it, 1 to 1.5rem. */
+ checkboxSize: string;
tableCellSpaceY: string;
tableRowStroke: string;
spaceCompact: string;
diff --git a/packages/client/src/utils/utils.spec.ts b/packages/client/src/utils/utils.spec.ts
new file mode 100644
index 0000000000..2fa4810419
--- /dev/null
+++ b/packages/client/src/utils/utils.spec.ts
@@ -0,0 +1,16 @@
+import { cn } from './utils';
+
+describe('cn', () => {
+ /** A caller's own size replaces the role a primitive draws, so the two never both survive and
+ * leave the winner to stylesheet order. */
+ it.each([
+ ['h-theme-control', 'h-9'],
+ ['h-theme-button-xs', 'h-8'],
+ ['size-theme-button', 'size-9'],
+ ['h-theme-control', 'size-theme-control'],
+ ['min-w-theme-target', 'min-w-0'],
+ ['min-h-theme-target', 'min-h-0'],
+ ])('lets a caller size replace %s', (role, caller) => {
+ expect(cn(role, caller)).toBe(caller);
+ });
+});
diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.ts
index 3fe6011adf..e87a8ff700 100644
--- a/packages/client/src/utils/utils.ts
+++ b/packages/client/src/utils/utils.ts
@@ -23,11 +23,33 @@ const twMerge = extendTailwindMerge({
h: [
{
h: [
+ 'theme-control',
'theme-table-head',
'theme-table-head-compact',
'theme-button',
'theme-button-sm',
+ 'theme-button-xs',
+ 'theme-button-lg',
+ 'theme-button-compact',
'theme-field',
+ 'theme-field-lg',
+ 'theme-target',
+ ],
+ },
+ ],
+ 'min-w': [{ 'min-w': ['theme-tab', 'theme-target'] }],
+ 'min-h': [{ 'min-h': ['theme-target'] }],
+ size: [
+ {
+ size: [
+ 'theme-control',
+ 'theme-button',
+ 'theme-button-xs',
+ 'theme-icon-button-sm',
+ 'theme-checkbox',
+ 'theme-icon',
+ 'theme-icon-md',
+ 'theme-icon-lg',
],
},
],
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index 1215c48a21..852f98717a 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -23,13 +23,32 @@ module.exports = {
/** The Button's default and `sm` heights. */
'theme-button': 'var(--theme-button-height, 2.5rem)',
'theme-button-sm': 'var(--theme-button-height-sm, 2.25rem)',
- /** A form field's height. */
+ 'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',
+ 'theme-button-lg': 'var(--theme-button-height-lg, 2.75rem)',
+ 'theme-button-compact': 'var(--theme-button-height-compact, 2rem)',
+ /** A form field's height, and the large `title` field's. */
'theme-field': 'var(--theme-field-height, 2.5rem)',
+ 'theme-field-lg': 'var(--theme-field-height-lg, 3rem)',
+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never
+ * smaller. */
+ 'theme-target': '24px',
/** A header cell: the table's vertical cell space on both sides of one text line. */
'theme-table-head': 'calc(var(--theme-table-cell-space-y, 1rem) * 2 + 1rem)',
/** A compact header: half the cell space on both sides of a text-sm line. */
'theme-table-head-compact': 'calc(var(--theme-table-cell-space-y, 1rem) + 1.25rem)',
},
+ minHeight: {
+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never
+ * smaller. */
+ 'theme-target': '24px',
+ },
+ minWidth: {
+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never
+ * smaller. */
+ 'theme-target': '24px',
+ /** The narrowest a tab trigger draws. */
+ 'theme-tab': 'var(--theme-tab-min-width, 100px)',
+ },
width: {
/** Never narrower than the track is tall, so the knob always has somewhere to travel. */
'theme-switch':
@@ -39,6 +58,14 @@ module.exports = {
'theme-compact': 'var(--theme-space-compact, 0.375rem)',
'theme-normal': 'var(--theme-space-normal, 0.75rem)',
'theme-control': 'var(--theme-control-height, 2.25rem)',
+ /** Square sizes: icon buttons as wide as their row is tall, the checkbox, and icons. */
+ 'theme-button': 'var(--theme-button-height, 2.5rem)',
+ 'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',
+ 'theme-icon-button-sm': 'var(--theme-icon-button-size-sm, 2rem)',
+ 'theme-checkbox': 'var(--theme-checkbox-size, 1rem)',
+ 'theme-icon': 'var(--theme-icon-size, 1rem)',
+ 'theme-icon-md': 'var(--theme-icon-size-md, 1.25rem)',
+ 'theme-icon-lg': 'var(--theme-icon-size-lg, 1.5rem)',
/** A theme-sized control's inline padding and gap, falling back to the shared spacing it
* read before, for a stylesheet that predates the roles. */
'theme-control-x': 'var(--theme-control-padding-x, var(--theme-space-normal, 0.75rem))',
@@ -51,7 +78,8 @@ module.exports = {
/**
* The comfortable tap target (2.75rem / 44px), held against the theme's
* own control height with `max()` so a theme that already draws larger
- * controls is never shrunk on a phone. Pair it with `touch:`.
+ * controls is never shrunk on a phone. Pair it
+ * with `touch:`.
*/
'theme-control-touch': 'max(var(--theme-control-height, 2.25rem), 2.75rem)',
/** The switch knob inside the track's 2px border, in px so it holds at any root size,
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index 4ebc47d37e..4bb26d7ea5 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -229,6 +229,23 @@ const isSwitchLength = (value: unknown): value is string =>
* never vanishes; its offset may also be zero or negative, drawing the outline on or inside the
* element's edge.
*/
+/**
+ * A positive px or rem length inside the range its layouts were built for, in px on a 16px root:
+ * the icon and checkbox roles size glyphs that sit in fixed insets and rows, so a theme can retune
+ * them, but not past the room those layouts leave.
+ */
+const lengthWithin =
+ (minPx: number, maxPx: number) =>
+ (value: unknown): value is string => {
+ if (!isSwitchLength(value)) {
+ return false;
+ }
+ const px = parseFloat(value) * (value.endsWith('rem') ? 16 : 1);
+ return px >= minPx && px <= maxPx;
+ };
+/** A pointer target never drops under WCAG 2.5.8's 24px minimum, written in px or rem. */
+const isTargetSize = (value: unknown): value is string =>
+ isSwitchLength(value) && parseFloat(value) >= (value.endsWith('rem') ? 1.5 : 24);
const isFocusRingOffset = (value: unknown): value is string =>
typeof value === 'string' && /^(0|-?\d*\.?\d+(px|rem))$/.test(value);
/** A numeric CSS font weight, 1 to 1000, which is all a label weight needs. */
@@ -342,6 +359,7 @@ const appearanceValidators = {
menuRadius: isLength,
tooltipRadius: isLength,
tabRadius: isLength,
+ tabMinWidth: isTableLength,
radiusSm: isLength,
radiusMd: isLength,
radiusLg: isLength,
@@ -353,13 +371,24 @@ const appearanceValidators = {
* spacing that also pads message rows. */
controlPaddingX: isLength,
controlGap: isLength,
+ /** An icon's size (0.75 to 1.25rem), and the larger one a dialog's close button draws (1 to
+ * 2rem). */
+ iconSize: lengthWithin(12, 20),
+ iconSizeMd: lengthWithin(20, 24),
+ iconSizeLg: lengthWithin(16, 32),
/** A theme-sized control's label weight, and the Button's default and `sm` heights. */
controlFontWeight: isFontWeight,
buttonHeight: isLength,
buttonHeightSm: isLength,
+ /** The Button's `xs` and `lg` heights and the `icon-sm` square, each a pointer target. */
+ buttonHeightXs: isTargetSize,
+ buttonHeightLg: isTargetSize,
+ buttonHeightCompact: isTargetSize,
+ iconButtonSizeSm: isTargetSize,
/** A form field's height and vertical padding, and whether focus draws a ring or swaps the
* field's edge color. */
fieldHeight: isLength,
+ fieldHeightLg: isTargetSize,
fieldPaddingY: isLength,
fieldFocusStyle: (value: unknown) => value === 'ring' || value === 'border',
/** Whether a field stays transparent or paints `field-fill`. */
@@ -373,6 +402,8 @@ const appearanceValidators = {
labelFontWeight: (value: unknown) => value === 'inherit' || isFontWeight(value),
switchWidth: isSwitchLength,
switchHeight: isSwitchLength,
+ /** A checkbox's box and the check inside it, 1 to 1.5rem: never smaller than the box it was. */
+ checkboxSize: lengthWithin(16, 24),
tableCellSpaceY: isTableLength,
tableRowStroke: isTableLength,
spaceCompact: isLength,