Table, Bro is the Custom Element ‹table-bro›, so a React 19 app renders it in JSX as it is, without a wrapper package. A ref gives the element its columns, rows and config by configure(), an effect adds the listener of its bro-action events, and the theme prop sets its theme. The working page is the sample project samples/react-mui/react of the repository, with React 19.3 and the React MUI skin; StackBlitz opens it in the browser, and the setup below is its code. The Bootstrap skin of the sample project samples/frameworks/react and Native work in React the same way, as a skin of your own UI components does.
No | Description | Price |
|---|
|
|
The quickest start is the MCP server of Table, Bro: add it to your AI coding agent and describe the table you need. The agent installs the packages, generates the table, its setup and its cells, and checks the result. In a React app the server generates the table for Vanilla JS: a module with a function that renders ‹table-bro› into an element, which a component gives it. For Claude Code, in the root of the project:
claude mcp add --scope project table-bro -- npx -y @table-bro/mcp@1.3.0
MCP server gives the setup for Codex, Cursor, VS Code and Claude Desktop.
Install the packages
The table engine @table-bro/core, the skin @table-bro/react-mui, and MUI with Emotion, its styles. The skins @table-bro/bootstrap and @table-bro/native work in React the same way, as Getting started shows:
npm install @table-bro/core @table-bro/react-mui @mui/material @emotion/react @emotion/styled
Give the skin the theme of the application
The MUI theme of the application turns on its CSS variables, which the table reads, and the attribute of its color schemes, which a table with a theme of its own sets. Its light and dark schemes have the colors of the sample of Angular Material, the azure palette of Material 3, so that the table looks as the table of the skin mat. src/theme.ts:
import {createTheme} from '@mui/material/styles';
// The theme of the application: its CSS variables give the colors to the table, and the attribute of its color
// schemes lets a table with a theme of its own take the light or the dark one. The colors are the ones of the theme of
// the sample of Angular Material, the azure palette of Material 3, so the table looks as the table of the skin mat
export const theme = createTheme({
cssVariables: {colorSchemeSelector: 'data-mui-color-scheme'},
colorSchemes: {
light: {
palette: {
primary: {main: '#005cbb', contrastText: '#ffffff'},
text: {primary: '#1a1b1f', secondary: '#44474e'},
action: {active: '#44474e', hover: 'rgba(26, 27, 31, 0.08)', hoverOpacity: 0.08, disabled: 'rgba(26, 27, 31, 0.38)'},
background: {default: '#faf9fd', paper: '#faf9fd'},
divider: '#e0e2ec',
'LinearProgress': {primaryBg: '#e0e2ec'},
'TableCell': {border: '#74777f'}
}
},
dark: {
palette: {
primary: {main: '#abc7ff', contrastText: '#002f65'},
text: {primary: '#e3e2e6', secondary: '#e0e2ec'},
action: {active: '#e0e2ec', hover: 'rgba(227, 226, 230, 0.08)', hoverOpacity: 0.08, disabled: 'rgba(227, 226, 230, 0.38)'},
background: {default: '#121316', paper: '#121316'},
divider: '#44474e',
'LinearProgress': {primaryBg: '#44474e'},
'TableCell': {border: '#8e9099'}
}
}
}
});
Once, before the tables: the import of the skin defines ‹table-bro› and registers the skin mui, and setMuiTheme() gives its elements the theme. The CSS of the core and of the skin come as imports, which Vite and the other bundlers take. src/skin.ts:
// The CSS of the core and of the skin, then the skin: its import defines <table-bro> and registers the skin mui, and
// setMuiTheme() gives its elements the theme of the application
import '@table-bro/core/dist/table-bro.min.css';
import '@table-bro/react-mui/dist/table-bro.react-mui.min.css';
import {setMuiTheme} from '@table-bro/react-mui';
import {theme} from './theme';
import './sample-page.css';
setMuiTheme(theme);
Load the fonts of MUI
Roboto and the ligature icons of Material, which the skin shows, come from Google Fonts. index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Table, Bro + React MUI</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Describe the columns, the rows and the config
conf.skin names the registered skin. src/orders.ts:
import type {BroCol, BroConfig, BroRow} from '@table-bro/core';
export interface Order extends BroRow {
description: string;
price: number;
}
export const cols: BroCol<Order>[] = [
{
title: 'Description',
name: 'description'
}, {
title: 'Price',
name: 'price',
dataType: 'number',
className: 'bro-col_text-right'
}
];
// The orders of the demos of Docs on table-bro.com
export const rows: Order[] = [
{description: 'Handcrafted Wooden Table, Gorgeous Bronze Watch, Modern Fresh Salad, Refined Plastic Keyboard, Practical Rubber Shoes', price: 80},
{description: 'Small Concrete Gloves, Licensed Frozen Pizza, Refined Plastic Keyboard, Modern Fresh Salad, Practical Rubber Shoes', price: 57},
{description: 'Rustic Cotton Shirt, Ergonomic Steel Chair, Handcrafted Wooden Table, Small Concrete Gloves, Sleek Granite Lamp', price: 13},
{description: 'Refined Plastic Keyboard, Ergonomic Steel Chair, Modern Fresh Salad, Gorgeous Bronze Watch, Sleek Granite Lamp', price: 27},
{description: 'Licensed Frozen Pizza, Practical Rubber Shoes, Gorgeous Bronze Watch, Sleek Granite Lamp, Rustic Cotton Shirt', price: 96},
{description: 'Small Concrete Gloves, Handcrafted Wooden Table, Gorgeous Bronze Watch, Ergonomic Steel Chair, Practical Rubber Shoes', price: 69},
{description: 'Practical Rubber Shoes, Modern Fresh Salad, Refined Plastic Keyboard, Handcrafted Wooden Table, Gorgeous Bronze Watch', price: 91},
{description: 'Modern Fresh Salad, Practical Rubber Shoes, Ergonomic Steel Chair, Licensed Frozen Pizza, Gorgeous Bronze Watch', price: 48},
{description: 'Gorgeous Bronze Watch, Refined Plastic Keyboard, Licensed Frozen Pizza, Ergonomic Steel Chair, Rustic Cotton Shirt', price: 75},
{description: 'Small Concrete Gloves, Refined Plastic Keyboard, Handcrafted Wooden Table, Rustic Cotton Shirt, Practical Rubber Shoes', price: 97},
{description: 'Modern Fresh Salad, Refined Plastic Keyboard, Licensed Frozen Pizza, Practical Rubber Shoes, Sleek Granite Lamp', price: 54},
{description: 'Modern Fresh Salad, Refined Plastic Keyboard, Ergonomic Steel Chair, Practical Rubber Shoes, Handcrafted Wooden Table', price: 99},
{description: 'Sleek Granite Lamp, Ergonomic Steel Chair, Handcrafted Wooden Table, Gorgeous Bronze Watch, Practical Rubber Shoes', price: 55},
{description: 'Refined Plastic Keyboard, Sleek Granite Lamp, Modern Fresh Salad, Handcrafted Wooden Table, Ergonomic Steel Chair', price: 81},
{description: 'Refined Plastic Keyboard, Modern Fresh Salad, Practical Rubber Shoes, Small Concrete Gloves, Rustic Cotton Shirt', price: 86},
{description: 'Practical Rubber Shoes, Small Concrete Gloves, Refined Plastic Keyboard, Licensed Frozen Pizza, Rustic Cotton Shirt', price: 56},
{description: 'Rustic Cotton Shirt, Practical Rubber Shoes, Small Concrete Gloves, Ergonomic Steel Chair, Licensed Frozen Pizza', price: 20},
{description: 'Modern Fresh Salad, Refined Plastic Keyboard, Small Concrete Gloves, Sleek Granite Lamp, Handcrafted Wooden Table', price: 34},
{description: 'Refined Plastic Keyboard, Modern Fresh Salad, Small Concrete Gloves, Licensed Frozen Pizza, Rustic Cotton Shirt', price: 72},
{description: 'Ergonomic Steel Chair, Practical Rubber Shoes, Gorgeous Bronze Watch, Rustic Cotton Shirt, Modern Fresh Salad', price: 57}
];
export const conf: BroConfig = {
skin: 'mui',
toolbarTitle: 'Orders'
};
With server-side rendering, the steps of Next.js come after these: a server component prerenders the table in its loading state in the markup of MUI.
Table, Bro ships the skins Angular Material, React MUI, Solid SUID, Svelte M3, Vue Vuetify, Vanilla Bootstrap and Vanilla HTML, and a skin of your own design system or UI components is built the same way: Getting started describes the skins, and Your own skin how to build one.
The columns, the rows and the config go to the table in one call, configure({cols, rows, conf}), once the element is in the document: a ref gives the element, useEffect makes the call after the first render, through queueMicrotask(): the elements of the skin render by flushSync of React, which waits for the end of the effects, and the table measures them right after it renders them. The same effect adds the listener of bro-action and removes it at the end; the sample logs the name of each action. src/OrdersTable.tsx:
import {useEffect, useRef} from 'react';
import type {BroActionDetail, TableBroHTMLElement} from '@table-bro/core';
import {cols, conf, rows} from './orders';
export function OrdersTable() {
const table = useRef<TableBroHTMLElement>(null);
useEffect(() => {
const element = table.current!;
const onAction = (event: CustomEvent<BroActionDetail>) => console.log(event.detail.action);
// The elements of the skin render by flushSync of React, which waits for the end of the effects: the table
// renders after them, and measures its elements rendered
queueMicrotask(() => element.configure({cols, rows, conf}));
element.addEventListener('bro-action', onAction);
return () => element.removeEventListener('bro-action', onAction);
}, []);
return (
<div className="bro-table-shadow-container">
<table-bro id="orders" ref={table} theme="auto"></table-bro>
</div>
);
}
React 19 sets a prop of a custom element as a property when the element has a property of that name, and as an attribute otherwise (React 19, Support for Custom Elements): theme is a property of ‹table-bro›. "jsx": "react-jsx" in tsconfig.json of the sample gives the JSX runtime of React to TypeScript and to Vite.
JSX of React knows the HTML elements only; a declaration adds ‹table-bro› with the methods of TableBroHTMLElement. src/elements.d.ts:
// The element <table-bro> in the JSX of React, with its attribute theme
import type {DetailedHTMLProps, HTMLAttributes} from 'react';
import type {TableBroHTMLElement} from '@table-bro/core';
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
'table-bro': DetailedHTMLProps<HTMLAttributes<TableBroHTMLElement>, TableBroHTMLElement> & {theme?: 'light' | 'dark' | 'auto'};
}
}
}
src/main.tsx imports the skin before the tables, and renders them in ThemeProvider of MUI, which writes the CSS variables of the theme, with CssBaseline. defaultMode="light" keeps the page light, as the page of the sample of Angular Material; the table takes the color scheme of the system by its theme:
// The skin is registered before the tables
import './skin';
import CssBaseline from '@mui/material/CssBaseline';
import {ThemeProvider} from '@mui/material/styles';
import {StrictMode} from 'react';
import {createRoot} from 'react-dom/client';
import {OrdersTable} from './OrdersTable';
import {theme} from './theme';
// The page is light, as the page of the sample of Angular Material; the table takes the scheme of the system by its
// theme
createRoot(document.getElementById('app')!).render(
<StrictMode>
<ThemeProvider theme={theme} defaultMode="light">
<CssBaseline />
<OrdersTable />
</ThemeProvider>
</StrictMode>
);
The theme attribute or property of the table is 'light', 'dark' or 'auto', which follows the color scheme of the system; the attribute wins over config.theme. The sample sets 'auto', as a table without the attribute does; a variable of the state bound to it switches the theme, and the table puts the class bro-dark-theme or bro-light-theme on itself, and the attribute data-mui-color-scheme of the MUI theme. More in Dark/Light mode.
No. React 19 passes the props of a custom element as properties or attributes (React, Custom HTML elements) and passes all 32 tests of Custom Elements Everywhere. Table, Bro takes its data by configure() through a ref, which works in every version of React.
The sample uses addEventListener in an effect: it works in React 18 and 19 and removes the listener on unmount.
Yes. The table renders in the browser, as configure() runs in an effect of a client component ('use client'), and the server render of Next.js prerenders it in its loading state in the markup of MUI: Next.js.
Getting started, Custom content in tables using Custom Elements, MCP server for AI coding agents, Next.js, Angular data table, Preact data table, Solid data table, Svelte data table, Vue 3 data table, Vanilla JS data table.
We use Google Analytics to understand how you use our site and to make it better.
Learn more in our Privacy Policy