🔎 feat: Let Themes Focus Fields by Their Edge and Size Fields and Labels (#16550)

* feat: Let Themes Focus Fields by Their Edge and Size Fields and Labels

Shared fields drew a fixed 40px control that could only focus with the
keyboard ring, and Label a fixed text-sm at leading 1, so a theme could not
draw Click UI's 32px field that swaps its stroke on focus, or its 500
0.75rem/1.5 field label.

Fields now read fieldHeight and fieldFocusStyle: ring keeps today's
keyboard-only ring, border swaps the edge to border-field-focus on any focus
with no ring, mirrored on the root as data-theme-field-focus so the pointer
modality reset leaves it alone. Label reads labelSize, labelLeading and
labelFontWeight. Every default reproduces today's field and label; the edge
color follows focus-control and the label size textSm for a theme that
names only those. The ClickHouse theme takes Click UI's field height,
active stroke and label typography, and the drift guard pins them. The
shared Badge, which no app surface renders, keeps a recorded deviation.

* fix: Keep the Pointer Focus Reset for Edge-Focused Fields

Under fieldFocusStyle border the pointer-modality rule was skipped whole,
so a pointer-focused field lost its outline and ring reset along with the
edge reset. Only the edge reset now depends on the focus style.

* fix: Keep the Forced-Colors Outline and Give SecretInput the Field Roles

Under forced colors the edge color and ring drop out, so suppressing the
outline of an edge-focused field left keyboard focus invisible there. The
suppression now applies outside forced colors only.

SecretInput hard-coded h-10 and was not a shared field, so beside an Input
it kept 40px and missed the theme's focus treatment. It now composes
fieldControl, keeping its trailing padding for the controls; its keyboard
focus becomes the same focus-control ring the other fields draw.

* fix: Give Fields a Vertical Padding Role So a Short Field Keeps Its Line

The field kept a fixed py-2 inside the themed height, so ClickHouse's 32px
field left 14px for a 21px line. Fields now read fieldPaddingY, py-2 by
default; the ClickHouse theme takes Click UI's field.space.y, which fills
its 32px exactly, and the drift guard pins it.

* fix: Keep a 2px Keyboard Focus Perimeter and Respect Scoped Edge-Focus Roots

An edge-focused field showed keyboard focus only as its recolored 1px
edge, under the 2px perimeter the app holds as its focus floor. Keyboard
focus now adds a 1px ring in the same color; pointer focus stays edge-only.

The pointer reset checked only the document root for edge focus, so a
border-focus theme applied to a nested root had its edge reset to the
stock border. It now skips any field under an edge-focus root.

(cherry picked from commit ed6107aa89)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16550
This commit is contained in:
Marco Beretta 2026-09-30 17:33:39 +02:00 • committed by Lia
parent 2e0690616f
commit 6df4b8cb9b
28 changed files with 573 additions and 19 deletions

View file

@ -0,0 +1,193 @@
import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';
import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
import { NEW_CHAT_PATH } from '../helpers';
import { probeStyle } from './style.helpers';
/**
* Shared fields read their height and focus treatment, and Label its size, leading and weight,
* from theme roles. The Account tab's "Delete account" row label is a plain default Label, and
* its confirmation dialog holds a plain shared Input.
*/
test.describe.configure({ timeout: 120_000 });
test.use({ viewport: { width: 1280, height: 800 } });
type Mode = 'light' | 'dark';
/** A theme that opts into edge focus and names only the focus ring color. */
const legacyFocusTheme: ThemeDefinition = {
version: 1,
name: 'legacy-focus-reference',
modes: {
light: {
colors: { 'rgb-focus-control': '10 20 30' },
appearance: { fieldFocusStyle: 'border' },
},
dark: {
colors: { 'rgb-focus-control': '10 20 30' },
appearance: { fieldFocusStyle: 'border' },
},
},
};
async function storeDefinition(page: Page, definition: ThemeDefinition | null) {
await page.addInitScript((stored) => {
localStorage.removeItem('theme-colors');
localStorage.removeItem('theme-name');
if (stored === null) {
localStorage.removeItem('theme-definition');
localStorage.removeItem('theme-source');
return;
}
localStorage.setItem('theme-definition', JSON.stringify(stored));
localStorage.setItem('theme-source', 'definition');
}, definition);
}
const typeOf = (label: Locator): Promise<LabelType> =>
label.evaluate((node: HTMLElement) => {
const style = getComputedStyle(node);
return { size: style.fontSize, leading: style.lineHeight, weight: style.fontWeight };
});
type LabelType = { size: string; leading: string; weight: string };
/** Reads the row label before the confirmation opens, since the settings dialog then hides. */
async function openAccount(page: Page): Promise<{ label: LabelType; field: Locator }> {
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
await page.getByTestId('nav-user').click();
await page.getByRole('menuitem', { name: 'Settings' }).click();
const settings = page.getByRole('dialog', { name: 'Settings' });
await expect(settings.getByRole('heading', { name: 'Settings', exact: true })).toBeVisible({
timeout: 15000,
});
await settings.getByRole('tab', { name: 'Account' }).click();
const row = settings.locator('#delete-account-label');
await expect(row).toBeVisible();
const label = await typeOf(row);
await settings.getByRole('button', { name: 'Delete account' }).click();
const field = page.getByRole('textbox', { name: 'Please enter your account email' });
await expect(field).toBeVisible();
return { label, field };
}
/** The field's edge, height, and whether any box shadow paints: a zeroed ring reads as none. */
const focusOf = (field: Locator) =>
field.evaluate((node: HTMLElement) => {
const style = getComputedStyle(node);
const shadows = style.boxShadow === 'none' ? [] : style.boxShadow.split(/,(?![^(]*\))/);
const paints = shadows.some((shadow) => !/0px 0px 0px 0px\s*$/.test(shadow.trim()));
return {
edge: style.borderTopColor,
ring: paints ? 'ring' : 'none',
outline: style.outlineStyle,
height: node.offsetHeight,
};
});
/** Moves focus away and back with the keyboard, so the field holds keyboard focus. */
async function keyboardFocus(page: Page, field: Locator) {
await field.click();
await page.keyboard.press('Shift+Tab');
await page.keyboard.press('Tab');
await expect(field).toBeFocused();
}
const resolvedMode = (page: Page) =>
page.evaluate(() =>
document.documentElement.classList.contains('dark') ? 'dark' : 'light',
) as Promise<Mode>;
test.describe('theme field focus', () => {
test('fields keep their 40px height and keyboard ring without a theme @scenario:fields-keep-default-height-and-ring', async ({
page,
}) => {
await storeDefinition(page, null);
const { label, field } = await openAccount(page);
expect(label).toMatchObject({ size: '14px', leading: '14px' });
const edge = await probeStyle(page, 'border border-border-control', 'border-top-color');
await field.click();
expect(await focusOf(field)).toMatchObject({ height: 40, edge, ring: 'none' });
await keyboardFocus(page, field);
const focused = await focusOf(field);
expect(focused.edge).toBe(edge);
expect(focused.ring).toBe('ring');
/** A border-focus theme applied to a nested root, while the document stays on the ring, still
* keeps its swapped edge on pointer focus. */
const classes = (await field.getAttribute('class')) ?? '';
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({
timeout: 15000,
});
await page.evaluate((className) => {
const scope = document.createElement('div');
scope.setAttribute('data-theme-field-focus', 'border');
scope.style.setProperty('--border-field-focus', '10 20 30');
const probe = document.createElement('input');
probe.className = className;
probe.setAttribute('aria-label', 'scoped field probe');
scope.append(probe);
document.body.append(scope);
}, classes);
const scoped = page.getByRole('textbox', { name: 'scoped field probe' });
await scoped.click();
expect((await focusOf(scoped)).edge).toBe('rgb(10, 20, 30)');
});
test('ClickHouse fields take Click UI height, edge focus and label type @scenario:clickhouse-fields-follow-click-ui', async ({
page,
}) => {
await storeDefinition(page, clickHouseTheme);
/** An explicit mode, as a user who picked light or dark has, so forced colors below leave
* the deployment theme in place instead of switching to high contrast. */
await page.addInitScript(() =>
localStorage.setItem(
'color-theme',
matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light',
),
);
const { label, field } = await openAccount(page);
await expect(page.locator('html')).toHaveAttribute('data-theme-field-focus', 'border');
const mode = await resolvedMode(page);
/** `field.color.stroke.active`. */
const active = mode === 'light' ? 'rgb(22, 21, 23)' : 'rgb(250, 255, 105)';
/** `field.typography.label.default`: 500 0.75rem/1.5. */
expect(label).toEqual({ size: '12px', leading: '18px', weight: '500' });
/** `field.space.y` on both sides of a 0.875rem/1.5 line and a 1px stroke fills the 32px. */
const padding = await field.evaluate((node: HTMLElement) =>
parseFloat(getComputedStyle(node).paddingTop),
);
expect(padding).toBeCloseTo(4.5, 0);
const edgeOnly = { edge: active, ring: 'none', outline: 'none', height: 32 };
await field.click();
expect(await focusOf(field)).toEqual(edgeOnly);
/** Keyboard focus adds a 1px ring in the edge color for a 2px perimeter, and the app's
* unlayered dark-mode outline must not add another indicator around it. */
await keyboardFocus(page, field);
expect(await focusOf(field)).toEqual({ ...edgeOnly, ring: 'ring' });
/** Forced colors drop the edge color and the ring, so the outline is kept as the indicator. */
await page.emulateMedia({ forcedColors: 'active' });
await expect(page.locator('html')).toHaveAttribute('data-theme-field-focus', 'border');
await keyboardFocus(page, field);
expect((await focusOf(field)).outline).not.toBe('none');
});
test('a theme that opts into edge focus and names only its ring color edges fields in it @scenario:legacy-focus-theme-keeps-field-focus', async ({
page,
}) => {
await storeDefinition(page, legacyFocusTheme);
const { field } = await openAccount(page);
await expect(page.locator('html')).toHaveAttribute('data-theme', 'legacy-focus-reference');
await field.click();
expect(await focusOf(field)).toMatchObject({ edge: 'rgb(10, 20, 30)', ring: 'none' });
});
});

View file

@ -2,10 +2,29 @@
only. Text inputs match :focus-visible on pointer focus too (a UA heuristic
CSS cannot distinguish), so the ring is gated on the input modality tracked
by useInputModality (mount it once near the app root). Without the hook the
attribute is absent and the ring always shows, which is the safe fallback. */
attribute is absent and the ring always shows, which is the safe fallback.
A theme that focuses fields by swapping their edge (`fieldFocusStyle: border`)
keeps that edge on pointer focus too, so only the edge reset skips it, for a
field under any root that theme is applied to, not only the document. */
html[data-input-modality='pointer'] .lc-field:focus,
html[data-input-modality='pointer'] .lc-field:focus-visible {
border-color: rgb(var(--border-light) / var(--border-light-alpha, 1));
box-shadow: none;
outline: none;
}
html[data-input-modality='pointer'] .lc-field:not([data-theme-field-focus='border'] *):focus,
html[data-input-modality='pointer']
.lc-field:not([data-theme-field-focus='border'] *):focus-visible {
border-color: rgb(var(--border-light) / var(--border-light-alpha, 1));
}
/* A field focused by its edge draws no outline either. The app's dark-mode
`:focus-visible` outline is unlayered, so it outranks the field's own
`focus-visible:outline-hidden` utility and would add a second indicator
around the swapped edge. Forced colors drop the edge color and the ring, so
there the outline stays as the only indicator. */
@media not (forced-colors: active) {
[data-theme-field-focus='border'] .lc-field:focus-visible {
outline: none;
}
}

View file

@ -7,8 +7,11 @@ import { disabledFillClasses } from '~/utils/theme';
* Callers compose a variant rather than restating these classes locally. The
* border is `border-control` because it is the only edge the control has, so a
* palette can raise it to the 3:1 non-text floor without touching separators.
* A theme whose `fieldFocusStyle` is `border` focuses the field by swapping that edge to
* `border-field-focus`; keyboard focus adds a 1px ring in the same color, so the indicator keeps
* the 2px perimeter the app holds as its focus floor.
*/
export const fieldBase: string = `lc-field flex w-full rounded-lg border border-border-control px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control disabled:cursor-not-allowed disabled:opacity-50 ${disabledFillClasses}`;
export const fieldBase: string = `lc-field flex w-full rounded-lg border border-border-control px-3 py-theme-field-y text-sm text-text-primary placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control theme-field-border:focus:border-border-field-focus theme-field-border:focus-visible:ring-1 theme-field-border:focus-visible:ring-border-field-focus disabled:cursor-not-allowed disabled:opacity-50 ${disabledFillClasses}`;
/** A single-line control sized to sit in a form row, matching `Input`. */
export const fieldControl: string = `${fieldBase} h-10 bg-transparent`;
export const fieldControl: string = `${fieldBase} h-theme-field bg-transparent`;

View file

@ -7,7 +7,15 @@ describe('Label', () => {
render(<Label htmlFor="field">Name</Label>);
const label = screen.getByText('Name');
expect(label).toHaveClass('block', 'w-full', 'break-all', 'leading-none', 'text-sm');
/** The theme's label roles, which default to `text-sm`, leading 1 and the surrounding weight. */
expect(label).toHaveClass(
'block',
'w-full',
'break-all',
'text-(length:--theme-label-size)',
'leading-(--theme-label-leading)',
'font-theme-label',
);
expect(label).toHaveClass('text-text-primary', 'peer-disabled:opacity-70');
});

View file

@ -18,7 +18,10 @@ type LabelVariantOptions =
const labelVariants: (props?: LabelVariantOptions) => string = cva('', {
variants: {
variant: {
default: 'text-sm leading-none text-text-primary',
/** Size, leading and weight are the theme's label roles: `text-sm`, leading 1 and the
* surrounding weight by default. */
default:
'text-(length:--theme-label-size) leading-(--theme-label-leading) font-theme-label text-text-primary',
/** Eyebrow above a field or settings group. */
section: 'text-[11px] font-medium uppercase tracking-wide text-text-secondary',
},

View file

@ -48,4 +48,20 @@ describe('SecretInput', () => {
});
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('secret-value');
});
/** A secret sits beside plain inputs in forms, so it composes the shared field and takes the
* theme's field height and focus treatment with them. */
it('draws the shared field with its height and focus roles', () => {
render(<SecretInput value="secret" showCopy readOnly aria-label="token" />);
const field = screen.getByLabelText('token');
expect(field).toHaveClass(
'lc-field',
'h-theme-field',
'focus-visible:ring-focus-control',
'theme-field-border:focus:border-border-field-focus',
'pr-20',
);
expect(field).not.toHaveClass('h-10');
});
});

