Table

The <smart-table> component renders a tabular data view with optional title, description, toolbar slot, columns + rows, optional checkbox column, custom per-cell/per-header templates, an empty state slot, and a bottom footer slot. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract TableBaseComponent defines the shared API — optional ITableOptions and cssClass (alias class). TableStandardComponent is a barebones placeholder concrete implementation. TableComponent is the public wrapper that renders TableStandardComponent by default and accepts a custom replacement via TABLE_STANDARD_COMPONENT_TOKEN. TablePresetComponent is the styled Tailwind variation you register on that token (see Preset).


Usage

<smart-table [options]="options" />

The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Components

TableComponent (<smart-table>)

Main wrapper component. Renders TableStandardComponent by default. When TABLE_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet and hands it the options and class inputs.

TableStandardComponent (<smart-table-standard>)

Barebones placeholder concrete implementation. Renders a wrapper <div> containing an optional <h3 class="title">, optional <p class="description">, optional toolbar slot, and — only when there is at least one column — a <table> with <thead> (one <th> per column, with the column label or, without it, the key, and the column's ariaLabel and data-align) and <tbody> (one <tr> per row, one <td> per column reading the value via row[col.key]). When withCheckboxes is set, an extra column of plain, unbound checkboxes is rendered before all data columns. Per-column cellTpl (context { $implicit: row, column }) and headerTpl templates override the default text rendering. When rows is empty and emptyTpl is provided, the empty template is rendered as a single full-width row. A bottom footerTpl renders inside <div class="footer">. The external cssClass is applied to the root wrapper. It does not include any visual styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.

TablePresetComponent (<smart-table-preset>)

Styled drop-in replacement for TableStandardComponent. See Preset.

TableBaseComponent (abstract)

Abstract base directive for extending custom table implementations. Exposes options as an InputSignal<ITableOptions | undefined> and cssClass as an InputSignal<string> (with alias class).

API

Inputs

InputTypeDefaultDescription
optionsInputSignal<ITableOptions | undefined>-Optional configuration (title, description, columns, rows, layout flags, empty/footer slots)
classInputSignal<string>''External CSS classes (alias for cssClass)

ITableOptions

All properties are optional except ITableColumn.key. A section is rendered only when its template/string is provided.

FieldTypeDefaultDescription
titlestring-Heading above the table.
descriptionstring-Text under the heading.
toolbarTplTemplateRef<unknown>-A slot above the table (filters, buttons).
columnsITableColumn[][]The columns; without any, no <table> is rendered.
rowsTableRow[][]The rows, as records (Record<string, unknown>).
withCheckboxesboolean-A checkbox column: plain, unbound inputs in the standard; select-all and row highlight in the preset (internal state, no outputs).
emptyTplTemplateRef<unknown>-A full-width row shown when there are no rows.
footerTplTemplateRef<unknown>-A slot below the table.
stripedboolean-Preset only: zebra rows. The standard ignores it.
stickyHeaderboolean-Preset only: the body scrolls under a sticky header. The standard ignores it.
withBorderboolean-Preset only: a bordered card frame. The standard ignores it.

ITableColumn

FieldTypeDefaultDescription
keystringrequiredThe row field shown in the column.
labelstringkeyHeader text.
align'left' | 'center' | 'right''left'The standard only sets data-align; the preset aligns the header and the body cells.
sortableboolean-Preset only: a header button that sorts the rows client-side (internal state, no outputs).
cellTplTemplateRef<unknown>-Body cell content, with the context { $implicit: row, column }.
headerTplTemplateRef<unknown>-Header content; wins over label.
ariaLabelstring-Accessible name of the header cell.

TABLE_STANDARD_COMPONENT_TOKEN

InjectionToken that allows replacing the default TableStandardComponent with a custom implementation. Provide a component class extending TableBaseComponent under TABLE_STANDARD_COMPONENT_TOKEN; every <smart-table> below that injector renders it.

Preset

TablePresetComponent (<smart-table-preset>) extends TableBaseComponent, so it takes the same options input, and it renders everything the standard component renders in the Tailwind UI table look. Every class carries the smart: prefix and has an explicit smart:dark:* twin. The class recipes are internal to the preset and not exported.

It styles the parts listed below.

  • Header (data-role="header", only rendered when there is a title, description or toolbar). The title is an <h3> with text-base font-semibold text-gray-900 dark:text-white. The description uses text-sm text-gray-500 dark:text-gray-400. toolbarTpl sits on the right of the header on sm+ screens.
  • Table. min-w-full divide-y divide-gray-300 dark:divide-white/15. Header cells use text-sm font-semibold text-gray-900 dark:text-white. Body cells use whitespace-nowrap text-sm: the first data column is emphasised (font-medium text-gray-900 dark:text-white) and the rest are muted (text-gray-500 dark:text-gray-400).
  • Checkbox column (withCheckboxes). Styled checkboxes, with select-all and an indeterminate state in the header. Selected rows are highlighted with bg-gray-50 dark:bg-gray-800/50. Selection is internal visual state; the table has no outputs.
  • Slots. cellTpl gets { $implicit: row, column }. headerTpl replaces the label. emptyTpl renders in a centred row that spans every column (checkbox column included). footerTpl renders under the table.
  • External class. Merged onto the root <div> next to w-full.

The table lists the options the standard component ignores, which the preset honours.

OptionPreset rendering
defaultRows separated by divide-y divide-gray-200 dark:divide-white/10, no frame, outer columns flush with the edges
stripedRow dividers replaced by zebra stripes, even:bg-gray-50 dark:even:bg-gray-800/50
withBorderRounded card (rounded-lg bg-white shadow-sm outline-1 outline-black/5, dark:bg-gray-900 dark:outline-white/10) with a bg-gray-50 dark:bg-gray-800/75 header, outer cells padded
stickyHeaderBody scrolls inside max-h-96 overflow-y-auto; header cells are sticky top-0 z-10 bg-white/75 backdrop-blur-sm dark:bg-gray-900/75
column.aligntext-left / text-center / text-right on both the header and the body cells
column.sortableHeading becomes a button with a chevron. Click sorts the rows client-side ascending, click again for descending; aria-sort is set on the <th>. Numbers sort numerically, text in natural order, empty values last. The active column's chevron gets a bg-gray-100 dark:bg-gray-800 chip

The flags combine freely (for example striped + bordered + sortable + checkboxes).

The preset declares cssClass without the inherited class alias. Pass class on <smart-table> as usual, or bind [cssClass] when you use <smart-table-preset> directly.

Provide TablePresetComponent under TABLE_STANDARD_COMPONENT_TOKEN to restyle every <smart-table>, or register every preset of the library at once with provideSmartPresets().

The preset adds no new ITableOptions fields; it only consumes the existing API.

Extending the base class

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

import {
  ITableOptions,
  TABLE_STANDARD_COMPONENT_TOKEN,
  TableBaseComponent,
  TableComponent,
  TableRow,
} from '@smartsoft001/angular';

@Component({
  selector: 'docs-custom-table',
  template: `
    <div [class]="containerClasses()">
      @if (options()?.title) {
        <h3 class="docs-table__title">{{ options()!.title }}</h3>
      }
      @if (options()?.description) {
        <p class="docs-table__description">{{ options()!.description }}</p>
      }

      <table>
        <thead>
          <tr>
            @for (col of options()?.columns ?? []; track col.key) {
              <th scope="col" [attr.data-align]="col.align ?? null">
                {{ col.label ?? col.key }}
              </th>
            }
          </tr>
        </thead>
        <tbody>
          @for (row of options()?.rows ?? []; track $index) {
            <tr>
              @for (col of options()?.columns ?? []; track col.key) {
                <td [attr.data-align]="col.align ?? null">
                  {{ readCell(row, col.key) }}
                </td>
              }
            </tr>
          }
        </tbody>
      </table>
    </div>
  `,
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomTableComponent extends TableBaseComponent {
  containerClasses = computed(() =>
    [
      'docs-table',
      this.options()?.striped ? 'docs-table--striped' : '',
      this.options()?.withBorder ? 'docs-table--bordered' : '',
      this.cssClass(),
    ]
      .filter(Boolean)
      .join(' '),
  );

  // Rows are plain records, so cells are read by the column key.
  protected readCell(row: TableRow, key: string): unknown {
    return row[key];
  }
}

@Component({
  selector: 'docs-table-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [TableComponent],
  // The token swaps the standard table for the custom one everywhere below this
  // component, so consumers keep writing `<smart-table>`.
  providers: [
    {
      provide: TABLE_STANDARD_COMPONENT_TOKEN,
      useValue: CustomTableComponent,
    },
  ],
  template: `<smart-table [options]="options" />`,
})
export class TableCustomExampleComponent {
  options: ITableOptions = {
    title: 'Users',
    description: 'Everyone with access to this workspace.',
    striped: true,
    columns: [
      { key: 'name', label: 'Name' },
      { key: 'role', label: 'Role' },
      { key: 'email', label: 'Email' },
      { key: 'seats', label: 'Seats', align: 'right' },
    ],
    rows: [
      {
        name: 'Lindsay Walton',
        role: 'Front-end Developer',
        email: 'lindsay.walton@example.com',
        seats: 3,
      },
      {
        name: 'Courtney Henry',
        role: 'Designer',
        email: 'courtney.henry@example.com',
        seats: 1,
      },
      {
        name: 'Tom Cook',
        role: 'Director of Product',
        email: 'tom.cook@example.com',
        seats: 8,
      },
    ],
  };
}

Source

The component lives in packages/shared/angular/src/lib/components/table and is documented for Claude Code by the angular-components-table skill.

SmartTable renders a <table> from options.columns and options.rows (plain records). A column's cellTpl is a node or a render function of { row, column }; without it the cell shows row[column.key] as text. SmartTableStandard is unstyled and ignores the visual hints; SmartTablePreset honours striped, stickyHeader, withBorder, per-column align, client-side sorting of sortable columns (with aria-sort) and a checkbox column with select-all. Sort and selection are internal to the preset and not reported to the parent.


Usage

import { ISmartTableOptions, SmartTable } from '@smartsoft001/react';

const options: ISmartTableOptions = {
  title: 'Users',
  description: 'Everyone in your account, with their title and role.',
  striped: true,
  columns: [
    { key: 'name', label: 'Name' },
    { key: 'title', label: 'Title' },
    { key: 'email', label: 'Email' },
    { key: 'role', label: 'Role', align: 'right' },
  ],
  rows: [
    {
      name: 'Lindsay Walton',
      title: 'Front-end Developer',
      email: 'lindsay.walton@example.com',
      role: 'Member',
    },
    {
      name: 'Courtney Henry',
      title: 'Designer',
      email: 'courtney.henry@example.com',
      role: 'Admin',
    },
    {
      name: 'Tom Cook',
      title: 'Director of Product',
      email: 'tom.cook@example.com',
      role: 'Member',
    },
  ],
};

export function TableUsageExample() {
  return <SmartTable options={options} />;
}

The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Exports

All from @smartsoft001/react.

ExportKindWhat it is
SmartTablecomponentRenders the implementation registered as components.table on SmartProvider, SmartTableStandard by default.
SmartTablePresetcomponentStyled table variation (preset).
SmartTableStandardcomponentThe default table rendering: an unstyled title, description and toolbar, a <table> (only when there are columns) with an optional checkbox column, the emptyTpl row when there are no rows, and the footer slot.
renderTableCellfunctionThe content of a body cell: the column's cellTpl (called with the { row, column } context when it is a function), otherwise row[column.key] as text, empty for null / undefined.

The preset's class helpers (getTableFrameClasses, getTableScrollClasses, getTableHeadClasses, getTableBodyClasses, getTableHeaderCellClasses, getTableRowClasses, getTableCellClasses, getTableSortIconClasses, TABLE_ROOT, TABLE_HEADER, TABLE_HEADER_TEXT, TABLE_TITLE, TABLE_DESCRIPTION, TABLE_TOOLBAR, TABLE_TABLE, TABLE_CHECKBOX_CELL, TABLE_CHECKBOX, TABLE_SORT_BUTTON, TABLE_EMPTY, TABLE_FOOTER) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartTableProps

PropTypeDefaultDescription
options?ISmartTableOptions—Columns, rows, hints and slots.
className?string—Classes on the root element.

ISmartTableOptions

ITableOptions with ISmartTableColumn columns. Extends Omit<ITableOptions, 'columns'>.

FieldTypeDefaultDescription
columns?ISmartTableColumn[][]The columns.

ITableOptions

The base options; ISmartTableOptions replaces its columns.

FieldTypeDefaultDescription
title?string—Heading above the table.
description?string—Text under the heading.
columns?ITableColumn[][]See ISmartTableOptions.columns.
rows?TableRow[][]The rows, as records.
striped?boolean—Preset: zebra rows.
stickyHeader?boolean—Preset: the header sticks while scrolling.
withCheckboxes?boolean—A checkbox column (select-all and row highlight in the preset; plain unbound inputs in the standard).
withBorder?boolean—Preset: a bordered card frame.
emptyTpl?ReactNode—Row shown when there are no rows.
footerTpl?ReactNode—A slot below the table.
toolbarTpl?ReactNode—A slot above the table (filters, buttons).

SmartTableCellContext

What a cellTpl render function receives: the cell's row and column.

FieldTypeDefaultDescription
rowTableRowrequiredThe row being rendered.
columnISmartTableColumnrequiredThe column being rendered.

ISmartTableColumn

ITableColumn whose cellTpl may be a render function of the cell's row and column. headerTpl has no context and stays a ReactNode. Extends Omit<ITableColumn, 'cellTpl'>.

FieldTypeDefaultDescription
cellTpl?SmartTableCellTpl—A node, or a render function of { row, column }.

ITableColumn

The base column; ISmartTableColumn widens its cellTpl.

FieldTypeDefaultDescription
keystringrequiredThe row field shown in the column.
label?string—Header text.
align?'left' | 'center' | 'right'—Preset: cell alignment.
sortable?boolean—Preset: a clickable header that sorts the rows client-side.
cellTpl?ReactNode—See ISmartTableColumn.cellTpl.
headerTpl?ReactNode—Header content as a node; wins over label.
ariaLabel?string—Accessible name of the header cell.
  • SmartTableCellTpl: ReactNode \| ((context: SmartTableCellContext) => ReactNode) — A node, or a render function of the cell context.
  • TableRow: Record<string, unknown> — A row: a record of field values.

Replacing the Implementation

SmartTable renders the component registered under the 'table' key of SmartProvider's components, and SmartTableStandard when nothing is registered there. Every SmartTable below the provider then renders the registered component, which receives the same props.

SmartTablePreset is the styled (preset) implementation: register it under the 'table' key of SmartProvider's components, render it directly in place of SmartTable, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.

renderTableCell(row, column) is the cell rule every rendering uses (the cellTpl, else row[column.key] as text), so a custom table stays consistent:

import {
  ISmartTableOptions,
  renderTableCell,
  SmartProvider,
  SmartTable,
  SmartTableProps,
} from '@smartsoft001/react';

// The table has no behaviour hook: an implementation only renders its props.
// renderTableCell reads a cell the way every table does: the column's cellTpl,
// otherwise row[column.key] as text.
export function CustomTable({ options, className }: SmartTableProps) {
  const columns = options?.columns ?? [];
  const containerClasses = [
    'docs-table',
    options?.striped && 'docs-table--striped',
    options?.withBorder && 'docs-table--bordered',
    className,
  ]
    .filter(Boolean)
    .join(' ');

  return (
    <div className={containerClasses}>
      {options?.title && <h3 className="docs-table__title">{options.title}</h3>}
      {options?.description && (
        <p className="docs-table__description">{options.description}</p>
      )}

      <table>
        <thead>
          <tr>
            {columns.map((column) => (
              <th key={column.key} scope="col" data-align={column.align}>
                {column.label ?? column.key}
              </th>
            ))}
          </tr>
        </thead>
        <tbody>
          {(options?.rows ?? []).map((row, index) => (
            <tr key={index}>
              {columns.map((column) => (
                <td key={column.key} data-align={column.align}>
                  {renderTableCell(row, column)}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}

// A module constant: a new object on every render would change the context.
const components = { table: CustomTable };

const options: ISmartTableOptions = {
  title: 'Users',
  description: 'Everyone with access to this workspace.',
  striped: true,
  columns: [
    { key: 'name', label: 'Name' },
    { key: 'role', label: 'Role' },
    { key: 'email', label: 'Email' },
    { key: 'seats', label: 'Seats', align: 'right' },
  ],
  rows: [
    {
      name: 'Lindsay Walton',
      role: 'Front-end Developer',
      email: 'lindsay.walton@example.com',
      seats: 3,
    },
    {
      name: 'Courtney Henry',
      role: 'Designer',
      email: 'courtney.henry@example.com',
      seats: 1,
    },
    {
      name: 'Tom Cook',
      role: 'Director of Product',
      email: 'tom.cook@example.com',
      seats: 8,
    },
  ],
};

// Every <SmartTable> below the provider renders CustomTable.
export function TableCustomExample() {
  return (
    <SmartProvider components={components}>
      <SmartTable options={options} />
    </SmartProvider>
  );
}

Styling

  • SmartTableStandard renders the table only when there are columns, with no visual styles; SmartTablePreset carries the Tailwind UI look with smart:dark: variants.

Source

The component lives in packages/shared/react/src/lib/components/table and is documented for Claude Code by the react-components-table skill.