v1.3.0

Angular data table

Table, Bro has its own package for Angular, @table-bro/angular: the component ‹table-bro-ng› renders the Custom Element ‹table-bro›, gives it the signal inputs cols, rows and conf, and turns its bro-action events into the outputs action and query. It works with the three skins: Angular Material, Vanilla Bootstrap and Vanilla HTML. Angular Material implements Material M3. The page below is the working page of the sample project samples/angular-material of the repository, with Angular 22 and Angular Material; StackBlitz opens it in the browser.

Filters
Orders
Loading
5
0 of 0

How do I install Table, Bro in Angular?

Install with the MCP server

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. 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 manually

The steps of each skin; the component of the table is the same in all three.

Angular Material
  1. Install the packages

    The table and the parts it needs; a project without Angular Material adds it first with ng add @angular/material.

    npm install @table-bro/core @table-bro/angular @table-bro/angular-material @angular/elements
    
  2. Add the CSS

    To "styles" of angular.json:

    "styles": [
      "node_modules/@table-bro/core/dist/table-bro.min.css",
      "node_modules/@table-bro/angular-material/dist/table-bro.material.min.css"
    ]
    
  3. Register the skin and its elements

    In the providers of app.config.ts. The elements that only some tables use come with their functions: withTags() for tags, withSwitch() for switches, withToolbarMenu() for the menu of the toolbar; a project that registers the skin already adds the ones of a new table to the call.

    import type {ApplicationConfig} from '@angular/core';
    
    import {provideTableBroMatSkin} from '@table-bro/angular-material';
    
    export const appConfig: ApplicationConfig = {
      providers: [
        provideTableBroMatSkin()
      ]
    };
    
  4. Keep the theme of Angular Material

    The mat skin takes the theme of the application, as the components of Angular Material do: the table looks as a mat-table of the project, and a table in the dark theme takes the dark scheme of the theme. ng add @angular/material writes the theme into styles.scss; a project without it adds it:

    @use '@angular/material' as mat;
    
    html {
      @include mat.theme((
        color: (
          primary: mat.$azure-palette,
          tertiary: mat.$blue-palette,
        ),
        typography: Roboto,
        density: 0,
      ));
    }
    
  5. Load the fonts of the icons

    The mat skin shows the ligature icons of Material, as Angular Material asks; the cells and the dialogs of the page take the newer Material Symbols. In index.html:

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,300,0,0" rel="stylesheet">
    
Vanilla Bootstrap
  1. Install the packages

    The table and the parts it needs:

    npm install @table-bro/core @table-bro/angular @table-bro/bootstrap bootstrap @types/bootstrap
    
  2. Add the CSS

    To "styles" of angular.json:

    "styles": [
      "node_modules/bootstrap/dist/css/bootstrap.min.css",
      "node_modules/@table-bro/core/dist/table-bro.min.css",
      "node_modules/@table-bro/bootstrap/dist/table-bro.bootstrap.min.css"
    ]
    
  3. Register the skin

    Once, in main.ts: the import registers the skin, which takes the classes of Bootstrap. The elements that only some tables use come with their functions: withTags() for tags, withSwitch() for switches; a project that registers the skin already adds the ones of a new table. A page may define them itself, as customElements.define('bro-bs-tags', BroBootstrapTagsComponent). With Angular server-side rendering, app.config.ts imports the package as well, import '@table-bro/bootstrap';, so that the server renders the skin too: Angular SSR.

    import {useBootstrap}      from '@table-bro/bootstrap';
    import {Dropdown, Tooltip} from 'bootstrap';
    
    useBootstrap({Dropdown, Tooltip});
    
Vanilla HTML
  1. Install the packages

    The table and the parts it needs:

    npm install @table-bro/core @table-bro/angular @table-bro/native
    
  2. Add the CSS

    To "styles" of angular.json:

    "styles": [
      "node_modules/@table-bro/core/dist/table-bro.min.css",
      "node_modules/@table-bro/native/dist/table-bro.native.min.css"
    ]
    
  3. Register the skin

    Once, in main.ts: the import registers the skin. The elements that only some tables use come with their functions: withTags() for tags, withSwitch() for switches; a project that registers the skin already adds the ones of a new table. A page may define them itself, as customElements.define('bro-nv-tags', BroNativeTagsComponent). With Angular server-side rendering, app.config.ts imports the package as well, import '@table-bro/native';, so that the server renders the skin too: Angular SSR.

    import '@table-bro/native';
    

With server-side rendering, the steps of Angular SSR come after these: the server render of Angular prerenders the table in its loading state, with the same component.

Which skins can I use?

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.

How do I pass cols, rows and conf?

‹table-bro-ng› takes them as inputs, here from signals of the component (Angular, Accepting data with input properties). A new value of rows replaces the rows of the table, and conf.skin names the registered skin. src/app/orders.component.ts:

import {ChangeDetectionStrategy, Component, signal} from '@angular/core';

import {TableBroNg}                     from '@table-bro/angular';
import type {BroCol, BroConfig, BroRow} from '@table-bro/core';

interface Order extends BroRow {
  description: string;
  price: number;
}

@Component({
  selector: 'app-orders',
  template: `
    <table-bro-ng class="bro-table-shadow-container" tableId="orders"
                  [cols]="cols()" [rows]="rows()" [conf]="conf()"></table-bro-ng>`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    TableBroNg
  ]
})
export class OrdersComponent {
  cols = signal<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
  rows = signal<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}
  ]);

  conf = signal<BroConfig>({
    skin: 'mat',
    toolbarTitle: 'Orders'
  });
}

How do I listen to bro-action?

The output action emits the detail of every bro-action event of the table, a BroActionDetail: custom cells, the toolbar, the paginator. The output query emits the queries of a table with server-side data instead (Angular, Custom events with outputs). In the template: (action)="onAction($event)".

How do I switch the theme?

The input theme of ‹table-bro-ng› is 'light', 'dark' or 'auto', which follows the color scheme of the system; without it the table takes config.theme, 'auto' by default. The table puts the class bro-dark-theme or bro-light-theme on itself. More in Dark/Light mode.

Questions

Does the template need CUSTOM_ELEMENTS_SCHEMA?

Not for ‹table-bro-ng›: it is a component of Angular in imports of the component. A template that renders ‹table-bro› itself needs CUSTOM_ELEMENTS_SCHEMA. Angular also turns its own components into Custom Elements (Angular, Custom Elements).

Does it work with server-side rendering?

Yes: ‹table-bro-ng› prerenders the table in its loading state during the server-side rendering of Angular, as Angular SSR shows.

Related

Getting started, Custom content in tables using Custom Elements, MCP server for AI coding agents, Angular SSR, Preact data table, React data table, Solid data table, Svelte data table, Vue 3 data table, Vanilla JS data table.

DJ