View file

@ -1,8 +1,9 @@
import * as React from 'react';
import { useState, useCallback } from 'react';
import { Eye, EyeOff, Copy, Check } from 'lucide';
import { cn, disabledFillClasses, disabledInkClasses } from '~/utils';
import { cn, disabledInkClasses } from '~/utils';
import { MorphIcon } from './MorphIcon';
import { fieldControl } from './Field';
export interface SecretInputProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
@ -83,8 +84,7 @@ const SecretInput: React.ForwardRefExoticComponent<
id={id}
type={isVisible ? 'text' : 'password'}
className={cn(
'border-border-control placeholder:text-text-secondary flex h-10 w-full rounded-lg border bg-transparent py-2 pl-3 text-sm focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
disabledFillClasses,
fieldControl,
colorTransition && 'transition-colors',
className ?? '',
copyButton != null || showCopy ? 'pr-20' : 'pr-11',

View file

@ -341,6 +341,16 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
keeps the half-opacity treatment every primitive carries.
- `font-display` - Headings (`displayFontFamily`). Follows the theme's
`fontFamily` when it names no display family.
- `border-border-field-focus` - A form field's edge while it holds focus, under
`fieldFocusStyle: border`. Follows `focus-control` when a theme names only that.
- Form fields and labels - `h-theme-field` (`fieldHeight`) sizes `Input`, `Dropdown`
and `ControlCombobox`. `fieldFocusStyle` picks the focus treatment: `ring` (the
default) draws the keyboard-only focus ring, and `border` swaps the field's edge
to `border-field-focus` on any focus, adding a 1px ring in that color on keyboard
focus so the indicator keeps the 2px focus floor, through the
`theme-field-border:` variant `applyTheme` enables with `data-theme-field-focus`.
`Label` reads `labelSize` (follows `textSm`), `labelLeading` and
`labelFontWeight` (`inherit` by default, so a label keeps the weight around it).
- `text-dialog-title` - An OGDialog title's ink. Follows `text-primary` when a
theme names only that.
- OGDialog chrome - `border-(length:--theme-dialog-stroke)` (`dialogStroke`, painted in

View file

@ -10,6 +10,12 @@ import React, {
} from 'react';
import { JSX } from 'react/jsx-runtime';
import type { IThemeRGB, ThemeDefinition, ThemeMode } from '../types';
import applyTheme, {
applyResolvedTheme,
themeOwnedProperties,
THEME_DISABLED_ATTRIBUTE,
THEME_FIELD_FOCUS_ATTRIBUTE,
} from '../utils/applyTheme';
import {
fromLegacyTheme,
highContrastTheme,
@ -17,11 +23,6 @@ import {
resolveTheme,
validateThemeDefinition,
} from '../registry';
import applyTheme, {
applyResolvedTheme,
themeOwnedProperties,
THEME_DISABLED_ATTRIBUTE,
} from '../utils/applyTheme';
import { defaultTheme } from '../themes/default';
import { darkTheme } from '../themes/dark';
import '../highContrast.css';
@ -53,6 +54,7 @@ type ThemeDOMSnapshot = {
colorScheme: { value: string; priority: string };
dataTheme: string | null;
disabledStyle: string | null;
fieldFocusStyle: string | null;
};
type ThemeClassSnapshot = {
@ -422,6 +424,7 @@ const captureThemeDOM = (root: HTMLElement): ThemeDOMSnapshot => ({
},
dataTheme: root.getAttribute('data-theme'),
disabledStyle: root.getAttribute(THEME_DISABLED_ATTRIBUTE),
fieldFocusStyle: root.getAttribute(THEME_FIELD_FOCUS_ATTRIBUTE),
});
const restoreThemeDOM = (snapshot: ThemeDOMSnapshot, root: HTMLElement): void => {
@ -453,6 +456,11 @@ const restoreThemeDOM = (snapshot: ThemeDOMSnapshot, root: HTMLElement): void =>
} else {
root.setAttribute(THEME_DISABLED_ATTRIBUTE, snapshot.disabledStyle);
}
if (snapshot.fieldFocusStyle === null) {
root.removeAttribute(THEME_FIELD_FOCUS_ATTRIBUTE);
} else {
root.setAttribute(THEME_FIELD_FOCUS_ATTRIBUTE, snapshot.fieldFocusStyle);
}
};
export function ThemeProvider({

View file

@ -137,6 +137,7 @@ html {
--border-xheavy-alpha: 1;
--border-destructive: var(--red-600);
--border-control: var(--gray-200);
--border-field-focus: var(--focus-control);
--focus-control: var(--gray-800);
--border-disabled: var(--gray-200);
--status-success: var(--green-700);
@ -208,6 +209,12 @@ html {
--theme-control-font-weight: 500;
--theme-button-height: 2.5rem;
--theme-button-height-sm: 2.25rem;
--theme-field-height: 2.5rem;
--theme-field-padding-y: 0.5rem;
--theme-field-focus-style: ring;
--theme-label-size: var(--theme-text-sm, 0.875rem);
--theme-label-leading: 1;
--theme-label-font-weight: inherit;
--theme-switch-width: 2.75rem;
--theme-switch-height: 1.5rem;
--theme-table-cell-space-y: 1rem;
@ -333,6 +340,7 @@ html {
--border-xheavy: var(--gray-400);
--border-destructive: var(--red-500);
--border-control: var(--gray-800);
--border-field-focus: var(--focus-control);
--focus-control: var(--gray-100);
--border-disabled: var(--gray-650);
--status-success: var(--green-300);

View file

@ -63,7 +63,7 @@ describe.each([
const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
it('covers every registry color', () => {
expect(tokens).toHaveLength(112);
expect(tokens).toHaveLength(113);
});
it('resolves every registry color to the runtime theme value', () => {
@ -84,6 +84,7 @@ const stockAliases: Partial<
> = {
controlPaddingX: 'spaceNormal',
controlGap: 'spaceCompact',
labelSize: 'textSm',
dialogTitleSize: 'textLg',
dialogTitleFontFamily: 'displayFontFamily',
};
@ -94,6 +95,7 @@ const colorAliases: Array<[string, string]> = [
['--button-primary', '--surface-inverted'],
['--button-primary-hover', '--surface-inverted-hover'],
['--dialog-title', '--text-primary'],
['--border-field-focus', '--focus-control'],
];
describe('the stock color aliases', () => {

View file

@ -836,6 +836,95 @@ describe('theme registry', () => {
});
});
it('keeps LibreChat’s field and label by default', () => {
expect(defaultAppearance).toMatchObject({
fieldHeight: '2.5rem',
fieldPaddingY: '0.5rem',
fieldFocusStyle: 'ring',
labelSize: defaultAppearance.textSm,
labelLeading: '1',
labelFontWeight: 'inherit',
});
expect(defaultTheme['rgb-border-field-focus']).toBe(defaultTheme['rgb-focus-control']);
expect(darkTheme['rgb-border-field-focus']).toBe(darkTheme['rgb-focus-control']);
});
it('keeps the fields and labels of a theme that predates the roles on its focus and type', () => {
const { colors, appearance } = resolveTheme(
{
version: 1,
name: 'focus-reference',
modes: {
light: {
colors: { 'rgb-text-primary': '10 20 30' },
appearance: { textSm: '0.95rem' },
},
},
},
'light',
);
/** The field edge chains through `focus-control`, which itself follows the primary ink. */
expect(colors['rgb-focus-control']).toBe('10 20 30');
expect(colors['rgb-border-field-focus']).toBe('10 20 30');
expect(appearance.labelSize).toBe('0.95rem');
expect(appearance.fieldFocusStyle).toBe('ring');
});
it('draws fields and labels from their own roles apart from the focus ring and type scale', () => {
const { colors, appearance } = resolveTheme(
{
version: 1,
name: 'edge-focus-reference',
modes: {
dark: {
colors: { 'rgb-border-field-focus': '200 30 90' },
appearance: {
fieldHeight: '3rem',
fieldPaddingY: '0.75rem',
fieldFocusStyle: 'border',
labelSize: '1rem',
labelLeading: '1.25',
labelFontWeight: '700',
},
},
},
},
'dark',
);
expect(colors['rgb-focus-control']).toBe(darkTheme['rgb-focus-control']);
expect(colors['rgb-border-field-focus']).toBe('200 30 90');
expect(appearance.textSm).toBe(defaultAppearance.textSm);
expect(appearance).toMatchObject({
fieldHeight: '3rem',
fieldPaddingY: '0.75rem',
fieldFocusStyle: 'border',
labelSize: '1rem',
labelLeading: '1.25',
labelFontWeight: '700',
});
});
it('rejects field and label values the shared validators refuse', () => {
const issues = (appearance: Record<string, string>) =>
validateThemeDefinition({
version: 1,
name: 'field-values',
modes: { light: { appearance } },
});
expect(issues({ fieldFocusStyle: 'border', labelFontWeight: 'inherit' })).toEqual([]);
[
{ fieldFocusStyle: 'glow' },
{ fieldHeight: 'tall' },
{ fieldPaddingY: '4' },
{ labelSize: '12' },
{ labelLeading: 'calc(1 / 0)' },
{ labelFontWeight: 'bold' },
].forEach((appearance) => expect(issues(appearance)).toHaveLength(1));
});
it('does not count the dialog title ink among the surfaces the verified mark sits on', () => {
const { colors } = resolveTheme(
{

View file

@ -134,9 +134,11 @@ export function dialogTitleFallback(colors: IThemeRGB): IThemeRGB {
export function focusFallbacks(colors: IThemeRGB): IThemeRGB {
const outline = colors['rgb-focus-outline'] ?? colors['rgb-ring-primary'];
const control = colors['rgb-focus-control'] ?? colors['rgb-text-primary'];
const field = colors['rgb-border-field-focus'] ?? control;
return {
...(outline !== undefined ? { 'rgb-focus-outline': outline } : {}),
...(control !== undefined ? { 'rgb-focus-control': control } : {}),
...(field !== undefined ? { 'rgb-border-field-focus': field } : {}),
};
}
@ -159,6 +161,12 @@ export const themeAppearanceProperties: Readonly<
controlFontWeight: '--theme-control-font-weight',
buttonHeight: '--theme-button-height',
buttonHeightSm: '--theme-button-height-sm',
fieldHeight: '--theme-field-height',
fieldPaddingY: '--theme-field-padding-y',
fieldFocusStyle: '--theme-field-focus-style',
labelSize: '--theme-label-size',
labelLeading: '--theme-label-leading',
labelFontWeight: '--theme-label-font-weight',
switchWidth: '--theme-switch-width',
switchHeight: '--theme-switch-height',
tableCellSpaceY: '--theme-table-cell-space-y',
@ -220,6 +228,12 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
controlFontWeight: '500',
buttonHeight: '2.5rem',
buttonHeightSm: '2.25rem',
fieldHeight: '2.5rem',
fieldPaddingY: '0.5rem',
fieldFocusStyle: 'ring',
labelSize: '0.875rem',
labelLeading: '1',
labelFontWeight: 'inherit',
...defaultSwitchSize,
tableCellSpaceY: '1rem',
tableRowStroke: '0px',
@ -404,6 +418,7 @@ const inheritedAppearance: ReadonlyArray<[keyof IThemeAppearance, keyof IThemeAp
['displayFontFamily', 'fontFamily'],
['controlPaddingX', 'spaceNormal'],
['controlGap', 'spaceCompact'],
['labelSize', 'textSm'],
['dialogTitleSize', 'textLg'],
['dialogTitleFontFamily', 'displayFontFamily'],
];

View file

@ -792,6 +792,35 @@ describe('state role defaults', () => {
expect(theme['rgb-dialog-title']).toBe(theme['rgb-text-primary']);
});
it.each([
['default light', defaultTheme],
['default dark', darkTheme],
['high contrast light', highContrastLightTheme],
['high contrast dark', highContrastDarkTheme],
])('edges %s focused fields in the focus ring color', (_name, theme: IThemeRGB) => {
expect(theme['rgb-border-field-focus']).toBe(theme['rgb-focus-control']);
});
it.each([
['clickhouse light', clickHouseLightTheme],
['clickhouse dark', clickHouseDarkTheme],
])('keeps the %s focused field edge at 3:1 on every field canvas', (_name, theme: IThemeRGB) => {
const edge = toRgb(theme, 'rgb-border-field-focus');
const canvases: Array<keyof IThemeRGB> = [
'rgb-surface-primary',
'rgb-presentation',
'rgb-surface-secondary',
'rgb-surface-dialog',
];
const failures = canvases.flatMap((canvas) => {
const ratio = contrast(edge, toRgb(theme, canvas));
return ratio < WCAG_MARK_MIN ? [`${canvas}: ${ratio.toFixed(2)}:1`] : [];
});
expect(failures).toEqual([]);
});
it.each([
['clickhouse light', clickHouseLightTheme],
['clickhouse dark', clickHouseDarkTheme],

View file

@ -106,6 +106,8 @@ describe('LibreChat Tailwind preset', () => {
['h-theme-switch', '--theme-switch-height', defaultAppearance.switchHeight],
['h-theme-button', '--theme-button-height', defaultAppearance.buttonHeight],
['h-theme-button-sm', '--theme-button-height-sm', defaultAppearance.buttonHeightSm],
['h-theme-field', '--theme-field-height', defaultAppearance.fieldHeight],
['py-theme-field-y', '--theme-field-padding-y', defaultAppearance.fieldPaddingY],
['font-theme-control', '--theme-control-font-weight', defaultAppearance.controlFontWeight],
['px-theme-dialog-x', '--theme-dialog-padding-x', defaultAppearance.dialogPaddingX],
[
@ -240,6 +242,7 @@ describe('LibreChat Tailwind preset', () => {
const aliases = {
controlPaddingX: 'spaceNormal',
controlGap: 'spaceCompact',
labelSize: 'textSm',
dialogTitleSize: 'textLg',
dialogTitleFontFamily: 'displayFontFamily',
};

View file

@ -105,6 +105,7 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-border-xheavy': '128 134 145', // #808691 (palette.slate.500, two steps past stroke.intense #b3b6bd (2.03:1 on white))
'rgb-border-destructive': '193 0 0', // #c10000 (palette.danger.600)
'rgb-border-control': '128 134 145', // #808691 (palette.slate.500, 3.42:1 on background.muted)
'rgb-border-field-focus': '22 21 23', // #161517 (field.color.stroke.active)
'rgb-surface-disabled': '223 223 223', // #dfdfdf (button.basic.color.primary.background.disabled)
'rgb-text-disabled': '160 160 160', // #a0a0a0 (text.disabled)
'rgb-border-disabled': '223 223 223', // #dfdfdf (field.color.stroke.disabled)
@ -248,6 +249,7 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-border-xheavy': '128 128 128', // #808080 (palette.neutral.500, three steps past stroke.intense #414141 (1.62:1 on the canvas))
'rgb-border-destructive': '255 117 117', // #ff7575 (palette.danger.300)
'rgb-border-control': '128 128 128', // #808080 (palette.neutral.500, 3.73:1 on background.muted)
'rgb-border-field-focus': '250 255 105', // #faff69 (field.color.stroke.active)
'rgb-surface-disabled': '65 65 65', // #414141 (button.basic.color.primary.background.disabled)
'rgb-text-disabled': '128 128 128', // #808080 (text.disabled)
'rgb-border-disabled': '65 65 65', // #414141 (field.color.stroke.disabled)
@ -378,6 +380,17 @@ const clickHouseShape = {
* 0.875rem/1.5 label and a 1px stroke, 32px in all. */
buttonHeight: '2rem',
buttonHeightSm: '2rem',
/** 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
* that color on keyboard focus only, to keep its 2px focus floor. */
fieldHeight: '2rem',
fieldPaddingY: '0.2813rem', // field.space.y
fieldFocusStyle: 'border' as const,
/** `field.typography.label.default`: 500 0.75rem/1.5. */
labelSize: '0.75rem',
labelLeading: '1.5',
labelFontWeight: '500',
dialogStroke: '1px', // dialog.stroke.default, in stroke.default (border-light)
dialogPaddingX: '2rem', // dialog.space.x; its space.y is LibreChat's 1.5rem
dialogHeaderGap: '0.25rem', // dialog.title.space.gap

View file

@ -38,9 +38,12 @@
"click.dialog.title.space.gap": "0.25rem",
"click.dialog.typography.title.default": "700 1.25rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.field.color.background.default": "#fbfcff",
"click.field.color.stroke.active": "#161517",
"click.field.color.stroke.default": "#e6e7e9",
"click.field.color.stroke.disabled": "#dfdfdf",
"click.field.color.text.default": "#302e32",
"click.field.space.y": "0.2813rem",
"click.field.typography.label.default": "500 0.75rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#c10000",
"click.global.color.text.warning": "#a33c00",
@ -160,9 +163,12 @@
"click.dialog.title.space.gap": "0.25rem",
"click.dialog.typography.title.default": "700 1.25rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.field.color.background.default": "rgb(17.794% 17.794% 17.794%)",
"click.field.color.stroke.active": "#faff69",
"click.field.color.stroke.default": "rgb(23.627% 23.627% 23.627%)",
"click.field.color.stroke.disabled": "#414141",
"click.field.color.text.default": "#e6e7e9",
"click.field.space.y": "0.2813rem",
"click.field.typography.label.default": "500 0.75rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#ffbaba",
"click.global.color.text.warning": "#ffb88f",

View file

@ -117,6 +117,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-border-xheavy': 'palette.slate.500',
'rgb-border-destructive': 'palette.danger.600',
'rgb-border-control': 'palette.slate.500',
'rgb-border-field-focus': 'click.field.color.stroke.active',
'rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled',
'rgb-text-disabled': 'global.color.text.disabled',
'rgb-border-disabled': 'click.field.color.stroke.disabled',
@ -230,6 +231,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-border-xheavy': 'palette.neutral.500',
'rgb-border-destructive': 'palette.danger.300',
'rgb-border-control': 'palette.neutral.500',
'rgb-border-field-focus': 'click.field.color.stroke.active',
'rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled',
'rgb-text-disabled': 'global.color.text.disabled',
'rgb-border-disabled': 'click.field.color.stroke.disabled',
@ -445,6 +447,18 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDeci
status: 'match',
reason: '2rem: Click UI draws one button size, so the small step matches the default',
},
fieldHeight: {
value: '2rem',
status: 'match',
reason:
'2rem: Click UI sizes its field by content, field.space.y (0.2813rem) twice, a 0.875rem/1.5 value and a 1px stroke each side',
},
fieldFocusStyle: {
value: 'border',
status: 'match',
reason:
'border: Click UI InputWrapper swaps the stroke to field.color.stroke.active on focus; keyboard focus adds a 1px ring in that color to hold the 2px focus floor',
},
};
const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
@ -491,6 +505,10 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
dialogTitleLeading: 'click.dialog.typography.title.default',
dialogTitleFontWeight: 'click.dialog.typography.title.default',
dialogTitleFontFamily: 'click.dialog.typography.title.default',
fieldPaddingY: 'click.field.space.y',
labelSize: 'click.field.typography.label.default',
labelLeading: 'click.field.typography.label.default',
labelFontWeight: 'click.field.typography.label.default',
scrimOpacity: 'click.dialog.color.opaqueBackground.default',
alertScrimOpacity: 'click.dialog.color.opaqueBackground.default',
modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',
@ -662,6 +680,9 @@ const fontShorthandParts: Partial<
dialogTitleSize: 'size',
dialogTitleLeading: 'leading',
dialogTitleFontFamily: 'family',
labelFontWeight: 'weight',
labelSize: 'size',
labelLeading: 'leading',
};
function comparable(key: keyof IThemeAppearance, raw: string | number): string {
@ -1161,7 +1182,7 @@ const sizeRoles: Record<SizeUtility, Record<string, keyof IThemeAppearance>> = {
'theme-button': 'buttonHeight',
'theme-button-sm': 'buttonHeightSm',
},
py: { 'theme-table-cell': 'tableCellSpaceY' },
py: { 'theme-table-cell': 'tableCellSpaceY', 'theme-field-y': 'fieldPaddingY' },
px: { 'theme-control-x': 'controlPaddingX', 'theme-dialog-x': 'dialogPaddingX' },
gap: { 'theme-control-gap': 'controlGap' },
};

View file

@ -79,6 +79,7 @@ export const darkTheme: IThemeRGB = {
'rgb-border-xheavy': '153 150 150', // #999696 (gray-400)
'rgb-border-destructive': '239 68 68', // #ef4444 (red-500)
'rgb-border-control': '33 33 33', // #212121 (gray-800), the stock field edge
'rgb-border-field-focus': '236 236 236', // #ececec (gray-100, matching focus-control)
'rgb-surface-disabled': '47 47 47', // #2f2f2f (gray-700)
'rgb-text-disabled': '153 150 150', // #999696 (gray-400)
'rgb-border-disabled': '57 57 57', // #393939 (gray-650)

View file

@ -79,6 +79,7 @@ export const defaultTheme: IThemeRGB = {
'rgb-border-xheavy': '89 89 89', // #595959 (gray-500)
'rgb-border-destructive': '220 38 38', // #dc2626 (red-600)
'rgb-border-control': '227 227 227', // #e3e3e3 (gray-200), the stock field edge
'rgb-border-field-focus': '33 33 33', // #212121 (gray-800, matching focus-control)
'rgb-surface-disabled': '236 236 236', // #ececec (gray-100)
'rgb-text-disabled': '153 150 150', // #999696 (gray-400)
'rgb-border-disabled': '227 227 227', // #e3e3e3 (gray-200)

View file

@ -115,6 +115,7 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-border-xheavy': '0 0 0', // #000000
'rgb-border-destructive': '161 0 0', // #a10000
'rgb-border-control': '0 0 0', // #000000
'rgb-border-field-focus': '0 0 0', // #000000 (matching focus-control)
'rgb-surface-disabled': '255 255 255', // #ffffff
'rgb-text-disabled': '87 87 87', // #575757
'rgb-border-disabled': '87 87 87', // #575757
@ -275,6 +276,7 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-border-xheavy': '255 255 255', // #ffffff
'rgb-border-destructive': '255 143 143', // #ff8f8f
'rgb-border-control': '255 255 255', // #ffffff
'rgb-border-field-focus': '255 255 255', // #ffffff (matching focus-control)
'rgb-surface-disabled': '0 0 0', // #000000
'rgb-text-disabled': '184 184 184', // #b8b8b8
'rgb-border-disabled': '184 184 184', // #b8b8b8

View file

@ -102,6 +102,8 @@
--color-border-xheavy: rgb(var(--border-xheavy) / var(--border-xheavy-alpha, 1));
--color-border-destructive: rgb(var(--border-destructive));
--color-border-control: rgb(var(--border-control));
/* Falls back to the focus ring color, for a stylesheet that predates it. */
--color-border-field-focus: rgb(var(--border-field-focus, var(--focus-control)));
--color-border-disabled: rgb(var(--border-disabled));
/* status */
@ -205,3 +207,7 @@
* `rc-input-number` renders its input inside the element that takes the
* component's classes. */
@custom-variant theme-disabled-within (&:is([data-theme-disabled='fill'] *):has(:disabled));
/* A theme whose `fieldFocusStyle` is `border` swaps a focused field's edge color instead of
* drawing a ring; `applyTheme` mirrors that choice as `data-theme-field-focus` on the root. */
@custom-variant theme-field-border (&:is([data-theme-field-focus='border'] *));

View file

@ -91,6 +91,9 @@ export interface IThemeRGB {
* 3:1 non-text floor on every canvas, so it is kept apart from the separator
* roles above, which stay quiet. */
'rgb-border-control'?: string;
/** A field's edge while it holds focus, under `fieldFocusStyle: 'border'`; follows
* `rgb-focus-control` when a theme omits it. */
'rgb-border-field-focus'?: string;
/** Disabled fill, ink and edge. Painted only under the `fill` disabled style. */
'rgb-surface-disabled'?: string;
'rgb-text-disabled'?: string;
@ -258,6 +261,7 @@ export interface IThemeVariables {
'--border-xheavy-alpha': string;
'--border-destructive': string;
'--border-control': string;
'--border-field-focus': string;
'--surface-disabled': string;
'--text-disabled': string;
'--border-disabled': string;
@ -378,6 +382,7 @@ export interface IThemeColors {
'border-xheavy'?: string;
'border-destructive'?: string;
'border-control'?: string;
'border-field-focus'?: string;
'surface-disabled'?: string;
'text-disabled'?: string;
'border-disabled'?: string;
@ -455,6 +460,20 @@ export interface IThemeAppearance {
controlFontWeight: string;
buttonHeight: string;
buttonHeightSm: 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 field's vertical padding, which has to leave its line room inside `fieldHeight`. */
fieldPaddingY: string;
fieldFocusStyle: 'ring' | 'border';
/** A field label's size, leading and weight. The size follows `textSm` when a theme omits it,
* and the default weight is `inherit`. */
labelSize: string;
labelLeading: string;
labelFontWeight: string;
switchWidth: string;
switchHeight: string;
tableCellSpaceY: string;

View file

@ -5,6 +5,7 @@ import applyTheme, {
themeOwnedProperties,
THEME_DISABLED_ATTRIBUTE,
THEME_SCOPE_ATTRIBUTE,
THEME_FIELD_FOCUS_ATTRIBUTE,
} from './applyTheme';
import { defaultAppearance, highContrastTheme, resolveTheme } from '../registry';
import { defaultTheme } from '../themes/default';
@ -439,6 +440,33 @@ describe('applyTheme', () => {
expect(root.style.getPropertyValue('--avatar-placeholder')).toBe('1 2 3');
});
it('marks the root only for a theme that focuses fields by their edge, and clears it', () => {
const root = document.documentElement;
const border: ThemeDefinition = {
version: 1,
name: 'field-border-reference',
modes: { light: { appearance: { fieldFocusStyle: 'border' } } },
};
applyResolvedTheme(resolveTheme(border, 'light'), root);
expect(root.getAttribute(THEME_FIELD_FOCUS_ATTRIBUTE)).toBe('border');
applyResolvedTheme(resolveTheme({ ...border, modes: {} }, 'light'), root);
expect(root.hasAttribute(THEME_FIELD_FOCUS_ATTRIBUTE)).toBe(false);
applyResolvedTheme(resolveTheme(border, 'light'), root);
clearAppliedTheme(root);
expect(root.hasAttribute(THEME_FIELD_FOCUS_ATTRIBUTE)).toBe(false);
});
it('focuses the fields of a legacy theme in the focus color it names', () => {
const root = document.documentElement;
applyTheme({ 'rgb-focus-control': '30 31 32' }, root, defaultTheme);
expect(root.style.getPropertyValue('--border-field-focus')).toBe('30 31 32');
});
it('keeps the switch knob of a legacy theme on the surface it repainted', () => {
const root = document.documentElement;

View file

@ -104,6 +104,12 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]>
if (colors['rgb-focus-control'] === undefined && focus['rgb-focus-control'] !== undefined) {
variables.push(['--focus-control', focus['rgb-focus-control']]);
}
if (
colors['rgb-border-field-focus'] === undefined &&
focus['rgb-border-field-focus'] !== undefined
) {
variables.push(['--border-field-focus', focus['rgb-border-field-focus']]);
}
const pressed = pressedFallbacks(colors);
if (colors['rgb-surface-pressed'] === undefined && pressed['rgb-surface-pressed'] !== undefined) {
@ -173,11 +179,18 @@ export const THEME_DISABLED_ATTRIBUTE = 'data-theme-disabled';
*/
export const THEME_SCOPE_ATTRIBUTE = 'data-theme-scope';
/**
* Mirrors the applied theme's `fieldFocusStyle` on the root, where the `theme-field-border:`
* variant reads it. Absent means the default `ring` style.
*/
export const THEME_FIELD_FOCUS_ATTRIBUTE = 'data-theme-field-focus';
export function clearAppliedTheme(root: HTMLElement = document.documentElement): void {
themeOwnedProperties.forEach((property) => root.style.removeProperty(property));
root.removeAttribute('data-theme');
root.removeAttribute(THEME_DISABLED_ATTRIBUTE);
root.removeAttribute(THEME_SCOPE_ATTRIBUTE);
root.removeAttribute(THEME_FIELD_FOCUS_ATTRIBUTE);
}
export function applyResolvedTheme(
@ -199,6 +212,11 @@ export function applyResolvedTheme(
} else {
root.removeAttribute(THEME_DISABLED_ATTRIBUTE);
}
if (theme.appearance.fieldFocusStyle === 'border') {
root.setAttribute(THEME_FIELD_FOCUS_ATTRIBUTE, 'border');
} else {
root.removeAttribute(THEME_FIELD_FOCUS_ATTRIBUTE);
}
}
/**

View file

@ -10,14 +10,31 @@ import { extendTailwindMerge } from 'tailwind-merge';
const twMerge = extendTailwindMerge({
extend: {
classGroups: {
py: [{ py: ['theme-table-cell', 'theme-table-cell-compact', 'theme-table-cell-dense'] }],
py: [
{
py: [
'theme-table-cell',
'theme-table-cell-compact',
'theme-table-cell-dense',
'theme-field-y',
],
},
],
h: [
{ h: ['theme-table-head', 'theme-table-head-compact', 'theme-button', 'theme-button-sm'] },
{
h: [
'theme-table-head',
'theme-table-head-compact',
'theme-button',
'theme-button-sm',
'theme-field',
],
},
],
px: [{ px: ['theme-control-x', 'theme-dialog-x'] }],
gap: [{ gap: ['theme-control-gap'] }],
'space-y': [{ 'space-y': ['theme-dialog-header'] }],
'font-weight': [{ font: ['theme-control', 'theme-dialog-title-weight'] }],
'font-weight': [{ font: ['theme-control', 'theme-dialog-title-weight', 'theme-label'] }],
'font-family': [{ font: ['theme-dialog-title'] }],
},
},

View file

@ -14,6 +14,8 @@ module.exports = {
'theme-control': 'var(--theme-control-font-weight, 500)',
/** A dialog title's weight; `-weight` keeps it apart from the family of the same name. */
'theme-dialog-title-weight': 'var(--theme-dialog-title-font-weight, 600)',
/** A field label's weight, the weight of the text around it by default. */
'theme-label': 'var(--theme-label-font-weight, inherit)',
},
height: {
'theme-control': 'var(--theme-control-height, 2.25rem)',
@ -21,6 +23,8 @@ 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-field': 'var(--theme-field-height, 2.5rem)',
/** 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. */
@ -41,6 +45,8 @@ module.exports = {
'theme-control-gap': 'var(--theme-control-gap, var(--theme-space-compact, 0.375rem))',
/** A dialog's inline padding and the gap between its title and description. */
'theme-dialog-x': 'var(--theme-dialog-padding-x, 1.5rem)',
/** A form field's vertical padding. */
'theme-field-y': 'var(--theme-field-padding-y, 0.5rem)',
'theme-dialog-header': 'var(--theme-dialog-header-gap, 0.375rem)',
/**
* The comfortable tap target (2.75rem / 44px), held against the theme's

View file

@ -77,6 +77,7 @@ export const themeColorTokens = Object.freeze([
'rgb-border-xheavy',
'rgb-border-destructive',
'rgb-border-control',
'rgb-border-field-focus',
'rgb-surface-disabled',
'rgb-text-disabled',
'rgb-border-disabled',
@ -328,6 +329,15 @@ const appearanceValidators = {
controlFontWeight: isFontWeight,
buttonHeight: isLength,
buttonHeightSm: isLength,
/** A form field's height and vertical padding, and whether focus draws a ring or swaps the
* field's edge color. */
fieldHeight: isLength,
fieldPaddingY: isLength,
fieldFocusStyle: (value: unknown) => value === 'ring' || value === 'border',
/** A field label's size, leading and weight; `inherit` keeps the weight of the text around it. */
labelSize: isLength,
labelLeading: isLineHeight,
labelFontWeight: (value: unknown) => value === 'inherit' || isFontWeight(value),
switchWidth: isSwitchLength,
switchHeight: isSwitchLength,
tableCellSpaceY: isTableLength,