Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(table): honor standard styling props on the root <table> (#3692)

AK1b61ba697207
diff --git a/.changeset/cli-tableprops-codemod.md b/.changeset/cli-tableprops-codemod.md
new file mode 100644
index 0000000000..003e8fa718
--- /dev/null
+++ b/.changeset/cli-tableprops-codemod.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[feat] New codemod for the Table `tableProps` deprecation: lifts object-literal `tableProps` keys into direct props on `<Table>`, keeps colliding or dynamic values in place with a TODO note. **Codemod:** `npx astryx upgrade --codemod migrate-table-tableprops-to-direct-props` (#3679)
+@AKnassa
diff --git a/.changeset/table-renderprops-xstyle-rename.md b/.changeset/table-renderprops-xstyle-rename.md
new file mode 100644
index 0000000000..d772ef6216
--- /dev/null
+++ b/.changeset/table-renderprops-xstyle-rename.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[breaking] Table plugin render-prop interfaces (`TableRenderProps`, `HeaderRowRenderProps`, `HeaderCellRenderProps`, `BodyRowRenderProps`, `BodyCellRenderProps`, `ScrollWrapperRenderProps`) and the `scrollWrapper` component contract rename their StyleX array field `styles` → `xstyle`, matching the prop name sub-components receive it under. Custom plugin authors: rename `props.styles` reads and `styles:` writes in transform functions (#3679)
+@AKnassa
diff --git a/.changeset/table-root-styling-props.md b/.changeset/table-root-styling-props.md
new file mode 100644
index 0000000000..10ec6b410c
--- /dev/null
+++ b/.changeset/table-root-styling-props.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Table now honors the standard root styling props: `className`, `style`, `xstyle`, `id`, `aria-*`, `data-*`, and other HTML attributes reach the root `<table>` element instead of being silently dropped. `tableProps` is deprecated (still works, loses conflicts to direct props); the computed column min-width still wins over a consumer `style.minWidth`, but no longer clobbers it when columns compute none (#3679)
+@AKnassa
diff --git a/packages/cli/src/codemods/__tests__/registry.test.mjs b/packages/cli/src/codemods/__tests__/registry.test.mjs
index a4d3b54e87..9cc2450edc 100644
--- a/packages/cli/src/codemods/__tests__/registry.test.mjs
+++ b/packages/cli/src/codemods/__tests__/registry.test.mjs
@@ -20,6 +20,7 @@ describe('registry', () => {
'0.1.2',
'0.1.3',
'0.1.5',
+ '0.1.7',
]);
});
});
diff --git a/packages/cli/src/codemods/registry.mjs b/packages/cli/src/codemods/registry.mjs
index 038be8b525..48d7d90f2c 100644
--- a/packages/cli/src/codemods/registry.mjs
+++ b/packages/cli/src/codemods/registry.mjs
@@ -21,6 +21,7 @@ const registry = new Map([
['0.1.2', () => import('./transforms/v0.1.2/index.mjs')],
['0.1.3', () => import('./transforms/v0.1.3/index.mjs')],
['0.1.5', () => import('./transforms/v0.1.5/index.mjs')],
+ ['0.1.7', () => import('./transforms/v0.1.7/index.mjs')],
]);
// Re-export from the shared utility so registry callers and other consumers
diff --git a/packages/cli/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs b/packages/cli/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs
new file mode 100644
index 0000000000..b4c7bbc351
--- /dev/null
+++ b/packages/cli/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs
@@ -0,0 +1,120 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+
+async function applyTransform(source) {
+ const {default: transform} = await import(
+ '../migrate-table-tableprops-to-direct-props.mjs'
+ );
+ const jscodeshift = (await import('jscodeshift')).default;
+ const j = jscodeshift.withParser('tsx');
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
+ const file = {source, path: 'test.tsx'};
+ const result = transform(file, api);
+ return result ?? source;
+}
+
+const TODO = 'TODO(astryx): tableProps is deprecated';
+
+describe('migrate-table-tableprops-to-direct-props', () => {
+ it('lifts className and style to sibling props', async () => {
+ const input = `import {Table} from '@astryxdesign/core';
+const x = <Table tableProps={{className: 'striped', style: {width: 400}}} columns={cols} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`className='striped'`);
+ expect(output).toContain('style={{width: 400}}');
+ expect(output).not.toContain('tableProps');
+ });
+
+ it(`lifts 'aria-label' and 'data-testid' string keys to hyphenated props`, async () => {
+ const input = `import {Table} from '@astryxdesign/core/Table';
+const x = <Table tableProps={{'aria-label': 'Users', 'data-testid': 'users-table'}} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`aria-label='Users'`);
+ expect(output).toContain(`data-testid='users-table'`);
+ expect(output).not.toContain('tableProps');
+ });
+
+ it('lifts id and an onClick handler', async () => {
+ const input = `import {Table} from '@xds/core';
+const x = <Table tableProps={{id: 'users', onClick: (e) => handle(e)}} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`id='users'`);
+ expect(output).toContain('onClick={(e) => handle(e)}');
+ expect(output).not.toContain('tableProps');
+ });
+
+ it('keeps colliding keys in a shrunken tableProps with a TODO comment', async () => {
+ const input = `import {Table} from '@astryxdesign/core';
+const x = <Table className='mine' tableProps={{className: 'theirs', id: 'users'}} />;`;
+ const output = await applyTransform(input);
+ // Non-colliding key lifted
+ expect(output).toContain(`id='users'`);
+ // Existing sibling wins; colliding key stays inside tableProps
+ expect(output).toContain(`className='mine'`);
+ expect(output).toContain('tableProps={{');
+ expect(output).toContain(`className: 'theirs'`);
+ expect(output).not.toContain('id: ');
+ expect(output).toContain(TODO);
+ });
+
+ it('leaves a dynamic tableProps={identifier} untouched with a TODO comment', async () => {
+ const input = `import {Table} from '@astryxdesign/core';
+const x = <Table tableProps={props} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain('tableProps={props}');
+ expect(output).toContain(TODO);
+ });
+
+ it('leaves an object containing a spread untouched with a TODO comment (no partial lift)', async () => {
+ const input = `import {Table} from '@astryxdesign/core';
+const x = <Table tableProps={{className: 'x', ...rest}} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`tableProps={{className: 'x', ...rest}}`);
+ expect(output).not.toContain(`<Table className=`);
+ expect(output).toContain(TODO);
+ });
+
+ it('transforms aliased Table imports', async () => {
+ const input = `import {Table as DataTable} from '@astryxdesign/core';
+const x = <DataTable tableProps={{className: 'x'}} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`<DataTable className='x' />`);
+ expect(output).not.toContain('tableProps');
+ });
+
+ it('does not touch other components with a tableProps attribute', async () => {
+ const input = `import {Table} from '@astryxdesign/core';
+const a = <Table tableProps={{id: 'users'}} />;
+const b = <OtherComponent tableProps={{className: 'x'}} />;`;
+ const output = await applyTransform(input);
+ expect(output).toContain(`<Table id='users' />`);
+ expect(output).toContain(`<OtherComponent tableProps={{className: 'x'}} />`);
+ });
+
+ it('returns undefined for files without a Table import', async () => {
+ const {default: transform} = await import(
+ '../migrate-table-tableprops-to-direct-props.mjs'
+ );
+ const jscodeshift = (await import('jscodeshift')).default;
+ const j = jscodeshift.withParser('tsx');
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
+ const source = `import {Grid} from '@astryxdesign/core';
+const x = <Table tableProps={{className: 'x'}} />;`;
+ const result = transform({source, path: 'test.tsx'}, api);
+ expect(result).toBeUndefined();
+ });
+
+ it('returns undefined for already-migrated files (no tableProps)', async () => {
+ const {default: transform} = await import(
+ '../migrate-table-tableprops-to-direct-props.mjs'
+ );
+ const jscodeshift = (await import('jscodeshift')).default;
+ const j = jscodeshift.withParser('tsx');
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
+ const source = `import {Table} from '@astryxdesign/core';
+const x = <Table className='x' />;`;
+ const result = transform({source, path: 'test.tsx'}, api);
+ expect(result).toBeUndefined();
+ });
+});
diff --git a/packages/cli/src/codemods/transforms/v0.1.7/index.mjs b/packages/cli/src/codemods/transforms/v0.1.7/index.mjs
new file mode 100644
index 0000000000..5801c1cb1c
--- /dev/null
+++ b/packages/cli/src/codemods/transforms/v0.1.7/index.mjs
@@ -0,0 +1,19 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file v0.1.7 transform manifest
+ *
+ * Lists all codemods for the v0.1.7 release in the order they should run.
+ */
+
+import migrateTableTablePropsToDirectProps, {
+ meta as migrateTableTablePropsToDirectPropsMeta,
+} from './migrate-table-tableprops-to-direct-props.mjs';
+
+export default [
+ {
+ name: 'migrate-table-tableprops-to-direct-props',
+ transform: migrateTableTablePropsToDirectProps,
+ meta: migrateTableTablePropsToDirectPropsMeta,
+ },
+];
diff --git a/packages/cli/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs b/packages/cli/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs
new file mode 100644
index 0000000000..0cf0975996
--- /dev/null
+++ b/packages/cli/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs
@@ -0,0 +1,188 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Codemod: Migrate Table tableProps to direct root props
+ * @see https://github.com/facebook/astryx/issues/3679
+ *
+ * `tableProps` (typed HTMLAttributes<HTMLTableElement>, nesting HTML
+ * attributes one level deep) is deprecated. As of v0.1.7, <Table> honors
+ * className/style/xstyle directly and spreads all other BaseProps
+ * (id, aria-*, data-*, event handlers, ...) onto the root <table>, with
+ * direct props taking precedence over tableProps.
+ *
+ * This codemod lifts object-literal `tableProps` keys into sibling JSX
+ * props:
+ *
+ * - tableProps={{className: 'x', style: s}} → className="x" style={s}
+ * - String-literal keys ('aria-label', 'data-testid') become hyphenated
+ * JSX attributes.
+ * - Keys that collide with an existing sibling attribute (or fail the
+ * attribute-name guard) are kept inside a shrunken tableProps with a
+ * trailing TODO comment for manual migration.
+ * - Dynamic values (tableProps={props}, tableProps={fn()}, objects with
+ * spreads/computed keys/methods) are left untouched with a TODO comment.
+ *
+ * Only elements whose name resolves to a `Table` import (alias-aware)
+ * from an Astryx core source are rewritten. No import changes are needed.
+ */
+
+export const meta = {
+ title: 'Migrate Table tableProps to direct root props',
+ description:
+ 'Lifts object-literal `tableProps` keys on <Table> into sibling JSX props ' +
+ '(className, style, id, aria-*, data-*, event handlers). Dynamic or ' +
+ 'colliding entries are kept and annotated with a TODO comment.',
+ pr: '#3679',
+};
+
+/** Import sources that provide the Astryx Table component. */
+const TABLE_IMPORT_SOURCES = new Set([
+ '@astryxdesign/core',
+ '@astryxdesign/core/Table',
+ '@xds/core',
+ '@xds/core/Table',
+]);
+
+/** Keys must be valid JSX attribute names to be lifted. */
+const LIFTABLE_KEY_RE = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;
+
+const TODO_COMMENT =
+ ' TODO(astryx): tableProps is deprecated — merge these into direct props manually ';
+
+/**
+ * Extract the static key name from an object property, or null when the
+ * property is not a simple liftable entry (spread, computed key, method,
+ * getter/setter, non-string literal key).
+ */
+function getPropertyKeyName(prop) {
+ if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') return null;
+ // espree-style Property nodes: skip methods and accessors
+ if (prop.method || (prop.kind != null && prop.kind !== 'init')) return null;
+ if (prop.computed) return null;
+ const key = prop.key;
+ if (key.type === 'Identifier') return key.name;
+ if (
+ (key.type === 'StringLiteral' || key.type === 'Literal') &&
+ typeof key.value === 'string'
+ ) {
+ return key.value;
+ }
+ return null;
+}
+
+export default function transformer(file, api) {
+ const j = api.jscodeshift;
+ const root = j(file.source);
+ let hasChanges = false;
+
+ // --- 1. Track local names for the Table import (alias-aware) ---
+ const tableLocals = new Set();
+ root.find(j.ImportDeclaration).forEach((path) => {
+ if (!TABLE_IMPORT_SOURCES.has(path.node.source.value)) return;
+ for (const spec of path.node.specifiers ?? []) {
+ if (spec.type === 'ImportSpecifier' && spec.imported.name === 'Table') {
+ tableLocals.add(spec.local.name);
+ }
+ }
+ });
+
+ if (tableLocals.size === 0) return undefined;
+
+ function attachTodo(attr) {
+ if (!attr.comments) attr.comments = [];
+ if (attr.comments.some((c) => c.value === TODO_COMMENT)) return;
+ attr.comments.push(j.commentBlock(TODO_COMMENT, false, true));
+ hasChanges = true;
+ }
+
+ function buildAttributeValue(valueNode) {
+ if (
+ valueNode.type === 'StringLiteral' ||
+ (valueNode.type === 'Literal' && typeof valueNode.value === 'string')
+ ) {
+ return j.stringLiteral(valueNode.value);
+ }
+ return j.jsxExpressionContainer(valueNode);
+ }
+
+ // --- 2. Rewrite tableProps on tracked <Table> elements ---
+ root.find(j.JSXOpeningElement).forEach((path) => {
+ const name = path.node.name;
+ const componentName = name.type === 'JSXIdentifier' ? name.name : null;
+ if (!componentName || !tableLocals.has(componentName)) return;
+
+ const attrs = path.node.attributes;
+ const tablePropsAttr = attrs.find(
+ (a) => a.type === 'JSXAttribute' && a.name?.name === 'tableProps',
+ );
+ if (!tablePropsAttr) return;
+
+ const value = tablePropsAttr.value;
+ const isObjectLiteral =
+ value?.type === 'JSXExpressionContainer' &&
+ value.expression.type === 'ObjectExpression';
+
+ // Dynamic case: tableProps={identifier}, tableProps={fn()}, ... —
+ // leave the attribute untouched and warn via a trailing comment
+ // (api.report is a stub; comments are the only warning channel).
+ if (!isObjectLiteral) {
+ attachTodo(tablePropsAttr);
+ return;
+ }
+
+ const obj = value.expression;
+
+ // Objects containing spreads, computed keys, or methods are treated
+ // as dynamic: no partial lift, just the TODO comment.
+ const allSimple = obj.properties.every(
+ (prop) => getPropertyKeyName(prop) !== null,
+ );
+ if (!allSimple) {
+ attachTodo(tablePropsAttr);
+ return;
+ }
+
+ const lifted = [];
+ const kept = [];
+ for (const prop of obj.properties) {
+ const keyName = getPropertyKeyName(prop);
+ const collidesWithSibling = attrs.some(
+ (a) => a.type === 'JSXAttribute' && a.name?.name === keyName,
+ );
+ const collidesWithLifted = lifted.some(
+ (a) => a.name.name === keyName,
+ );
+ if (
+ !LIFTABLE_KEY_RE.test(keyName) ||
+ collidesWithSibling ||
+ collidesWithLifted
+ ) {
+ kept.push(prop);
+ continue;
+ }
+ lifted.push(
+ j.jsxAttribute(
+ j.jsxIdentifier(keyName),
+ buildAttributeValue(prop.value),
+ ),
+ );
+ }
+
+ const tablePropsIdx = attrs.indexOf(tablePropsAttr);
+ if (kept.length === 0) {
+ // All keys lifted — replace tableProps with the sibling attributes.
+ attrs.splice(tablePropsIdx, 1, ...lifted);
+ hasChanges = true;
+ } else {
+ // Some keys collide or fail the name guard — keep only those in a
+ // shrunken tableProps and flag it for manual migration.
+ attrs.splice(tablePropsIdx, 0, ...lifted);
+ obj.properties = kept;
+ attachTodo(tablePropsAttr);
+ if (lifted.length > 0) hasChanges = true;
+ }
+ });
+
+ if (!hasChanges) return undefined;
+ return root.toSource({quote: 'single'});
+}
diff --git a/packages/cli/templates/themes/chocolate/chocolateTheme.ts b/packages/cli/templates/themes/chocolate/chocolateTheme.ts
index aca7447887..cd567dde04 100644
--- a/packages/cli/templates/themes/chocolate/chocolateTheme.ts
+++ b/packages/cli/templates/themes/chocolate/chocolateTheme.ts
@@ -44,7 +44,8 @@ export const chocolateTheme = defineTheme({
},
heading: {
family: 'Fraunces',
- fallbacks: 'Georgia, "Times New Roman", Times, serif',
+ fallbacks:
+ 'Georgia, "Times New Roman", Times, serif',
weights: {3: 'bold', 4: 'bold'},
},
code: {
@@ -187,9 +188,12 @@ export const chocolateTheme = defineTheme({
// =========================================================================
// Shadows — warm-toned
// =========================================================================
- '--shadow-low': '0 2px 4px #4a35200D, 0 4px 8px #4a35201A',
- '--shadow-med': '0 2px 4px #4a35200D, 0 4px 12px #4a35201A',
- '--shadow-high': '0 4px 6px #4a35201A, 0 12px 24px #4a352026',
+ '--shadow-low':
+ '0 2px 4px #4a35200D, 0 4px 8px #4a35201A',
+ '--shadow-med':
+ '0 2px 4px #4a35200D, 0 4px 12px #4a35201A',
+ '--shadow-high':
+ '0 4px 6px #4a35201A, 0 12px 24px #4a352026',
'--shadow-inset-hover': 'inset 0px 0px 0px 2px #8C592730',
'--shadow-inset-selected': 'inset 0px 0px 0px 2px #8C592750',
'--shadow-inset-success': 'inset 0px 0px 0px 2px #70990050',
diff --git a/packages/cli/templates/themes/neutral/neutralTheme.ts b/packages/cli/templates/themes/neutral/neutralTheme.ts
index d28c6f60a8..c8aa5c15b1 100644
--- a/packages/cli/templates/themes/neutral/neutralTheme.ts
+++ b/packages/cli/templates/themes/neutral/neutralTheme.ts
@@ -39,19 +39,19 @@ import {neutralIconRegistry} from './icons';
const neutralSyntax = defineSyntaxTheme({
name: 'xds-neutral',
tokens: {
- keyword: ['#700084', '#efa8ff'], // purple T30/T80
- string: ['#005600', '#a6d2a2'], // green (sat T30 / pastel T80)
- comment: ['#737373', '#a3a3a3'], // neutral
- number: ['#6e3500', '#ffb37f'], // orange
- function: ['#00458c', '#a0caff'], // blue T30/T80 H=255
- type: ['#700084', '#efa8ff'], // purple
- variable: ['#171717', '#e5e5e5'], // near-black / near-white
- operator: ['#737373', '#a3a3a3'], // neutral
- constant: ['#6e3500', '#ffb37f'], // orange
- tag: ['#89001a', '#ffaeaa'], // red
- attribute: ['#584400', '#eec12f'], // yellow
- property: ['#005348', '#83dac9'], // teal
- punctuation: ['#a3a3a3', '#525252'], // neutral
+ keyword: ['#700084', '#efa8ff'], // purple T30/T80
+ string: ['#005600', '#a6d2a2'], // green (sat T30 / pastel T80)
+ comment: ['#737373', '#a3a3a3'], // neutral
+ number: ['#6e3500', '#ffb37f'], // orange
+ function: ['#00458c', '#a0caff'], // blue T30/T80 H=255
+ type: ['#700084', '#efa8ff'], // purple
+ variable: ['#171717', '#e5e5e5'], // near-black / near-white
+ operator: ['#737373', '#a3a3a3'], // neutral
+ constant: ['#6e3500', '#ffb37f'], // orange
+ tag: ['#89001a', '#ffaeaa'], // red
+ attribute: ['#584400', '#eec12f'], // yellow
+ property: ['#005348', '#83dac9'], // teal
+ punctuation: ['#a3a3a3', '#525252'],// neutral
background: ['#fafafa', '#0a0a0a'],
},
});
@@ -127,39 +127,39 @@ export const neutralTheme = defineTheme({
// All values use the OKLCH Neutral tonal palette (chroma=0).
// =========================================================================
'--color-background-surface': ['#ffffff', '#262626'],
- '--color-background-body': ['#f1f1f1', '#1b1b1b'],
- '--color-background-card': ['#ffffff', '#1b1b1b'],
+ '--color-background-body': ['#f1f1f1', '#1b1b1b'],
+ '--color-background-card': ['#ffffff', '#1b1b1b'],
'--color-background-popover': ['#ffffff', '#1b1b1b'],
- '--color-background-muted': ['#f1f1f1', '#1b1b1b'],
+ '--color-background-muted': ['#f1f1f1', '#1b1b1b'],
// Accent + neutral surface tints (sit alongside backgrounds)
- '--color-accent': ['#262626', '#ebebeb'],
+ '--color-accent': ['#262626', '#ebebeb'],
'--color-accent-muted': ['#f1f1f1', '#262626'],
- '--color-neutral': ['#0000000F', '#FFFFFF1A'],
+ '--color-neutral': ['#0000000F', '#FFFFFF1A'],
// Overlays (modal scrims, hover/pressed tints)
- '--color-overlay': ['#00000080', '#000000CC'],
- '--color-overlay-hover': ['#0000000D', '#FFFFFF0D'],
+ '--color-overlay': ['#00000080', '#000000CC'],
+ '--color-overlay-hover': ['#0000000D', '#FFFFFF0D'],
'--color-overlay-pressed': ['#0000001A', '#FFFFFF1A'],
// Text
- '--color-text-primary': ['#171717', '#fafafa'],
+ '--color-text-primary': ['#171717', '#fafafa'],
'--color-text-secondary': ['#737373', '#a3a3a3'],
- '--color-text-disabled': ['#a3a3a3', '#525252'],
- '--color-text-accent': ['#262626', '#ebebeb'],
- '--color-on-dark': '#ffffff',
- '--color-on-light': '#171717',
+ '--color-text-disabled': ['#a3a3a3', '#525252'],
+ '--color-text-accent': ['#262626', '#ebebeb'],
+ '--color-on-dark': '#ffffff',
+ '--color-on-light': '#171717',
// Contrast: neutral accent is near-black (L) / near-white (D)
- '--color-on-accent': ['#ffffff', '#171717'],
+ '--color-on-accent': ['#ffffff', '#171717'],
'--color-on-success': ['#ffffff', '#171717'],
- '--color-on-error': ['#ffffff', '#171717'],
+ '--color-on-error': ['#ffffff', '#171717'],
'--color-on-warning': '#171717',
// Icon
- '--color-icon-accent': ['#262626', '#ebebeb'],
- '--color-icon-primary': ['#171717', '#fafafa'],
+ '--color-icon-accent': ['#262626', '#ebebeb'],
+ '--color-icon-primary': ['#171717', '#fafafa'],
'--color-icon-secondary': ['#737373', '#a3a3a3'],
- '--color-icon-disabled': ['#a3a3a3', '#525252'],
+ '--color-icon-disabled': ['#a3a3a3', '#525252'],
// Status / Sentiment — dark mode follows the issue #2150 rubric:
//
@@ -372,8 +372,8 @@ export const neutralTheme = defineTheme({
// =========================================================================
button: {
'variant:destructive': {
- backgroundColor: 'var(--color-error-muted)', // locked pastel red bg
- color: 'var(--color-error)', // locked T30 red — matches banner/input error text
+ backgroundColor: 'var(--color-error-muted)', // locked pastel red bg
+ color: 'var(--color-error)', // locked T30 red — matches banner/input error text
},
},
diff --git a/packages/cli/templates/themes/stone/stoneTheme.ts b/packages/cli/templates/themes/stone/stoneTheme.ts
index c226561ec7..199e75c1a2 100644
--- a/packages/cli/templates/themes/stone/stoneTheme.ts
+++ b/packages/cli/templates/themes/stone/stoneTheme.ts
@@ -94,13 +94,13 @@ export const stoneTheme = defineTheme({
// Core semantic — all neutrals H=291
// Stone 900 T=16 C=1.4, Stone 500 T=55 C=4, Stone 300 T=86 C=1.6, Stone 100 T=96 C=1
'--color-accent': ['#25252a', '#f3f3f5'], // light: Stone Neutral T15
- '--color-accent-muted': ['#25252a14', '#f3f3f5'], // light: Stone Neutral T15 · 8%
+ '--color-accent-muted': ['#25252a14', '#f3f3f520'], // light: Stone Neutral T15 · 8% / dark: T96 · 12.5%
'--color-neutral': ['#25252a0f', '#f3f3f51a'], // light: Stone Neutral T15 · 6% / dark: T96 · 10%
'--color-background-surface': ['#ffffff', '#1b1b1f'], // dark: Stone Neutral T10
'--color-background-body': ['#f3f3f5', '#111015'], // dark: Stone Neutral T5
- '--color-overlay': ['#25252a80', '#28282a'], // light: Stone Neutral T15 · 50%
- '--color-overlay-hover': ['#25252a0d', '#f3f3f5'], // light: Stone Neutral T15 · 5%
- '--color-overlay-pressed': ['#25252a1a', '#f3f3f5'], // light: Stone Neutral T15 · 10%
+ '--color-overlay': ['#25252a80', '#28282acc'], // light: Stone Neutral T15 · 50% / dark: 80%
+ '--color-overlay-hover': ['#25252a0d', '#f3f3f50d'], // light: Stone Neutral T15 · 5% / dark: T96 · 5%
+ '--color-overlay-pressed': ['#25252a1a', '#f3f3f51a'], // light: Stone Neutral T15 · 10% / dark: T96 · 10%
'--color-background-muted': ['#e2e2e8', '#3b3b3f'], // light: Stone Neutral T90
// Text — H=291
@@ -136,12 +136,12 @@ export const stoneTheme = defineTheme({
'--color-warning-muted': ['#f4e1b7', '#d7c59c'], // Yellow T90 / T80
// Border — H=291
- '--color-border': ['#e2e2e8', '#f3f3f5'], // light: Stone Neutral T90
+ '--color-border': ['#e2e2e8', '#f3f3f51a'], // light: Stone Neutral T90 / dark: T96 · 10%
'--color-border-emphasized': ['#83838a', '#5e5e61'], // T55 C=4 / T40 C=2
// Effects — H=291
'--color-skeleton': ['#d4d4da', '#5e5e64'], // T85 / T40 from H=291 C=3
- '--color-shadow': ['#25252a1a', '#000000'], // light: Stone Neutral T15 · 10%
+ '--color-shadow': ['#25252a1a', '#0000004d'], // light: Stone Neutral T15 · 10% / dark: 30%
'--color-tint-hover': ['black', 'white'],
// Typography override
diff --git a/packages/core/src/Table/BaseTable.tsx b/packages/core/src/Table/BaseTable.tsx
index a3d20011cf..a8040a4e96 100644
--- a/packages/core/src/Table/BaseTable.tsx
+++ b/packages/core/src/Table/BaseTable.tsx
@@ -163,7 +163,7 @@ function TableRowInner<T extends Record<string, unknown>>({
const initialBodyCellRenderProps: BodyCellRenderProps = {
htmlProps: initialCellHtmlProps,
- styles: [],
+ xstyle: [],
columnIndex,
columns: columns as ReadonlyArray<TableColumn<Record<string, unknown>>>,
};
@@ -207,7 +207,7 @@ function TableRowInner<T extends Record<string, unknown>>({
key={col.key}
{...cellRenderProps.htmlProps}
contextMenuActions={cellRenderProps.contextMenuActions}
- xstyle={cellRenderProps.styles}>
+ xstyle={cellRenderProps.xstyle}>
{content}
</CellComponent>
);
@@ -219,7 +219,7 @@ function TableRowInner<T extends Record<string, unknown>>({
p => p.transformBodyRow,
{
htmlProps: {},
- styles: [],
+ xstyle: [],
children: <>{cells}</>,
} satisfies BodyRowRenderProps,
item,
@@ -231,7 +231,7 @@ function TableRowInner<T extends Record<string, unknown>>({
key={rowKey}
ref={rowRenderProps.ref}
{...rowRenderProps.htmlProps}
- xstyle={rowRenderProps.styles}>
+ xstyle={rowRenderProps.xstyle}>
{rowRenderProps.children}
</RowComponent>
);
@@ -325,7 +325,11 @@ function BaseTableInner<T extends Record<string, unknown>>({
textOverflow = 'wrap',
scrollWrapper: ScrollWrapper,
emptyState,
+ xstyle,
+ className,
+ style,
ref,
+ ...rest
}: BaseTableProps<T> & {ref?: Ref<HTMLTableElement>}): ReactElement {
const t = useTranslator();
// Use stable empty array when no plugins provided
@@ -367,7 +371,7 @@ function BaseTableInner<T extends Record<string, unknown>>({
// --- Plugin pipeline: table ---
const tableRenderProps = applyPlugins(plugins, p => p.transformTable, {
htmlProps: {...userTableProps},
- styles: children ? [styles.table, styles.tableAutoLayout] : [styles.table],
+ xstyle: children ? [styles.table, styles.tableAutoLayout] : [styles.table],
} satisfies TableRenderProps);
// --- Plugin pipeline: header cells ---
@@ -388,7 +392,7 @@ function BaseTableInner<T extends Record<string, unknown>>({
const initialHeaderRenderProps: HeaderCellRenderProps = {
htmlProps: initialHeaderHtmlProps,
- styles: [],
+ xstyle: [],
content: headerContent,
columnIndex,
columns: resolvedColumns as ReadonlyArray<
@@ -449,7 +453,7 @@ function BaseTableInner<T extends Record<string, unknown>>({
{...mergedHtmlProps}
{...headerTitleProp}
contextMenuActions={cellRenderProps.contextMenuActions}
- xstyle={cellRenderProps.styles}>
+ xstyle={cellRenderProps.xstyle}>
{headerInner}
</HeaderCellComponent>
);
@@ -461,7 +465,7 @@ function BaseTableInner<T extends Record<string, unknown>>({
p => p.transformHeaderRow,
{
htmlProps: {},
- styles: [],
+ xstyle: [],
children: <>{headerCells}</>,
} satisfies HeaderRowRenderProps,
);
@@ -470,12 +474,15 @@ function BaseTableInner<T extends Record<string, unknown>>({
const hasData = data != null && data.length > 0;
const hasColumns = resolvedColumns.length > 0;
+ // Style precedence: deprecated tableProps.style < consumer style < the
+ // computed column min-width (structural — derived from column defs, so it
+ // must win when present; when absent, a consumer minWidth survives).
const tableStyle: React.CSSProperties = {
...tableRenderProps.htmlProps.style,
- minWidth:
- resolvedWidths.tableMinWidth > 0
- ? `${resolvedWidths.tableMinWidth}px`
- : undefined,
+ ...style,
+ ...(resolvedWidths.tableMinWidth > 0
+ ? {minWidth: `${resolvedWidths.tableMinWidth}px`}
+ : null),
};
let tableElement: ReactNode = (
@@ -484,10 +491,13 @@ function BaseTableInner<T extends Record<string, unknown>>({
{...tableRenderProps.htmlProps}
{...mergeProps(
themeProps('base-table'),
- stylex.props(...tableRenderProps.styles),
- tableRenderProps.htmlProps.className,
+ stylex.props(...tableRenderProps.xstyle, xstyle),
+ [tableRenderProps.htmlProps.className, className]
+ .filter(Boolean)
+ .join(' ') || undefined,
+ tableStyle,
)}
- style={tableStyle}>
+ {...rest}>
{children ? (
children
) : (
@@ -497,7 +507,7 @@ function BaseTableInner<T extends Record<string, unknown>>({
<RowComponent
{...headerRowRenderProps.htmlProps}
isHeaderRow
- xstyle={headerRowRenderProps.styles}>
+ xstyle={headerRowRenderProps.xstyle}>
{headerRowRenderProps.children}
</RowComponent>
</TableHeader>
@@ -558,14 +568,14 @@ function BaseTableInner<T extends Record<string, unknown>>({
p => p.transformScrollWrapper,
{
htmlProps: {},
- styles: [],
+ xstyle: [],
} satisfies ScrollWrapperRenderProps,
);
tableElement = (
<ScrollWrapper
htmlProps={scrollWrapperRenderProps.htmlProps}
- styles={scrollWrapperRenderProps.styles}
+ xstyle={scrollWrapperRenderProps.xstyle}
beforeTable={scrollWrapperRenderProps.beforeTable}
afterTable={scrollWrapperRenderProps.afterTable}>
{tableElement}
diff --git a/packages/core/src/Table/Table.test.tsx b/packages/core/src/Table/Table.test.tsx
index 5605d1bfca..df9650dd56 100644
--- a/packages/core/src/Table/Table.test.tsx
+++ b/packages/core/src/Table/Table.test.tsx
@@ -11,6 +11,7 @@
import {describe, it, expect, vi} from 'vitest';
import {render, screen} from '@testing-library/react';
+import * as stylex from '@stylexjs/stylex';
import {BaseTable} from './BaseTable';
import {Table} from './Table';
import {TableRow} from './TableRow';
@@ -414,6 +415,136 @@ describe('BaseTable', () => {
);
});
+ describe('root element styling props (#3679)', () => {
+ it('applies className to the table element', () => {
+ render(<Table data={users} columns={columns} className="custom-table" />);
+ expect(screen.getByRole('table').className).toContain('custom-table');
+ });
+
+ it('applies style to the table element', () => {
+ render(<Table data={users} columns={columns} style={{opacity: 0.9}} />);
+ expect(screen.getByRole('table').style.opacity).toBe('0.9');
+ });
+
+ it('accepts xstyle without error', () => {
+ render(<Table data={users} columns={columns} xstyle={undefined} />);
+ expect(screen.getByRole('table')).toBeInTheDocument();
+ });
+
+ it('spreads id and aria attributes onto the table element', () => {
+ render(
+ <Table
+ data={users}
+ columns={columns}
+ id="users-table"
+ aria-label="Users"
+ data-analytics="tables"
+ />,
+ );
+ const table = screen.getByRole('table', {name: 'Users'});
+ expect(table.id).toBe('users-table');
+ expect(table).toHaveAttribute('data-analytics', 'tables');
+ });
+
+ it('composes with deprecated tableProps, direct props winning conflicts', () => {
+ render(
+ <Table
+ data={users}
+ columns={columns}
+ className="direct"
+ style={{opacity: 1}}
+ tableProps={{
+ className: 'legacy',
+ style: {color: 'red', opacity: 0.5},
+ }}
+ />,
+ );
+ const table = screen.getByRole('table');
+ expect(table.className).toContain('legacy');
+ expect(table.className).toContain('direct');
+ // Direct style wins the conflicting key; non-conflicting legacy survives.
+ expect(table.style.opacity).toBe('1');
+ expect(table.style.color).toBe('red');
+ });
+
+ it('keeps the computed column min-width over a consumer style.minWidth', () => {
+ const {tableMinWidth} = resolveColumnWidths(columns);
+ render(
+ <Table data={users} columns={columns} style={{minWidth: '10px'}} />,
+ );
+ expect(screen.getByRole('table').style.minWidth).toBe(
+ `${tableMinWidth}px`,
+ );
+ });
+
+ it('lets a consumer style.minWidth survive when columns compute none', () => {
+ const plain: TableColumn<User>[] = [{key: 'name'}, {key: 'age'}];
+ render(<Table data={users} columns={plain} style={{minWidth: '10px'}} />);
+ expect(screen.getByRole('table').style.minWidth).toBe('10px');
+ });
+
+ it('direct id and aria attributes beat the same keys in tableProps', () => {
+ render(
+ <Table
+ data={users}
+ columns={columns}
+ id="direct-id"
+ aria-label="Direct"
+ tableProps={{id: 'legacy-id', 'aria-label': 'Legacy'}}
+ />,
+ );
+ const table = screen.getByRole('table', {name: 'Direct'});
+ expect(table.id).toBe('direct-id');
+ });
+
+ it('keeps the astryx theme classes alongside a consumer className', () => {
+ render(<Table data={users} columns={columns} className="custom-table" />);
+ const table = screen.getByRole('table');
+ expect(table.className).toContain('astryx-base-table');
+ expect(table.className).toContain('astryx-table');
+ expect(table.className).toContain('custom-table');
+ });
+
+ it('passes event handlers through to the table element', async () => {
+ const onClick = vi.fn();
+ render(<Table data={users} columns={columns} onClick={onClick} />);
+ screen
+ .getByRole('table')
+ .dispatchEvent(new MouseEvent('click', {bubbles: true}));
+ expect(onClick).toHaveBeenCalledTimes(1);
+ });
+
+ it('applies dynamic xstyle values to the table element', () => {
+ const dynamic = stylex.create({
+ opacity: (value: number) => ({opacity: value}),
+ });
+ render(
+ <Table data={users} columns={columns} xstyle={dynamic.opacity(0.42)} />,
+ );
+ expect(screen.getByRole('table').getAttribute('style')).toContain('0.42');
+ });
+
+ it('honors className in children mode', () => {
+ render(
+ <Table className="custom-table">
+ <tbody>
+ <TableRow>
+ <TableCell>Cell</TableCell>
+ </TableRow>
+ </tbody>
+ </Table>,
+ );
+ expect(screen.getByRole('table').className).toContain('custom-table');
+ });
+
+ it('honors className on an unwrapped BaseTable (no scrollWrapper)', () => {
+ render(
+ <BaseTable data={users} columns={columns} className="custom-table" />,
+ );
+ expect(screen.getByRole('table').className).toContain('custom-table');
+ });
+ });
+
describe('plugin pipeline', () => {
it('applies transformTable plugin', () => {
const plugin: TablePlugin<User> = {
@@ -826,7 +957,7 @@ describe('Table', () => {
const userPlugin: TablePlugin<User> = {
transformTable: props => {
// XDS plugin should have already added styles
- expect(props.styles.length).toBeGreaterThan(1);
+ expect(props.xstyle.length).toBeGreaterThan(1);
return {
...props,
htmlProps: {...props.htmlProps, 'data-testid': 'after-xds'},
diff --git a/packages/core/src/Table/Table.tsx b/packages/core/src/Table/Table.tsx
index d3fa14af2f..933203f0ec 100644
--- a/packages/core/src/Table/Table.tsx
+++ b/packages/core/src/Table/Table.tsx
@@ -136,7 +136,7 @@ const scrollWrapperStyles = stylex.create({
function TableScrollWrapper({
children,
htmlProps,
- styles: pluginStyles,
+ xstyle: pluginStyles,
beforeTable,
afterTable,
}: {
@@ -144,7 +144,7 @@ function TableScrollWrapper({
htmlProps?: React.HTMLAttributes<HTMLDivElement> & {
ref?: React.Ref<HTMLDivElement>;
};
- styles?: StyleXStyles[];
+ xstyle?: StyleXStyles[];
beforeTable?: React.ReactNode;
afterTable?: React.ReactNode;
}) {
@@ -196,7 +196,7 @@ function buildTableStylePlugin<
? `${existingClass} ${tableClass}`
: tableClass,
},
- styles: [...props.styles, tableStyles.base],
+ xstyle: [...props.xstyle, tableStyles.base],
};
},
};
diff --git a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
index d168562475..a90fd05e0a 100644
--- a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
+++ b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
@@ -857,7 +857,7 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
{handle}
</>
),
- styles: [...props.styles, headerCellRelative.base],
+ xstyle: [...props.xstyle, headerCellRelative.base],
};
},
}),
diff --git a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
index 365a566f78..41b54f08a6 100644
--- a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
+++ b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
@@ -307,7 +307,7 @@ export function useTableGroupedRows<T extends Record<string, unknown>>(
onClick: toggle,
'aria-expanded': !collapsed,
},
- styles: [...props.styles, styles.headerRow],
+ xstyle: [...props.xstyle, styles.headerRow],
children: (
// colSpan larger than the column count is clamped by the browser
// to the actual number of columns, so the header always spans the
diff --git a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
index efbc0088aa..858d4edc2e 100644
--- a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
+++ b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
@@ -439,10 +439,7 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(
? originalRenderCell(item)
: String(
((item as Record<string, unknown>)[col.key] as
- | string
- | number
- | null
- | undefined) ?? '',
+ string | number | null | undefined) ?? '',
);
if (depth === 0) {
@@ -573,7 +570,7 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(
...props.htmlProps,
onClick: () => onToggle(key),
},
- styles: [...props.styles, expansionStyles.clickableRow],
+ xstyle: [...props.xstyle, expansionStyles.clickableRow],
};
},
}),
diff --git a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
index f2d64c72f6..a9ee923863 100644
--- a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
+++ b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
@@ -337,8 +337,8 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
...props.htmlProps,
style: {...props.htmlProps.style, ...offsetStyle},
},
- styles: [
- ...props.styles,
+ xstyle: [
+ ...props.xstyle,
stickyStyles.cell,
stickyStyles.headerCell,
side.edge === 'start' ? shadowStyles.start : shadowStyles.end,
@@ -365,8 +365,8 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
...props.htmlProps,
style: {...props.htmlProps.style, ...offsetStyle},
},
- styles: [
- ...props.styles,
+ xstyle: [
+ ...props.xstyle,
stickyStyles.cell,
stickyStyles.bodyCell,
side.edge === 'start' ? shadowStyles.start : shadowStyles.end,
diff --git a/packages/core/src/Table/types.ts b/packages/core/src/Table/types.ts
index ba47893233..719fabe292 100644
--- a/packages/core/src/Table/types.ts
+++ b/packages/core/src/Table/types.ts
@@ -223,13 +223,13 @@ export interface TableColumn<T extends Record<string, unknown>> {
/** Props passed through the plugin pipeline for the `<table>` element */
export interface TableRenderProps {
htmlProps: HTMLAttributes<HTMLTableElement>;
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
}
/** Props passed through the plugin pipeline for the header `<tr>` */
export interface HeaderRowRenderProps {
htmlProps: HTMLAttributes<HTMLTableRowElement>;
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
children: ReactNode;
}
@@ -250,7 +250,7 @@ export interface HeaderRowRenderProps {
*/
export interface HeaderCellRenderProps {
htmlProps: ThHTMLAttributes<HTMLTableCellElement>;
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
/** Content rendered before the header label. */
before?: ReactNode;
/** The header label content. Initialized from `column.header ?? column.key`. Plugins may wrap or replace. */
@@ -286,7 +286,7 @@ export interface HeaderCellRenderProps {
/** Props passed through the plugin pipeline for each body `<tr>` */
export interface BodyRowRenderProps {
htmlProps: HTMLAttributes<HTMLTableRowElement>;
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
children: ReactNode;
/** Ref for the `<tr>` element. Plugins can set this to access the row DOM node. */
ref?: Ref<HTMLTableRowElement>;
@@ -295,7 +295,7 @@ export interface BodyRowRenderProps {
/** Props passed through the plugin pipeline for each body `<td>` */
export interface BodyCellRenderProps {
htmlProps: TdHTMLAttributes<HTMLTableCellElement>;
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
/**
* Right-click context-menu actions for this body cell. Plugins append their
* actions in `transformBodyCell`; BaseTable concatenates the arrays across
@@ -341,7 +341,7 @@ export interface ScrollWrapperRenderProps {
htmlProps: HTMLAttributes<HTMLDivElement> & {
ref?: Ref<HTMLDivElement>;
};
- styles: StyleXStyles[];
+ xstyle: StyleXStyles[];
/** Content rendered before the `<table>`, inside the scroll container. */
beforeTable?: ReactNode;
/** Content rendered after the `<table>`, inside the scroll container. */
@@ -389,8 +389,7 @@ export interface TableContextAction {
* every render.
*/
export type TableContextActions =
- | TableContextAction[]
- | (() => TableContextAction[]);
+ TableContextAction[] | (() => TableContextAction[]);
// =============================================================================
// Plugin Interface
@@ -543,7 +542,14 @@ export interface BaseTableProps<
/** Children mode — render `<tr>`/`<td>` directly instead of data-driven */
children?: ReactNode;
- /** Additional HTML attributes for the `<table>` element */
+ /**
+ * Additional HTML attributes for the `<table>` element.
+ *
+ * @deprecated Pass `className`, `style`, `xstyle`, and other HTML
+ * attributes directly on the component instead — they now reach the root
+ * `<table>` and win over `tableProps` on conflicts. Migrate with
+ * `npx astryx upgrade --codemod migrate-table-tableprops-to-direct-props`.
+ */
tableProps?: HTMLAttributes<HTMLTableElement>;
/**
* Optional wrapper rendered around the `<table>` element, inside the
@@ -551,15 +557,15 @@ export interface BaseTableProps<
* horizontal scroll container so plugin chrome (pagination, toolbars)
* stays outside the scrollable area.
*
- * Receives `htmlProps` (including an optional `ref`) and `styles` produced
+ * Receives `htmlProps` (including an optional `ref`) and `xstyle` produced
* by the plugin `transformScrollWrapper` pipeline, plus `beforeTable`/`afterTable`
- * chrome. The wrapper must spread `htmlProps` (and apply `styles`) onto its
+ * chrome. The wrapper must spread `htmlProps` (and apply `xstyle`) onto its
* scroll-container element so plugins can attach refs / scroll listeners.
*/
scrollWrapper?: ComponentType<{
children: ReactNode;
htmlProps?: HTMLAttributes<HTMLDivElement> & {ref?: Ref<HTMLDivElement>};
- styles?: StyleXStyles[];
+ xstyle?: StyleXStyles[];
beforeTable?: ReactNode;
afterTable?: ReactNode;
}>;