Skip to content

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

🗂️ feat: Give the Table Theme Roles for Header Text, Row Rules and Density (#16489)

Marco Berettad8797b227c5a
diff --git a/client/src/components/Chat/Input/Files/Table/DataTable.tsx b/client/src/components/Chat/Input/Files/Table/DataTable.tsx
index 15d10aee97..797ee3ec76 100644
--- a/client/src/components/Chat/Input/Files/Table/DataTable.tsx
+++ b/client/src/components/Chat/Input/Files/Table/DataTable.tsx
@@ -145,7 +145,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
<TableHead
key={header.id}
size="sm"
- className="px-2 py-2 whitespace-nowrap sm:px-4"
+ className="px-2 whitespace-nowrap sm:px-4"
style={{ ...style }}
>
{header.isPlaceholder
@@ -170,8 +170,9 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
return (
<TableCell
key={cell.id}
+ size="compact"
className={cn(
- 'align-start px-2 py-1 text-xs sm:px-4 sm:py-2 sm:text-sm [tr[data-disabled=true]_&]:opacity-50',
+ 'align-start px-2 text-xs sm:px-4 sm:text-sm [tr[data-disabled=true]_&]:opacity-50',
cell.column.id === 'select' ? 'overflow-visible' : 'overflow-x-auto',
)}
style={style}
diff --git a/e2e/specs/mock/scenarios/clickhouse-table.spec.ts b/e2e/specs/mock/scenarios/clickhouse-table.spec.ts
new file mode 100644
index 0000000000..3c3af0a864
--- /dev/null
+++ b/e2e/specs/mock/scenarios/clickhouse-table.spec.ts
@@ -0,0 +1,233 @@
+import { randomUUID } from 'crypto';
+import { expect, test } from '@playwright/test';
+import { FileSources } from 'librechat-data-provider';
+import type { TFile } from 'librechat-data-provider';
+import type { Page } from '@playwright/test';
+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
+import { deleteConversations, withMongo } from '../db';
+import { getE2EUser } from '../../../setup/user';
+
+/**
+ * The shared table reads its header text, its row rule and its cell density from theme roles.
+ * Click UI rules its rows with a 1px `stroke.default` and names columns in `text.default`;
+ * LibreChat's own table has no rules and secondary column names, and keeps them without a theme.
+ * The My Files table is a real consumer of the primitive, with a routed file list.
+ */
+test.describe.configure({ timeout: 120_000 });
+test.use({ viewport: { width: 1280, height: 800 } });
+
+type Mode = 'light' | 'dark';
+type ThemeChoice = 'clickhouse' | 'default' | 'dense';
+
+/** The ClickHouse theme with half the table cell space, to show the role reaching real tables. */
+const denseTheme = {
+ ...clickHouseTheme,
+ name: 'clickhouse-dense',
+ modes: Object.fromEntries(
+ Object.entries(clickHouseTheme.modes).map(([mode, definition]) => [
+ mode,
+ { ...definition, appearance: { ...definition?.appearance, tableCellSpaceY: '0.5rem' } },
+ ]),
+ ),
+};
+
+const files: TFile[] = Array.from({ length: 3 }, (_, index) => ({
+ file_id: `table-theme-file-${index}`,
+ filename: `Table theme fixture ${index}.txt`,
+ filepath: `/files/table-theme-file-${index}.txt`,
+ user: 'table-theme-user',
+ bytes: 100,
+ object: 'file',
+ source: FileSources.local,
+ type: 'text/plain',
+ usage: 0,
+ embedded: false,
+ createdAt: '2026-09-01T00:00:00.000Z',
+ updatedAt: '2026-09-01T00:00:00.000Z',
+}));
+
+/** One init script per page; the theme and mode each navigation wants ride in its URL. */
+async function installThemeBridge(page: Page) {
+ await page.addInitScript(
+ (definitions) => {
+ const params = new URL(location.href).searchParams;
+ const theme = params.get('e2eTheme');
+ const mode = params.get('e2eThemeMode');
+ if (theme === null || mode === null) {
+ return;
+ }
+ localStorage.setItem('color-theme', mode);
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ const definition = (definitions as Record<string, unknown>)[theme];
+ if (definition) {
+ localStorage.setItem('theme-definition', JSON.stringify(definition));
+ localStorage.setItem('theme-source', 'definition');
+ } else {
+ localStorage.removeItem('theme-definition');
+ localStorage.removeItem('theme-source');
+ }
+ },
+ { clickhouse: clickHouseTheme, dense: denseTheme },
+ );
+}
+
+async function measureFilesTable(page: Page, theme: ThemeChoice, mode: Mode) {
+ await page.goto(`/c/new?e2eTheme=${theme}&e2eThemeMode=${mode}`, { timeout: 15000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menu').getByRole('menuitem', { name: 'My Files', exact: true }).click();
+ const dialog = page.getByRole('dialog', { name: 'My Files' });
+ const header = dialog.locator('thead');
+ await expect(header).toBeVisible();
+ await expect(dialog.getByText(files[0].filename)).toBeVisible();
+ const readings = await header.evaluate((thead) => {
+ const cell = thead.querySelector('th') as HTMLElement;
+ const firstBodyCell = thead.parentElement?.querySelector('tbody td') as HTMLElement;
+ /** Read off cells: under separated borders a row's own border is never drawn. */
+ return {
+ headerFill: getComputedStyle(thead).backgroundColor,
+ headerText: getComputedStyle(cell).color,
+ headerRule: getComputedStyle(cell).borderBottomWidth,
+ rowRule: getComputedStyle(firstBodyCell).borderBottomWidth,
+ ruleColor: getComputedStyle(firstBodyCell).borderBottomColor,
+ };
+ });
+ await page.keyboard.press('Escape');
+ return readings;
+}
+
+const rgb = (triplet: string | undefined) => `rgb(${(triplet ?? '').split(' ').join(', ')})`;
+
+test.describe('theme table', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.route('**/api/files', (route) => route.fulfill({ json: files }));
+ await installThemeBridge(page);
+ });
+
+ test('the files table takes Click UI header text, fill and row rules under the ClickHouse theme @scenario:clickhouse-table-follows-click-ui', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as Mode[]) {
+ const colors = clickHouseTheme.modes[mode]?.colors ?? {};
+ const readings = await measureFilesTable(page, 'clickhouse', mode);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');
+
+ expect(readings).toEqual({
+ headerFill: rgb(colors['rgb-surface-secondary']),
+ headerText: rgb(colors['rgb-table-header-text']),
+ headerRule: '1px',
+ rowRule: '1px',
+ ruleColor: rgb(colors['rgb-border-light']),
+ });
+ }
+ });
+
+ test('the default theme keeps an unruled table with secondary column names @scenario:default-theme-table-unchanged', async ({
+ page,
+ }) => {
+ for (const mode of ['light', 'dark'] as Mode[]) {
+ const readings = await measureFilesTable(page, 'default', mode);
+ const expected = await page.evaluate(() => {
+ const root = getComputedStyle(document.documentElement);
+ const color = (name: string) =>
+ `rgb(${root.getPropertyValue(name).trim().split(' ').join(', ')})`;
+ return { fill: color('--surface-secondary'), text: color('--text-secondary') };
+ });
+
+ expect(readings).toMatchObject({
+ headerFill: expected.fill,
+ headerText: expected.text,
+ headerRule: '0px',
+ rowRule: '0px',
+ });
+ }
+ });
+
+ test('the table cell space reaches the data tables that draw compact rows @scenario:table-density-role-reaches-data-tables', async ({
+ page,
+ }) => {
+ const readings: Record<string, { cell: string; head: string }> = {};
+ for (const theme of ['default', 'clickhouse', 'dense'] as ThemeChoice[]) {
+ await page.goto(`/c/new?e2eTheme=${theme}&e2eThemeMode=light`, { timeout: 15000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menu').getByRole('menuitem', { name: 'My Files', exact: true }).click();
+ const dialog = page.getByRole('dialog', { name: 'My Files' });
+ await expect(dialog.getByText(files[0].filename)).toBeVisible();
+ readings[theme] = await dialog.locator('table').evaluate((table) => ({
+ cell: getComputedStyle(table.querySelector('tbody td') as HTMLElement).paddingTop,
+ head: getComputedStyle(table.querySelector('thead th') as HTMLElement).paddingTop,
+ }));
+ await page.keyboard.press('Escape');
+ }
+
+ /** Half the space from `sm` up: 8px at LibreChat's and Click UI's 1rem, 4px at 0.5rem. */
+ expect(readings).toEqual({
+ default: { cell: '8px', head: '8px' },
+ clickhouse: { cell: '8px', head: '8px' },
+ dense: { cell: '4px', head: '4px' },
+ });
+ });
+
+ test('the archived chats header takes the table header fill @scenario:archived-chats-header-follows-table-header-fill', async ({
+ page,
+ }) => {
+ const conversationId = randomUUID();
+ const { email } = getE2EUser();
+ await withMongo(async (db) => {
+ const user = await db.collection('users').findOne({ email });
+ await db.collection('conversations').insertOne({
+ conversationId,
+ title: 'Archived header fixture',
+ user: String(user?._id),
+ endpoint: 'openAI',
+ isArchived: true,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ __v: 0,
+ });
+ });
+
+ /** The header height less its text line: the cell space a theme sets, apart from the line
+ * height its own type scale draws. */
+ const spaces: Record<string, number> = {};
+ try {
+ for (const [theme, mode] of [
+ ['default', 'light'],
+ ['clickhouse', 'light'],
+ ['clickhouse', 'dark'],
+ ['dense', 'light'],
+ ] as Array<[ThemeChoice, Mode]>) {
+ await page.goto(`/c/new?e2eTheme=${theme}&e2eThemeMode=${mode}`, { timeout: 15000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menuitem', { name: 'Archived chats' }).click();
+ const dialog = page.getByRole('dialog', { name: 'Archived chats' });
+ await expect(dialog.getByText('Archived header fixture')).toBeVisible({ timeout: 15000 });
+ const header = dialog.locator('thead th').first();
+ const reading = await header.evaluate((cell) => ({
+ fill: getComputedStyle(cell).backgroundColor,
+ space: (cell as HTMLElement).offsetHeight - parseFloat(getComputedStyle(cell).lineHeight),
+ expected: (() => {
+ const root = getComputedStyle(document.documentElement);
+ return `rgb(${root.getPropertyValue('--surface-dialog').trim().split(' ').join(', ')})`;
+ })(),
+ }));
+
+ spaces[`${theme}-${mode}`] = reading.space;
+ if (theme === 'default') {
+ /** The dialog surface it always had. */
+ expect(reading.fill).toBe(reading.expected);
+ } else {
+ const colors = clickHouseTheme.modes[mode]?.colors ?? {};
+ expect(reading.fill).toBe(rgb(colors['rgb-table-header-fill']));
+ }
+ await page.keyboard.press('Escape');
+ }
+ /** ClickHouse keeps LibreChat's 1rem space around its own, taller text line; half the space
+ * takes half of it off each side of the header line. */
+ expect(spaces['clickhouse-light']).toBe(spaces['default-light']);
+ expect(spaces['dense-light']).toBe(spaces['default-light'] - 8);
+ } finally {
+ await deleteConversations([conversationId]);
+ }
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 0bae62134c..a8f7e5c572 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -272,7 +272,7 @@
},
"client/src/components/Chat/Input/Files/Table/DataTable.tsx": {
"shadcn/no-restyle": {
- "count": 17
+ "count": 14
},
"shadcn/no-unknown-classes": {
"count": 1
diff --git a/packages/client/src/components/DataTable.tsx b/packages/client/src/components/DataTable.tsx
index b9b06a5e6b..eff19def6b 100644
--- a/packages/client/src/components/DataTable.tsx
+++ b/packages/client/src/components/DataTable.tsx
@@ -16,6 +16,7 @@ import {
import type { Table as TTable } from '@tanstack/react-table';
import { Table, TableRow, TableBody, TableCell, TableHead, TableHeader } from './Table';
import { useMediaQuery, useLocalize, TranslationKeys } from '~/hooks';
+import { useTableRowHeight } from './DataTable/DataTable.hooks';
import AnimatedSearchInput from './AnimatedSearchInput';
import { TrashIcon, Spinner } from '~/svgs';
import { Skeleton } from './Skeleton';
@@ -81,12 +82,15 @@ const TableRowComponent = <TData, TValue>({
onSelectionChange,
index,
isSearching,
+ measureRef,
}: {
row: Row<TData>;
isSmallScreen: boolean;
onSelectionChange?: (rowId: string, selected: boolean) => void;
index: number;
isSearching: boolean;
+ /** Lets the virtualizer measure the row it rendered, whatever cells it carries. */
+ measureRef?: (node: HTMLTableRowElement | null) => void;
}) => {
const handleSelection = useCallback(
(value: boolean) => {
@@ -98,8 +102,10 @@ const TableRowComponent = <TData, TValue>({
return (
<TableRow
+ ref={measureRef}
+ data-index={index}
data-state={row.getIsSelected() ? 'selected' : undefined}
- className="motion-safe:animate-fadeIn border-b border-border-light transition-all duration-300 ease-out hover:bg-surface-secondary"
+ className="motion-safe:animate-fadeIn border-border-light hover:bg-surface-secondary border-b transition-all duration-300 ease-out"
style={{
animationDelay: `${index * 20}ms`,
transform: `translateY(${isSearching ? '4px' : '0'})`,
@@ -109,7 +115,7 @@ const TableRowComponent = <TData, TValue>({
{row.getVisibleCells().map((cell) => {
if (cell.column.id === 'select') {
return (
- <TableCell key={cell.id} className="px-2 py-1 transition-all duration-300">
+ <TableCell key={cell.id} size="dense" className="px-2 transition-all duration-300">
<SelectionCheckbox
checked={row.getIsSelected()}
onChange={handleSelection}
@@ -121,9 +127,12 @@ const TableRowComponent = <TData, TValue>({
if (cell.column.id === 'title') {
return (
+ /* A row's title, not a column name: it keeps the secondary text rather than the
+ column-header role the cell would otherwise take. */
<TableHead
key={cell.id}
- className="w-0 max-w-0 px-2 py-1 align-middle text-xs transition-all duration-300 sm:px-4 sm:py-2 sm:text-sm"
+ size="row"
+ className="text-text-secondary w-0 max-w-0 px-2 align-middle text-xs transition-all duration-300 sm:px-4 sm:text-sm"
style={getColumnStyle(
cell.column.columnDef as TableColumn<TData, TValue>,
isSmallScreen,
@@ -140,7 +149,8 @@ const TableRowComponent = <TData, TValue>({
return (
<TableCell
key={cell.id}
- className="w-0 max-w-0 overflow-visible px-2 py-1 align-middle text-xs transition-all duration-300 sm:px-4 sm:py-2 sm:text-sm"
+ size="compact"
+ className="w-0 max-w-0 overflow-visible px-2 align-middle text-xs transition-all duration-300 sm:px-4 sm:text-sm"
style={getColumnStyle(
cell.column.columnDef as TableColumn<TData, TValue>,
isSmallScreen,
@@ -198,7 +208,7 @@ const DeleteButton = memo(
<Spinner className="size-4" />
) : (
<>
- <TrashIcon className="size-3.5 text-text-destructive sm:size-4" />
+ <TrashIcon className="text-text-destructive size-3.5 sm:size-4" />
{!isSmallScreen && <span className="ml-2">Delete</span>}
</>
)}
@@ -286,13 +296,30 @@ export default function DataTable<TData, TValue>({
const { rows } = table.getRowModel();
+ /** The first guess for a row that has not rendered yet, from the columns it will carry: a
+ * title cell's height when there is one, a compact row otherwise. Both follow the theme's cell
+ * space and row rule, and rendered rows are measured. */
+ const hasTitleColumn = useMemo(
+ () =>
+ columns.some(
+ (column) =>
+ column.id === 'title' || ('accessorKey' in column && column.accessorKey === 'title'),
+ ),
+ [columns],
+ );
+ const rowHeight = useTableRowHeight(hasTitleColumn ? 'titled' : 'compact');
const rowVirtualizer = useVirtualizer({
count: rows.length,
getScrollElement: () => tableContainerRef.current,
- estimateSize: useCallback(() => 48, []),
+ estimateSize: useCallback(() => rowHeight, [rowHeight]),
overscan: 10,
});
+ /** The virtualizer caches row sizes, so a theme that changes the row height drops them. */
+ useEffect(() => {
+ rowVirtualizer.measure();
+ }, [rowHeight, rowVirtualizer]);
+
const virtualRows = rowVirtualizer.getVirtualItems();
const totalSize = rowVirtualizer.getTotalSize();
const paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
@@ -378,13 +405,13 @@ export default function DataTable<TData, TValue>({
const firstDataColumnIndex = tableColumns[0]?.id === 'select' ? 1 : 0;
return (
- <TableRow key={index} className="motion-safe:animate-fadeIn border-b border-border-light">
+ <TableRow key={index} className="motion-safe:animate-fadeIn border-border-light border-b">
{tableColumns.map((column, columnIndex) => {
const style = getColumnStyle(column as TableColumn<TData, TValue>, isSmallScreen);
const isFirstDataColumn = columnIndex === firstDataColumnIndex;
return (
- <TableCell key={column.id} className="px-2 py-1 sm:px-4 sm:py-2" style={style}>
+ <TableCell key={column.id} size="compact" className="px-2 sm:px-4" style={style}>
<Skeleton
className="h-6"
style={isFirstDataColumn ? { width: `${randomWidth}px` } : { width: '100%' }}
@@ -429,7 +456,7 @@ export default function DataTable<TData, TValue>({
<div
ref={tableContainerRef}
className={cn(
- 'relative min-h-0 max-w-full flex-1 overflow-x-auto overflow-y-auto rounded-md border border-border-light',
+ 'border-border-light relative min-h-0 max-w-full flex-1 overflow-x-auto overflow-y-auto rounded-md border',
'transition-all duration-300 ease-out',
isSearching && 'bg-surface-secondary/50',
className,
@@ -439,13 +466,13 @@ export default function DataTable<TData, TValue>({
unwrapped
className="w-full min-w-[300px] table-fixed border-separate border-spacing-0"
>
- <TableHeader className="sticky top-0 z-50 bg-surface-secondary">
+ <TableHeader className="bg-surface-secondary sticky top-0 z-50">
{table.getHeaderGroups().map((headerGroup) => (
- <TableRow key={headerGroup.id} className="border-b border-border-light">
+ <TableRow key={headerGroup.id} className="border-border-light border-b">
{headerGroup.headers.map((header) => (
<TableHead
key={header.id}
- className="whitespace-nowrap bg-surface-secondary px-2 py-2 text-left text-sm font-medium text-text-secondary sm:px-4"
+ className="bg-surface-secondary text-table-header-text px-2 text-left text-sm font-medium whitespace-nowrap sm:px-4"
style={getColumnStyle(
header.column.columnDef as TableColumn<TData, TValue>,
isSmallScreen,
@@ -484,6 +511,7 @@ export default function DataTable<TData, TValue>({
isSmallScreen={isSmallScreen}
index={virtualRow.index}
isSearching={isSearching}
+ measureRef={rowVirtualizer.measureElement}
/>
);
})}
diff --git a/packages/client/src/components/DataTable/DataTable.hooks.spec.ts b/packages/client/src/components/DataTable/DataTable.hooks.spec.ts
index 88e5b001f3..67ed2682c0 100644
--- a/packages/client/src/components/DataTable/DataTable.hooks.spec.ts
+++ b/packages/client/src/components/DataTable/DataTable.hooks.spec.ts
@@ -1,11 +1,12 @@
import { renderHook, act, waitFor } from '@testing-library/react';
+import type { TableColumn } from './DataTable.types';
import {
useDebounced,
useOptimizedRowSelection,
useColumnStyles,
useKeyboardNavigation,
+ useTableRowHeight,
} from './DataTable.hooks';
-import type { TableColumn } from './DataTable.types';
describe('DataTable Hooks', () => {
describe('useDebounced', () => {
@@ -468,3 +469,30 @@ describe('DataTable Hooks', () => {
});
});
});
+
+describe('useTableRowHeight', () => {
+ afterEach(() => {
+ document.documentElement.style.removeProperty('--theme-table-cell-space-y');
+ document.documentElement.style.removeProperty('--theme-table-row-stroke');
+ });
+
+ it('is 40px dense, 36px compact and 48px titled without a theme, the heights the tables drew', () => {
+ expect(renderHook(() => useTableRowHeight('dense')).result.current).toBe(40);
+ expect(renderHook(() => useTableRowHeight('compact')).result.current).toBe(36);
+ expect(renderHook(() => useTableRowHeight('titled')).result.current).toBe(48);
+ });
+
+ it('follows a theme that repaints the cell space and rules its rows', async () => {
+ const { result } = renderHook(() => useTableRowHeight('dense'));
+ const titled = renderHook(() => useTableRowHeight('titled'));
+
+ act(() => {
+ document.documentElement.style.setProperty('--theme-table-cell-space-y', '8px');
+ document.documentElement.style.setProperty('--theme-table-row-stroke', '1px');
+ });
+
+ await waitFor(() => expect(result.current).toBe(37));
+ /** The title cell's fixed height is a border box, so the rule sits inside it. */
+ expect(titled.result.current).toBe(32);
+ });
+});
diff --git a/packages/client/src/components/DataTable/DataTable.hooks.ts b/packages/client/src/components/DataTable/DataTable.hooks.ts
index ed062f0b4c..88e7547e11 100644
--- a/packages/client/src/components/DataTable/DataTable.hooks.ts
+++ b/packages/client/src/components/DataTable/DataTable.hooks.ts
@@ -1,4 +1,12 @@
-import { useState, useEffect, useMemo, SetStateAction, Dispatch, CSSProperties } from 'react';
+import {
+ useMemo,
+ useState,
+ useEffect,
+ useSyncExternalStore,
+ SetStateAction,
+ Dispatch,
+ CSSProperties,
+} from 'react';
import type { TableColumn } from './DataTable.types';
export function useDebounced<T>(value: T, delay: number): T {
@@ -142,3 +150,73 @@ export const useKeyboardNavigation = (
return { focusedRowIndex, setFocusedRowIndex };
};
+
+const DEFAULT_CELL_SPACE_PX = 16;
+
+/**
+ * A root custom property in px. The table roles only accept px or rem (zero allowed), so the value
+ * is read exactly against the root size; an unset property reads its `fallbackRem`, as the preset
+ * does.
+ */
+function readRootLength(property: string, fallbackRem: number): number {
+ if (typeof document === 'undefined') {
+ return fallbackRem * DEFAULT_CELL_SPACE_PX;
+ }
+ const style = getComputedStyle(document.documentElement);
+ const rootSize = parseFloat(style.fontSize) || DEFAULT_CELL_SPACE_PX;
+ const match = /^(\d*\.?\d+)(px|rem)?$/.exec(style.getPropertyValue(property).trim());
+ if (!match) {
+ return fallbackRem * rootSize;
+ }
+ return Number(match[1]) * (match[2] === 'rem' ? rootSize : 1);
+}
+
+type TableRowKind = 'dense' | 'compact' | 'titled';
+
+/**
+ * A row's height in px. A dense row holds 2rem of controls between a quarter of the cell space
+ * above and below; a compact row a 1.25rem text line between half the space above and below (its
+ * size from `sm` up); a titled row is as tall as its title cell, a header-sized cell of twice the
+ * space around a 1rem line. The dense and compact cells grow by the row rule under them; the title
+ * cell's fixed height is a border box that already holds it.
+ */
+function readTableRowHeight(kind: TableRowKind): number {
+ const rootSize =
+ typeof document === 'undefined'
+ ? DEFAULT_CELL_SPACE_PX
+ : parseFloat(getComputedStyle(document.documentElement).fontSize) || DEFAULT_CELL_SPACE_PX;
+ const space = readRootLength('--theme-table-cell-space-y', 1);
+ const stroke = readRootLength('--theme-table-row-stroke', 0);
+ const heights: Record<TableRowKind, number> = {
+ dense: 2 * rootSize + space / 2 + stroke,
+ compact: 1.25 * rootSize + space + stroke,
+ titled: rootSize + 2 * space,
+ };
+ return heights[kind];
+}
+
+/** The theme paints its appearance onto the root's inline style and class, so those are the
+ * changes worth re-reading on. */
+function subscribeToGeometry(onChange: () => void): () => void {
+ if (typeof MutationObserver === 'undefined' || typeof document === 'undefined') {
+ return () => undefined;
+ }
+ const observer = new MutationObserver(onChange);
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ['style', 'class'],
+ });
+ return () => observer.disconnect();
+}
+
+/**
+ * A table row's height in px (dense 40px, compact 36px, titled 48px by default), for geometry JavaScript has
+ * to know, such as a virtualized row. Follows a theme switch.
+ */
+export function useTableRowHeight(kind: TableRowKind): number {
+ return useSyncExternalStore(
+ subscribeToGeometry,
+ () => readTableRowHeight(kind),
+ () => ({ dense: 40, compact: 36, titled: 48 })[kind],
+ );
+}
diff --git a/packages/client/src/components/DataTable/DataTable.spec.tsx b/packages/client/src/components/DataTable/DataTable.spec.tsx
index e3809c9263..ba0a39d8f3 100644
--- a/packages/client/src/components/DataTable/DataTable.spec.tsx
+++ b/packages/client/src/components/DataTable/DataTable.spec.tsx
@@ -54,6 +54,7 @@ jest.mock('@tanstack/react-virtual', () => ({
})),
getTotalSize: () => count * size,
calculateRange: () => {},
+ measure: () => {},
measureElement: () => {},
scrollToIndex: () => {},
};
diff --git a/packages/client/src/components/DataTable/DataTable.tsx b/packages/client/src/components/DataTable/DataTable.tsx
index 5a822ad12c..860ee7e940 100644
--- a/packages/client/src/components/DataTable/DataTable.tsx
+++ b/packages/client/src/components/DataTable/DataTable.tsx
@@ -14,9 +14,9 @@ import {
type Table as TTable,
} from '@tanstack/react-table';
import type { DataTableProps, ProcessedDataRow } from './DataTable.types';
+import { useDebounced, useTableRowHeight, useOptimizedRowSelection } from './DataTable.hooks';
import { SelectionCheckbox, MemoizedTableRow, SkeletonRows } from './DataTableComponents';
import { Table, TableBody, TableHead, TableHeader, TableCell, TableRow } from '../Table';
-import { useDebounced, useOptimizedRowSelection } from './DataTable.hooks';
import { useMediaQuery, useLocalize } from '~/hooks';
import { DataTableSearch } from './DataTableSearch';
import { MorphIcon } from '../MorphIcon';
@@ -64,11 +64,16 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
virtualization: {
overscan = 10,
minRows = 50,
- rowHeight = 40,
+ rowHeight: configuredRowHeight,
fastOverscanMultiplier = 4,
} = {},
} = config || {};
+ /** A dense row follows the theme's cell space and row rule, 40px by default; a caller that
+ * sizes its own rows still wins. */
+ const denseRowHeight = useTableRowHeight('dense');
+ const rowHeight = configuredRowHeight ?? denseRowHeight;
+
const virtualizationActive = data.length >= minRows;
// Dynamic overscan for fast scrolling - increases rendered rows during rapid scroll
@@ -311,6 +316,12 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
overscan: dynamicOverscan,
});
+ /** The virtualizer caches every row's size, so a theme that changes the row height after mount
+ * has to drop those sizes, or offsets and the total height keep the old one. */
+ useEffect(() => {
+ rowVirtualizer.measure();
+ }, [rowHeight, rowVirtualizer]);
+
// Only read the virtualizer when active; the non-virtualized branch renders rows directly,
// so engaging it for small tables is wasted render-phase work.
const virtualRows = virtualizationActive ? rowVirtualizer.getVirtualItems() : [];
@@ -602,7 +613,8 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
className="shrink-0 table-auto border-separate border-spacing-0"
unwrapped={true}
>
- <TableHeader>
+ {/* Each header cell carries its own opaque fill (see below). */}
+ <TableHeader filled={false}>
{headerGroups.map((headerGroup) => (
<TableRow key={headerGroup.id} className="border-0 hover:bg-transparent">
{headerGroup.headers.map((header) => {
@@ -652,7 +664,7 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
<Button
type="button"
variant="ghost"
- className="group text-text-secondary hover:text-text-primary h-auto w-full justify-start gap-1 px-0 py-0 text-xs font-medium tracking-wide uppercase hover:bg-transparent md:gap-1.5"
+ className="group text-table-header-text hover:text-text-primary h-auto w-full justify-start gap-1 px-0 py-0 text-xs font-medium tracking-wide uppercase hover:bg-transparent md:gap-1.5"
onClick={header.column.getToggleSortingHandler()}
>
{renderedHeader}
@@ -677,7 +689,7 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
);
} else {
headerContent = (
- <div className="text-text-secondary flex items-center text-xs font-medium tracking-wide uppercase">
+ <div className="text-table-header-text flex items-center text-xs font-medium tracking-wide uppercase">
{renderedHeader}
</div>
);
@@ -687,11 +699,13 @@ function DataTable<TData extends Record<string, unknown>, TValue>({
<TableHead
key={header.id}
scope="col"
+ size="compact"
className={cn(
/* Stuck per cell rather than on <thead>, which does not stay
put once the table uses separated borders. The fill has to
- be opaque or virtualized rows show through it. */
- 'border-border-light bg-surface-dialog sticky top-0 z-10 h-9 border-b px-3 py-2 md:px-4',
+ be opaque or virtualized rows show through it, so it is its
+ own role, the dialog surface by default. */
+ 'border-border-light bg-table-header-fill sticky top-0 z-10 border-b px-3 md:px-4',
isSelectHeader && 'px-0 text-center',
canSort && 'cursor-pointer',
meta?.className,
diff --git a/packages/client/src/components/DataTable/DataTableComponents.spec.tsx b/packages/client/src/components/DataTable/DataTableComponents.spec.tsx
index 1ee2276184..0467b1dc31 100644
--- a/packages/client/src/components/DataTable/DataTableComponents.spec.tsx
+++ b/packages/client/src/components/DataTable/DataTableComponents.spec.tsx
@@ -1,7 +1,8 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
+import type { Row } from '@tanstack/react-table';
import type { TableColumn } from './DataTable.types';
-import { SelectionCheckbox, SkeletonRows } from './DataTableComponents';
+import { MemoizedTableRow, SelectionCheckbox, SkeletonRows } from './DataTableComponents';
// Mock the cn utility
jest.mock('~/utils', () => ({
@@ -335,3 +336,23 @@ describe('DataTableComponents', () => {
});
});
});
+
+describe('MemoizedTableRow', () => {
+ it('takes a new height when the theme changes the row height of a mounted row', () => {
+ const row = { original: {}, getVisibleCells: () => [] } as unknown as Row<
+ Record<string, unknown>
+ >;
+ const renderRow = (height: number) => (
+ <table>
+ <tbody>
+ <MemoizedTableRow row={row} selected={false} style={{ height }} />
+ </tbody>
+ </table>
+ );
+ const { container, rerender } = render(renderRow(40));
+
+ rerender(renderRow(37));
+
+ expect((container.querySelector('tr') as HTMLElement).style.height).toBe('37px');
+ });
+});
diff --git a/packages/client/src/components/DataTable/DataTableComponents.tsx b/packages/client/src/components/DataTable/DataTableComponents.tsx
index d9c23702ac..5923b1feb6 100644
--- a/packages/client/src/components/DataTable/DataTableComponents.tsx
+++ b/packages/client/src/components/DataTable/DataTableComponents.tsx
@@ -86,8 +86,9 @@ const TableRowComponent = <TData extends Record<string, unknown>>(
return (
<CellComponent
key={cell.id}
+ size="dense"
className={cn(
- 'max-w-0 truncate px-3 py-1 text-sm transition-colors',
+ 'max-w-0 truncate px-3 text-sm transition-colors',
'group-hover:bg-surface-secondary-alt group-data-[state=selected]:bg-surface-active',
cell.column.id === 'select' && 'w-8 p-1',
meta?.className,
@@ -127,7 +128,9 @@ export const MemoizedTableRow: React.MemoExoticComponent<(props: GenericRowProps
(prev: GenericRowProps, next: GenericRowProps) =>
prev.row.original === next.row.original &&
prev.selected === next.selected &&
- prev.cellsVersion === next.cellsVersion,
+ prev.cellsVersion === next.cellsVersion &&
+ /** The row height follows the theme, so a theme switch has to reach mounted rows. */
+ prev.style?.height === next.style?.height,
);
export const SkeletonRows: React.MemoExoticComponent<
@@ -165,11 +168,8 @@ export const SkeletonRows: React.MemoExoticComponent<
return (
<TableCell
key={columnKey}
- className={cn(
- 'px-3 py-1',
- meta?.className,
- meta?.desktopOnly && 'hidden md:table-cell',
- )}
+ size="dense"
+ className={cn('px-3', meta?.className, meta?.desktopOnly && 'hidden md:table-cell')}
>
<Skeleton className="h-6 w-full" />
</TableCell>
diff --git a/packages/client/src/components/Table.tsx b/packages/client/src/components/Table.tsx
index 2c95f36e0f..cf9a242f24 100644
--- a/packages/client/src/components/Table.tsx
+++ b/packages/client/src/components/Table.tsx
@@ -24,12 +24,22 @@ Table.displayName = 'Table';
interface TableHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {
sticky?: boolean;
+ /**
+ * The header row's fill, on by default so column names read as a header in any theme. A table
+ * whose header cells paint their own opaque fill turns it off, so a translucent cell state
+ * (a column being resized) still shows the surface behind the table.
+ */
+ filled?: boolean;
}
const tableHeaderVariants = cva('', {
variants: {
sticky: {
- true: 'bg-surface-secondary sticky top-0 z-50',
+ true: 'sticky top-0 z-50',
+ false: '',
+ },
+ filled: {
+ true: 'bg-surface-secondary',
false: '',
},
},
@@ -38,8 +48,12 @@ const tableHeaderVariants = cva('', {
const TableHeader: React.ForwardRefExoticComponent<
TableHeaderProps & React.RefAttributes<HTMLTableSectionElement>
> = React.forwardRef<HTMLTableSectionElement, TableHeaderProps>(
- ({ className, sticky = false, ...props }, ref) => (
- <thead ref={ref} className={cn(tableHeaderVariants({ sticky }), className)} {...props} />
+ ({ className, sticky = false, filled = true, ...props }, ref) => (
+ <thead
+ ref={ref}
+ className={cn(tableHeaderVariants({ sticky, filled }), className)}
+ {...props}
+ />
),
);
TableHeader.displayName = 'TableHeader';
@@ -80,30 +94,46 @@ const TableRow: React.ForwardRefExoticComponent<
);
TableRow.displayName = 'TableRow';
-/** A compact table's header: a side panel lists records rather than presenting
- * a grid, and a full-height, full-size heading over two text lines reads as
- * scaffolding rather than as the column names those rows sit under. */
+/**
+ * The rule a theme may draw under each row, 0px by default. It sits on the cells rather than the
+ * row: a table with separated borders, which is how the tables that round their hover rows are
+ * laid out, never draws a border on a `<tr>`.
+ */
+const tableCellRule = 'border-b-(length:--theme-table-row-stroke) border-border-light';
+
+/**
+ * A header cell's size. `sm` is a compact table's header: a side panel lists records rather than
+ * presenting a grid, and a full-height, full-size heading over two text lines reads as scaffolding
+ * rather than as the column names those rows sit under. `compact` keeps the header's own type on a
+ * compact row height, and `row` is a row's title rendered as a header cell, padded like the compact
+ * body cells beside it. Every padding and height reads the theme's table cell space.
+ */
const tableHeadVariants = cva('', {
variants: {
size: {
default: '',
- sm: 'h-auto text-xs',
+ sm: 'h-auto py-theme-table-cell-compact text-xs',
+ compact: 'h-theme-table-head-compact py-theme-table-cell-compact',
+ row: 'py-theme-table-cell-dense sm:py-theme-table-cell-compact',
},
},
defaultVariants: { size: 'default' },
});
+type TableHeadSize = 'default' | 'sm' | 'compact' | 'row';
+
const TableHead: React.ForwardRefExoticComponent<
React.ThHTMLAttributes<HTMLTableCellElement> &
- React.RefAttributes<HTMLTableCellElement> & { size?: 'default' | 'sm' }
+ React.RefAttributes<HTMLTableCellElement> & { size?: TableHeadSize }
> = React.forwardRef<
HTMLTableCellElement,
- React.ThHTMLAttributes<HTMLTableCellElement> & { size?: 'default' | 'sm' }
+ React.ThHTMLAttributes<HTMLTableCellElement> & { size?: TableHeadSize }
>(({ className, size, ...props }, ref) => (
<th
ref={ref}
className={cn(
- 'text-text-secondary h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
+ tableCellRule,
+ 'text-table-header-text h-theme-table-head px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
tableHeadVariants({ size }),
className,
)}
@@ -112,34 +142,63 @@ const TableHead: React.ForwardRefExoticComponent<
));
TableHead.displayName = 'TableHead';
+/**
+ * A body cell's vertical space, from the theme's table cell space: `default` is the full space,
+ * `compact` a quarter of it on a narrow screen and half from `sm` up, and `dense` a quarter at
+ * every width. Click UI's own table sizes halve the same way (`md` 1rem, `sm` 0.5rem).
+ */
+const tableCellVariants = cva('', {
+ variants: {
+ size: {
+ default: 'py-theme-table-cell',
+ compact: 'py-theme-table-cell-dense sm:py-theme-table-cell-compact',
+ dense: 'py-theme-table-cell-dense',
+ },
+ },
+ defaultVariants: { size: 'default' },
+});
+
+type TableCellSize = 'default' | 'compact' | 'dense';
+
const TableCell: React.ForwardRefExoticComponent<
- React.TdHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>
-> = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
- ({ className, ...props }, ref) => (
- <td
- ref={ref}
- className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
- {...props}
- />
- ),
-);
+ React.TdHTMLAttributes<HTMLTableCellElement> &
+ React.RefAttributes<HTMLTableCellElement> & { size?: TableCellSize }
+> = React.forwardRef<
+ HTMLTableCellElement,
+ React.TdHTMLAttributes<HTMLTableCellElement> & { size?: TableCellSize }
+>(({ className, size, ...props }, ref) => (
+ <td
+ ref={ref}
+ className={cn(
+ tableCellRule,
+ 'px-4 align-middle [&:has([role=checkbox])]:pr-0',
+ tableCellVariants({ size }),
+ className,
+ )}
+ {...props}
+ />
+));
TableCell.displayName = 'TableCell';
const TableRowHeader: React.ForwardRefExoticComponent<
- React.ThHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>
-> = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
- ({ className, ...props }, ref) => (
- <th
- ref={ref}
- scope="row"
- className={cn(
- 'p-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
- className,
- )}
- {...props}
- />
- ),
-);
+ React.ThHTMLAttributes<HTMLTableCellElement> &
+ React.RefAttributes<HTMLTableCellElement> & { size?: TableCellSize }
+> = React.forwardRef<
+ HTMLTableCellElement,
+ React.ThHTMLAttributes<HTMLTableCellElement> & { size?: TableCellSize }
+>(({ className, size, ...props }, ref) => (
+ <th
+ ref={ref}
+ scope="row"
+ className={cn(
+ tableCellRule,
+ 'px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
+ tableCellVariants({ size }),
+ className,
+ )}
+ {...props}
+ />
+));
TableRowHeader.displayName = 'TableRowHeader';
const TableCaption: React.ForwardRefExoticComponent<
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index ee891b2489..2b58c225f3 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -199,6 +199,8 @@ html {
--theme-control-height: 2.25rem;
--theme-switch-width: 2.75rem;
--theme-switch-height: 1.5rem;
+ --theme-table-cell-space-y: 1rem;
+ --theme-table-row-stroke: 0px;
--theme-space-compact: 0.375rem;
--theme-space-normal: 0.75rem;
--theme-disabled-style: dim;
@@ -240,6 +242,9 @@ html {
--theme-motion-normal: 200ms;
--switch-unchecked: 148 148 148;
--switch-thumb: 255 255 255;
+ /* Follows the secondary text it was before it had a role, in every mode. */
+ --table-header-text: var(--text-secondary);
+ --table-header-fill: var(--surface-dialog);
--provider-openai: #19c37d;
--provider-openai-gpt4: #ab68ff;
--provider-openai-reasoning: #000000;
diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts
index 5f2ec9d9ef..f3a39740b5 100644
--- a/packages/client/src/theme/defaults.spec.ts
+++ b/packages/client/src/theme/defaults.spec.ts
@@ -63,7 +63,7 @@ describe.each([
const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
it('covers every registry color', () => {
- expect(tokens).toHaveLength(104);
+ expect(tokens).toHaveLength(106);
});
it('resolves every registry color to the runtime theme value', () => {
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index f55a4a2f20..b51ff6a708 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -300,6 +300,22 @@ describe('theme registry', () => {
expect(resolved.colors['rgb-chart-widget-stroke']).toBe('50 51 52');
});
+ it('accepts table lengths in px or rem, zero included, and rejects other units', () => {
+ const withTable = (tableCellSpaceY: string, tableRowStroke: string) =>
+ ({
+ version: 1,
+ name: 'table',
+ modes: { light: { appearance: { tableCellSpaceY, tableRowStroke } } },
+ }) as ThemeDefinition;
+
+ expect(validateThemeDefinition(withTable('0.5rem', '0'))).toEqual([]);
+ expect(validateThemeDefinition(withTable('8px', '1px'))).toEqual([]);
+ expect(validateThemeDefinition(withTable('1em', 'calc(1px - 0px)'))).toEqual([
+ 'Invalid appearance value for tableCellSpaceY: 1em',
+ 'Invalid appearance value for tableRowStroke: calc(1px - 0px)',
+ ]);
+ });
+
describe('switch size pair', () => {
const withSwitch = (switchWidth: string, switchHeight: string) =>
({
@@ -386,6 +402,46 @@ describe('theme registry', () => {
expect(untouched.colors['rgb-switch-thumb']).toBe(darkTheme['rgb-switch-thumb']);
});
+ it('keeps a self-sticking table header on the dialog surface a theme repainted', () => {
+ const legacy = resolveTheme(
+ {
+ version: 1,
+ name: 'legacy-table-fill',
+ modes: { dark: { colors: { 'rgb-surface-dialog': '20 21 22' } } },
+ },
+ 'dark',
+ );
+
+ expect(legacy.colors['rgb-table-header-fill']).toBe('20 21 22');
+ expect(resolveTheme(libreChatTheme, 'dark').colors['rgb-table-header-fill']).toBe(
+ darkTheme['rgb-surface-dialog'],
+ );
+ });
+
+ it('keeps table column names on the secondary text a theme repainted', () => {
+ const legacy = resolveTheme(
+ {
+ version: 1,
+ name: 'legacy-table-header',
+ modes: { light: { colors: { 'rgb-text-secondary': '20 21 22' } } },
+ },
+ 'light',
+ );
+ const explicit = resolveTheme(
+ {
+ version: 1,
+ name: 'explicit-table-header',
+ modes: {
+ light: { colors: { 'rgb-text-secondary': '20 21 22', 'rgb-table-header-text': '1 2 3' } },
+ },
+ },
+ 'light',
+ );
+
+ expect(legacy.colors['rgb-table-header-text']).toBe('20 21 22');
+ expect(explicit.colors['rgb-table-header-text']).toBe('1 2 3');
+ });
+
it('keeps the light border a legacy theme drew its controls with', () => {
const resolved = resolveTheme(
{
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index 0923708ce6..a4ce393206 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -137,6 +137,8 @@ export const themeAppearanceProperties: Readonly<
controlHeight: '--theme-control-height',
switchWidth: '--theme-switch-width',
switchHeight: '--theme-switch-height',
+ tableCellSpaceY: '--theme-table-cell-space-y',
+ tableRowStroke: '--theme-table-row-stroke',
spaceCompact: '--theme-space-compact',
spaceNormal: '--theme-space-normal',
disabledStyle: '--theme-disabled-style',
@@ -183,6 +185,8 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
radius3xl: '1.5rem',
controlHeight: '2.25rem',
...defaultSwitchSize,
+ tableCellSpaceY: '1rem',
+ tableRowStroke: '0px',
spaceCompact: '0.375rem',
spaceNormal: '0.75rem',
disabledStyle: 'dim',
@@ -448,6 +452,18 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
customColors?.['rgb-surface-primary'] !== undefined
? { 'rgb-switch-thumb': customColors['rgb-surface-primary'] }
: {};
+ /** Table column names were `text-secondary` before they had a role. */
+ const tableHeaderTextFallback =
+ customColors?.['rgb-table-header-text'] === undefined &&
+ customColors?.['rgb-text-secondary'] !== undefined
+ ? { 'rgb-table-header-text': customColors['rgb-text-secondary'] }
+ : {};
+ /** Self-sticking table headers were the dialog surface before they had a role. */
+ const tableHeaderFillFallback =
+ customColors?.['rgb-table-header-fill'] === undefined &&
+ customColors?.['rgb-surface-dialog'] !== undefined
+ ? { 'rgb-table-header-fill': customColors['rgb-surface-dialog'] }
+ : {};
const chartWidgetStrokeFallback =
customColors?.['rgb-chart-widget-stroke'] === undefined &&
customColors?.['rgb-border-light'] !== undefined
@@ -520,6 +536,8 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...chartWidgetSurfaceFallback,
...chartWidgetStrokeFallback,
...switchThumbFallback,
+ ...tableHeaderTextFallback,
+ ...tableHeaderFillFallback,
...borderControlFallback,
...focusFallback,
...pressedFallback,
diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.ts
index 6a4e742b79..4bd0e6b687 100644
--- a/packages/client/src/theme/semanticTokens.spec.ts
+++ b/packages/client/src/theme/semanticTokens.spec.ts
@@ -528,6 +528,27 @@ describe.each([
});
});
+describe.each([
+ ['default', defaultTheme],
+ ['dark', darkTheme],
+ ['high contrast light', highContrastLightTheme],
+ ['high contrast dark', highContrastDarkTheme],
+ ['clickhouse light', clickHouseLightTheme],
+ ['clickhouse dark', clickHouseDarkTheme],
+])('%s table header', (_name, theme: IThemeRGB) => {
+ it('keeps column names readable on the header fill', () => {
+ expect(
+ contrast(toRgb(theme, 'rgb-table-header-text'), toRgb(theme, 'rgb-surface-secondary')),
+ ).toBeGreaterThanOrEqual(4.5);
+ });
+
+ it('keeps column names readable on a self-sticking header', () => {
+ expect(
+ contrast(toRgb(theme, 'rgb-table-header-text'), toRgb(theme, 'rgb-table-header-fill')),
+ ).toBeGreaterThanOrEqual(4.5);
+ });
+});
+
describe('switch track defaults', () => {
/** The app stylesheet only restates the registry now: the contrast modes used
* to carry their own `html.high-contrast` overrides here, which the published
@@ -545,6 +566,33 @@ describe('switch track defaults', () => {
]);
});
+ it('declares table column names on the secondary text they were before the role', () => {
+ const appStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
+
+ expect([...appStyles.matchAll(/--table-header-text:\s*([^;]+);/g)].map((m) => m[1])).toEqual([
+ 'var(--text-secondary)',
+ ]);
+ expect(defaultTheme['rgb-table-header-text']).toBe(defaultTheme['rgb-text-secondary']);
+ expect(darkTheme['rgb-table-header-text']).toBe(darkTheme['rgb-text-secondary']);
+ });
+
+ it('declares the self-sticking header fill on the dialog surface it was before the role', () => {
+ const appStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
+
+ expect([...appStyles.matchAll(/--table-header-fill:\s*([^;]+);/g)].map((m) => m[1])).toEqual([
+ 'var(--surface-dialog)',
+ ]);
+ [defaultTheme, darkTheme, highContrastLightTheme, highContrastDarkTheme].forEach((theme) =>
+ expect(theme['rgb-table-header-fill']).toBe(theme['rgb-surface-dialog']),
+ );
+ });
+
+ it('ships the no-rule table default with the package', () => {
+ const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
+
+ expect(stockStyles).toContain(`--theme-table-row-stroke: ${defaultAppearance.tableRowStroke};`);
+ });
+
it('declares the stock thumb the registry paints', () => {
const stockStyles = readFileSync(join(__dirname, 'defaults.css'), 'utf8');
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 3208c172b2..2bbf7cc41c 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -107,6 +107,23 @@ describe('LibreChat Tailwind preset', () => {
['w-theme-switch', '--theme-switch-width', defaultAppearance.switchWidth],
['size-theme-switch-thumb', '--theme-switch-height', defaultAppearance.switchHeight],
['translate-x-theme-switch-travel', '--theme-switch-width', defaultAppearance.switchWidth],
+ ['py-theme-table-cell', '--theme-table-cell-space-y', defaultAppearance.tableCellSpaceY],
+ ['h-theme-table-head', '--theme-table-cell-space-y', defaultAppearance.tableCellSpaceY],
+ [
+ 'h-theme-table-head-compact',
+ '--theme-table-cell-space-y',
+ defaultAppearance.tableCellSpaceY,
+ ],
+ [
+ 'py-theme-table-cell-compact',
+ '--theme-table-cell-space-y',
+ defaultAppearance.tableCellSpaceY,
+ ],
+ [
+ 'py-theme-table-cell-dense',
+ '--theme-table-cell-space-y',
+ defaultAppearance.tableCellSpaceY,
+ ],
['p-theme-compact', '--theme-space-compact', defaultAppearance.spaceCompact],
['p-theme-normal', '--theme-space-normal', defaultAppearance.spaceNormal],
['p-theme-control-touch', '--theme-control-height', defaultAppearance.controlHeight],
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index 6564bb2a37..6fed6c6a79 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -155,6 +155,10 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-switch-unchecked': '128 134 145', // #808691 (palette.slate.500)
'rgb-switch-thumb': '255 255 255', // #ffffff (switch.color.indicator.default)
+ // Table
+ 'rgb-table-header-text': '22 21 23', // #161517 (table.header.color.title.default)
+ 'rgb-table-header-fill': '246 247 250', // #f6f7fa (table.header.color.background.default)
+
// Presentation
'rgb-presentation': '255 255 255', // #ffffff (background.default)
};
@@ -288,6 +292,10 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-switch-unchecked': '128 128 128', // #808080 (palette.neutral.500)
'rgb-switch-thumb': '21 21 21', // #151515 (switch.color.indicator.default)
+ // Table
+ 'rgb-table-header-text': '249 249 249', // #f9f9f9 (table.header.color.title.default, rgb(97.5% 97.5% 97.5%))
+ 'rgb-table-header-fill': '40 40 40', // #282828 (table.header.color.background.default)
+
// Presentation
'rgb-presentation': '31 31 28', // #1f1f1c (background.default)
};
@@ -357,6 +365,10 @@ const clickHouseShape = {
disabledStyle: 'fill' as const,
switchWidth: '2rem', // switch.size.width
switchHeight: '1rem', // switch.size.height
+ /** 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. */
+ tableCellSpaceY: '1rem', // table.body.cell.space.md.y
+ tableRowStroke: '1px', // table.cell.stroke
motionFast: '100ms', // transition.duration.medium, the step transition.default runs at
motionNormal: '150ms', // transition.duration.smooth
};
diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json
index 1fe2f68ba4..e4705d9856 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -41,6 +41,9 @@
"click.switch.radii.all": "9999px",
"click.switch.size.height": "1rem",
"click.switch.size.width": "2rem",
+ "click.table.body.cell.space.md.y": "1rem",
+ "click.table.body.cell.space.sm.y": "0.5rem",
+ "click.table.cell.stroke": "1px",
"click.table.header.color.background.default": "#f6f7fa",
"click.table.header.color.title.default": "#161517",
"click.table.radii.all": "0.25rem",
@@ -145,6 +148,9 @@
"click.switch.radii.all": "9999px",
"click.switch.size.height": "1rem",
"click.switch.size.width": "2rem",
+ "click.table.body.cell.space.md.y": "1rem",
+ "click.table.body.cell.space.sm.y": "0.5rem",
+ "click.table.cell.stroke": "1px",
"click.table.header.color.background.default": "#282828",
"click.table.header.color.title.default": "rgb(97.5% 97.5% 97.5%)",
"click.table.radii.all": "0.25rem",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index 0c7821054e..bc9903e349 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -146,6 +146,8 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-series-8': 'global.color.chart.default.teal',
'rgb-switch-unchecked': 'palette.slate.500',
'rgb-switch-thumb': 'click.switch.color.indicator.default',
+ 'rgb-table-header-text': 'click.table.header.color.title.default',
+ 'rgb-table-header-fill': 'click.table.header.color.background.default',
'rgb-presentation': 'global.color.background.default',
},
dark: {
@@ -251,6 +253,8 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-series-8': 'global.color.chart.default.teal',
'rgb-switch-unchecked': 'palette.neutral.500',
'rgb-switch-thumb': 'click.switch.color.indicator.default',
+ 'rgb-table-header-text': 'click.table.header.color.title.default',
+ 'rgb-table-header-fill': 'click.table.header.color.background.default',
'rgb-presentation': 'global.color.background.default',
},
};
@@ -315,6 +319,8 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',
switchWidth: 'click.switch.size.width',
switchHeight: 'click.switch.size.height',
+ tableCellSpaceY: 'click.table.body.cell.space.md.y',
+ tableRowStroke: 'click.table.cell.stroke',
motionFast: 'transition.duration.medium',
motionNormal: 'transition.duration.smooth',
};
@@ -442,7 +448,7 @@ function comparable(key: keyof IThemeAppearance, raw: string | number): string {
* every decision; the floors below only move up.
*/
type ParityKind = 'color' | 'shape';
-type Utility = 'bg' | 'text' | 'border' | 'rounded' | 'w' | 'h';
+type Utility = 'bg' | 'text' | 'border' | 'rounded' | 'w' | 'h' | 'py';
interface ParityProbe {
/** The Click UI component token the primitive should reproduce. */
@@ -665,13 +671,39 @@ const parityProbes: Record<string, ParityProbe> = {
token: 'click.table.row.color.stroke.default',
kind: 'color',
utility: 'border',
- element: tableProbe('tbody tr'),
+ element: tableProbe('td'),
+ },
+ 'Table cell space': {
+ token: 'click.table.body.cell.space.md.y',
+ kind: 'shape',
+ utility: 'py',
+ element: tableProbe('td'),
+ },
+ 'Table compact cell space': {
+ token: 'click.table.body.cell.space.sm.y',
+ kind: 'shape',
+ utility: 'py',
+ variant: 'sm:',
+ element: () =>
+ mount(
+ createElement(
+ Table,
+ null,
+ createElement(
+ TableBody,
+ null,
+ createElement(TableRow, null, createElement(TableCell, { size: 'compact' }, 'Row')),
+ ),
+ ),
+ 'td',
+ ),
},
'Table corner': {
token: 'click.table.radii.all',
kind: 'shape',
utility: 'rounded',
element: tableProbe('div'),
+ deviation: 'the table has no frame of its own; each consumer draws the panel it sits in',
},
'Badge fill': {
token: 'click.badge.opaque.color.background.default',
@@ -701,8 +733,8 @@ const parityProbes: Record<string, ParityProbe> = {
/** The fewest decisions per mode that must match; raise a floor when a change closes a gap. */
const parityFloors: Record<ThemeMode, Record<ParityKind, number>> = {
- light: { color: 6, shape: 8 },
- dark: { color: 7, shape: 8 },
+ light: { color: 9, shape: 10 },
+ dark: { color: 10, shape: 10 },
};
const radiusRoles: Record<string, keyof IThemeAppearance> = {
@@ -720,23 +752,47 @@ const radiusRoles: Record<string, keyof IThemeAppearance> = {
const fixedRadii: Record<string, string> = { full: '9999px', none: '0px' };
-const sizeRoles: Record<'w' | 'h', Record<string, keyof IThemeAppearance>> = {
+type SizeUtility = 'w' | 'h' | 'py';
+
+const sizeRoles: Record<SizeUtility, Record<string, keyof IThemeAppearance>> = {
w: { 'theme-switch': 'switchWidth' },
h: { 'theme-switch': 'switchHeight', 'theme-control': 'controlHeight' },
+ py: { 'theme-table-cell': 'tableCellSpaceY' },
};
-/** A `border`, `border-2` or one-sided `border-b` class, the width a border color needs to show. */
-const drawsBorder = (classes: string[]) =>
- classes.some((name) => /^border(-[0-9]+|-[xytblrse](-[0-9]+)?)?$/.test(name));
+/** The compact and dense table sizes divide the cell space, as the preset does. */
+const derivedSizes: Record<string, [keyof IThemeAppearance, number]> = {
+ 'theme-table-cell-compact': ['tableCellSpaceY', 2],
+ 'theme-table-cell-dense': ['tableCellSpaceY', 4],
+};
+
+const isSizeUtility = (utility: Utility): utility is SizeUtility =>
+ utility === 'w' || utility === 'h' || utility === 'py';
+
+/** A `border`, `border-2` or one-sided `border-b` class, or a theme stroke role that is not
+ * zero: the width a border color needs to show. */
+const drawsBorder = (classes: string[], resolved: Resolved) =>
+ classes.some(
+ (name) =>
+ /^border(-[0-9]+|-[xytblrse](-[0-9]+)?)?$/.test(name) ||
+ (/^border(-[xytblrse])?-\(length:--theme-table-row-stroke\)$/.test(name) &&
+ parseFloat(resolved.appearance.tableRowStroke) > 0),
+ );
type Resolved = ReturnType<typeof resolveTheme>;
-/** A `w-*` or `h-*` step: a theme role, or Tailwind's 0.25rem spacing scale. */
-function sizeValue(utility: 'w' | 'h', name: string, resolved: Resolved): string | undefined {
+/** A `w-*`, `h-*` or `py-*` step: a theme role, or Tailwind's 0.25rem spacing scale. */
+function sizeValue(utility: SizeUtility, name: string, resolved: Resolved): string | undefined {
const role = sizeRoles[utility][name];
if (role !== undefined) {
return resolved.appearance[role];
}
+ const derived = utility === 'py' ? derivedSizes[name] : undefined;
+ if (derived !== undefined) {
+ const [source, divisor] = derived;
+ const value = resolved.appearance[source];
+ return `${parseFloat(value) / divisor}${value.replace(/^[\d.]+/, '')}`;
+ }
return /^[0-9.]+$/.test(name) ? `${Number(name) / 4}rem` : undefined;
}
@@ -763,11 +819,15 @@ function paintedRole(element: Element, probe: ParityProbe, resolved: Resolved):
if (probe.utility === 'rounded') {
return names.find((name) => name in radiusRoles || name in fixedRadii);
}
- if (probe.utility === 'w' || probe.utility === 'h') {
+ if (isSizeUtility(probe.utility)) {
const utility = probe.utility;
- return names.find((name) => sizeValue(utility, name, resolved) !== undefined);
+ /** `p-4` pads every side, so it answers a `py` probe too. */
+ const padding = utility === 'py' ? classes.filter((name) => /^p-[0-9.]+$/.test(name)) : [];
+ return [...names, ...padding.map((name) => name.slice(2))].find(
+ (name) => sizeValue(utility, name, resolved) !== undefined,
+ );
}
- if (probe.utility === 'border' && !drawsBorder(classes)) {
+ if (probe.utility === 'border' && !drawsBorder(classes, resolved)) {
return undefined;
}
return names.find((name) => roleColor(resolved, name) !== undefined);
@@ -795,7 +855,7 @@ function shapeValue(utility: Utility, role: string | undefined, resolved: Resolv
if (role === undefined) {
return utility === 'rounded' ? '0px' : 'auto';
}
- if (utility === 'w' || utility === 'h') {
+ if (isSizeUtility(utility)) {
return sizeValue(utility, role, resolved) ?? 'auto';
}
return fixedRadii[role] ?? resolved.appearance[radiusRoles[role]];
diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts
index a4df843d78..ab46f28fb7 100644
--- a/packages/client/src/theme/themes/dark.ts
+++ b/packages/client/src/theme/themes/dark.ts
@@ -151,6 +151,8 @@ export const darkTheme: IThemeRGB = {
* thumb, 5.74:1 against the checked `surface-inverted` track. */
'rgb-switch-unchecked': '102 102 102', // #666666
'rgb-switch-thumb': '13 13 13', // #0d0d0d (gray-900, matching surface-primary)
+ 'rgb-table-header-text': '205 205 205', // #cdcdcd (gray-300, matching text-secondary)
+ 'rgb-table-header-fill': '18 18 18', // #121212 (matching surface-dialog)
// Presentation
'rgb-presentation': '33 33 33', // #212121 (gray-800)
diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts
index cd91c854d1..057d8616e0 100644
--- a/packages/client/src/theme/themes/default.ts
+++ b/packages/client/src/theme/themes/default.ts
@@ -138,6 +138,8 @@ export const defaultTheme: IThemeRGB = {
* track, so the control reads in either state. */
'rgb-switch-unchecked': '148 148 148', // #949494
'rgb-switch-thumb': '255 255 255', // #fff (white, matching surface-primary)
+ 'rgb-table-header-text': '66 66 66', // #424242 (gray-600, matching text-secondary)
+ 'rgb-table-header-fill': '255 255 255', // #fff (white, matching surface-dialog)
// Presentation
'rgb-presentation': '255 255 255', // #fff (white)
diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts
index 0fe04e56af..6ea583b80b 100644
--- a/packages/client/src/theme/themes/highContrast.ts
+++ b/packages/client/src/theme/themes/highContrast.ts
@@ -176,6 +176,8 @@ export const highContrastLightTheme: IThemeRGB = {
* `surface-inverted` track. */
'rgb-switch-unchecked': '102 102 102', // #666666
'rgb-switch-thumb': '255 255 255', // #ffffff (matching surface-primary)
+ 'rgb-table-header-text': '0 0 0', // #000000 (matching text-secondary)
+ 'rgb-table-header-fill': '255 255 255', // #ffffff (matching surface-dialog)
// Presentation
'rgb-presentation': '255 255 255', // #ffffff
@@ -325,6 +327,8 @@ export const highContrastDarkTheme: IThemeRGB = {
* thumb, 3.95:1 against the checked `surface-inverted` track. */
'rgb-switch-unchecked': '128 128 128', // #808080
'rgb-switch-thumb': '0 0 0', // #000000 (matching surface-primary)
+ 'rgb-table-header-text': '255 255 255', // #ffffff (matching text-secondary)
+ 'rgb-table-header-fill': '0 0 0', // #000000 (matching surface-dialog)
// Presentation
'rgb-presentation': '0 0 0', // #000000
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index d633d2c722..452ca7b8cc 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -132,8 +132,10 @@
--color-chart-widget-surface: rgb(var(--chart-widget-surface));
--color-chart-widget-stroke: rgb(var(--chart-widget-stroke));
--color-switch-unchecked: rgb(var(--switch-unchecked));
- /* Falls back to the surface it was painted before the role, for a stylesheet that predates it. */
+ /* Each falls back to what it was painted with before its role, for a stylesheet that predates it. */
--color-switch-thumb: rgb(var(--switch-thumb, var(--surface-primary)));
+ --color-table-header-text: rgb(var(--table-header-text, var(--text-secondary)));
+ --color-table-header-fill: rgb(var(--table-header-fill, var(--surface-dialog)));
}
/* The plain radius, font, type scale and shadow utilities read theme-owned properties, so a theme
diff --git a/packages/client/src/theme/tokens.spec.ts b/packages/client/src/theme/tokens.spec.ts
index b3e901e1a1..0bc4f5fd1a 100644
--- a/packages/client/src/theme/tokens.spec.ts
+++ b/packages/client/src/theme/tokens.spec.ts
@@ -87,12 +87,16 @@ describe('theme color tokens', () => {
'text-text-secondary',
'bg-series-1',
'bg-switch-thumb',
+ 'text-table-header-text',
+ 'bg-table-header-fill',
]);
expect(css).toContain('rgb(var(--surface-primary))');
expect(css).toContain('rgb(var(--text-secondary))');
expect(css).toContain('rgb(var(--series-1))');
expect(css).toContain('rgb(var(--switch-thumb, var(--surface-primary)))');
+ expect(css).toContain('rgb(var(--table-header-text, var(--text-secondary)))');
+ expect(css).toContain('rgb(var(--table-header-fill, var(--surface-dialog)))');
});
it('keeps a border token on its intrinsic alpha and still takes an opacity modifier', async () => {
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index 919e886d2d..17ea1e8b8b 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -165,6 +165,10 @@ export interface IThemeRGB {
'rgb-switch-unchecked'?: string;
/** The switch's knob in both states, painted over the unchecked track and the checked fill. */
'rgb-switch-thumb'?: string;
+ /** Column names in a table header, over its `surface-secondary` fill. */
+ 'rgb-table-header-text'?: string;
+ /** The opaque fill of a header whose cells stick on their own, the dialog surface by default. */
+ 'rgb-table-header-fill'?: string;
// Presentation
'rgb-presentation'?: string;
@@ -284,6 +288,8 @@ export interface IThemeVariables {
'--switch-unchecked': string;
'--switch-thumb': string;
+ '--table-header-text': string;
+ '--table-header-fill': string;
'--presentation': string;
}
@@ -385,6 +391,8 @@ export interface IThemeColors {
'series-7'?: string;
'switch-unchecked'?: string;
'switch-thumb'?: string;
+ 'table-header-text'?: string;
+ 'table-header-fill'?: string;
'series-8'?: string;
presentation?: string;
@@ -416,6 +424,8 @@ export interface IThemeAppearance {
controlHeight: string;
switchWidth: string;
switchHeight: string;
+ tableCellSpaceY: string;
+ tableRowStroke: string;
spaceCompact: string;
spaceNormal: string;
/** `dim` fades a disabled control to half opacity; `fill` paints it in the disabled roles. */
diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.ts
index eda4667612..42b1d7bf12 100644
--- a/packages/client/src/theme/utils/applyTheme.spec.ts
+++ b/packages/client/src/theme/utils/applyTheme.spec.ts
@@ -19,6 +19,8 @@ const semanticProperties = [
'--chart-widget-surface',
'--chart-widget-stroke',
'--switch-thumb',
+ '--table-header-text',
+ '--table-header-fill',
'--border-destructive',
'--border-control',
'--status-success',
@@ -382,6 +384,22 @@ describe('applyTheme', () => {
expect(root.style.getPropertyValue('--switch-thumb')).toBe('1 2 3');
});
+ it('keeps table column names of a legacy theme on its secondary text', () => {
+ const root = document.documentElement;
+
+ applyTheme({ 'rgb-text-secondary': '20 21 22' }, root);
+
+ expect(root.style.getPropertyValue('--table-header-text')).toBe('20 21 22');
+ });
+
+ it('keeps a legacy self-sticking table header on its dialog surface', () => {
+ const root = document.documentElement;
+
+ applyTheme({ 'rgb-surface-dialog': '20 21 22' }, root);
+
+ expect(root.style.getPropertyValue('--table-header-fill')).toBe('20 21 22');
+ });
+
it('carries a legacy light border onto the control outline', () => {
const root = document.documentElement;
diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.ts
index cee27214c8..c7f497b011 100644
--- a/packages/client/src/theme/utils/applyTheme.ts
+++ b/packages/client/src/theme/utils/applyTheme.ts
@@ -74,6 +74,14 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]>
variables.push(['--switch-thumb', colors['rgb-surface-primary']]);
}
+ if (colors['rgb-table-header-text'] === undefined && colors['rgb-text-secondary'] !== undefined) {
+ variables.push(['--table-header-text', colors['rgb-text-secondary']]);
+ }
+
+ if (colors['rgb-table-header-fill'] === undefined && colors['rgb-surface-dialog'] !== undefined) {
+ variables.push(['--table-header-fill', colors['rgb-surface-dialog']]);
+ }
+
if (colors['rgb-chart-widget-stroke'] === undefined && colors['rgb-border-light'] !== undefined) {
variables.push(['--chart-widget-stroke', colors['rgb-border-light']]);
}
diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.ts
index fad4c32a09..6d0005fbe5 100644
--- a/packages/client/src/utils/utils.ts
+++ b/packages/client/src/utils/utils.ts
@@ -1,6 +1,20 @@
// ESM utility functions
import { type ClassValue, clsx } from 'clsx';
-import { twMerge } from 'tailwind-merge';
+import { extendTailwindMerge } from 'tailwind-merge';
+
+/**
+ * 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
+ * and leaving the winner to stylesheet order.
+ */
+const twMerge = extendTailwindMerge({
+ extend: {
+ classGroups: {
+ py: [{ py: ['theme-table-cell', 'theme-table-cell-compact', 'theme-table-cell-dense'] }],
+ h: [{ h: ['theme-table-head', 'theme-table-head-compact'] }],
+ },
+ },
+});
export const cn = (...inputs: ClassValue[]): string => {
return twMerge(clsx(inputs));
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index c7d2c97bf4..340c929c8d 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -8,10 +8,15 @@ module.exports = {
height: {
'theme-control': 'var(--theme-control-height, 2.25rem)',
'theme-switch': 'var(--theme-switch-height, 1.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. */
+ 'theme-table-head-compact': 'calc(var(--theme-table-cell-space-y, 1rem) + 1.25rem)',
},
width: {
/** Never narrower than the track is tall, so the knob always has somewhere to travel. */
- 'theme-switch': 'max(var(--theme-switch-width, 2.75rem), var(--theme-switch-height, 1.5rem))',
+ 'theme-switch':
+ 'max(var(--theme-switch-width, 2.75rem), var(--theme-switch-height, 1.5rem))',
},
spacing: {
'theme-compact': 'var(--theme-space-compact, 0.375rem)',
@@ -28,6 +33,10 @@ module.exports = {
'theme-switch-thumb': 'max(0px, calc(var(--theme-switch-height, 1.5rem) - 4px))',
'theme-switch-travel':
'max(0px, calc(var(--theme-switch-width, 2.75rem) - var(--theme-switch-height, 1.5rem)))',
+ 'theme-table-cell': 'var(--theme-table-cell-space-y, 1rem)',
+ /** The compact and dense table sizes: half and a quarter of the cell space. */
+ 'theme-table-cell-compact': 'calc(var(--theme-table-cell-space-y, 1rem) / 2)',
+ 'theme-table-cell-dense': 'calc(var(--theme-table-cell-space-y, 1rem) / 4)',
},
keyframes: {
/** Discord-style "connecting" dots: each dot lifts and brightens in
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index fb78e8d083..33927bff8e 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -117,6 +117,8 @@ export const themeColorTokens = Object.freeze([
'rgb-series-8',
'rgb-switch-unchecked',
'rgb-switch-thumb',
+ 'rgb-table-header-text',
+ 'rgb-table-header-fill',
'rgb-presentation',
] as const);
@@ -190,6 +192,12 @@ const isLength = (value: unknown): value is string =>
* A switch dimension is a positive px or rem length: `em` would follow the component's own font
* size, and the pair is only comparable when both sides share one unit.
*/
+/**
+ * A table's cell space and row rule are px or rem, zero allowed: the virtualized table sizes its
+ * rows from them in JavaScript, which has to read them exactly at the root.
+ */
+const isTableLength = (value: unknown): value is string =>
+ typeof value === 'string' && /^(0|\d*\.?\d+(px|rem))$/.test(value);
const isSwitchLength = (value: unknown): value is string =>
typeof value === 'string' && /^\d*\.?\d+(px|rem)$/.test(value) && parseFloat(value) > 0;
const isFontFamily = (value: unknown): value is string =>
@@ -302,6 +310,8 @@ const appearanceValidators = {
controlHeight: isLength,
switchWidth: isSwitchLength,
switchHeight: isSwitchLength,
+ tableCellSpaceY: isTableLength,
+ tableRowStroke: isTableLength,
spaceCompact: isLength,
spaceNormal: isLength,
/** `dim` fades a disabled control to half opacity; `fill` paints it in the disabled roles. */