Table

Responsive data tables for displaying structured information. Use the Table component for most scenarios or the table primitives for complete control over rendering and layout.

Quick Start

Use the Table component to render tabular data from a simple configuration object containing headers and rows.

Product

Category

Price

Gold SheetSemi-Finished£125.00
Silver WireWire£42.50
1import { Table } from "@ecos/ui";
2
3<Table
4  tableData={{
5    headers: [
6      { key: "product", label: "Product" },
7      { key: "category", label: "Category" },
8      { key: "price", label: "Price" },
9    ],
10    rows: [
11      {
12        product: "Gold Sheet",
13        category: "Semi-Finished",
14        price: "£125.00",
15      },
16      {
17        product: "Silver Wire",
18        category: "Wire",
19        price: "£42.50",
20      },
21    ],
22  }}
23/>

Headlines

Optionally display a headline above the table and control its heading level.

Pricing Overview

Tier

Monthly Price

Starter£10
Professional£25
1<Table
2  headline="Pricing Overview"
3  headlineLevel="h2"
4  tableData={{
5    headers: [
6      { key: "tier", label: "Tier" },
7      { key: "price", label: "Monthly Price" },
8    ],
9    rows: [
10      { tier: "Starter", price: "£10" },
11      { tier: "Professional", price: "£25" },
12    ],
13  }}
14/>

Header Alignment

Headers and cells can be aligned independently using the align property.

Product

Qty

Price

Gold Sheet2£125.00
Silver Wire10£42.50
1<Table
2  tableData={{
3    headers: [
4      { key: "product", label: "Product" },
5      { key: "qty", label: "Qty", align: "center" },
6      { key: "price", label: "Price", align: "right" },
7    ],
8    rows: [
9      {
10        product: "Gold Sheet",
11        qty: 2,
12        price: "£125.00",
13      },
14      {
15        product: "Silver Wire",
16        qty: 10,
17        price: "£42.50",
18      },
19    ],
20  }}
21/>

Text Styling

Apply emphasis or muted styling to columns using the header configuration.

Product

Status

Gold SheetIn Stock
Silver WireOut of Stock
1<Table
2  tableData={{
3    headers: [
4      {
5        key: "product",
6        label: "Product",
7        isBold: true,
8      },
9      {
10        key: "status",
11        label: "Status",
12        isMuted: true,
13      },
14    ],
15    rows: [
16      {
17        product: "Gold Sheet",
18        status: "In Stock",
19      },
20      {
21        product: "Silver Wire",
22        status: "Out of Stock",
23      },
24    ],
25  }}
26/>

Row Banding

Rows are zebra-striped by default. Disable row banding using the removeBanding prop.

Feature

Enabled

Alternating row backgroundsNo
Header rowYes
1<Table
2  removeBanding
3  tableData={{
4    headers: [
5      { key: "feature", label: "Feature" },
6      { key: "enabled", label: "Enabled" },
7    ],
8    rows: [
9      {
10        feature: "Alternating row backgrounds",
11        enabled: "No",
12      },
13      {
14        feature: "Header row",
15        enabled: "Yes",
16      },
17    ],
18  }}
19/>

Hidden Headers

Hide visual table headers when the structure is already communicated elsewhere in the interface.

SKUABC123
CategorySemi-Finished
1<Table
2  hideHeaders
3  tableData={{
4    headers: [
5      { key: "name", label: "Name" },
6      { key: "value", label: "Value" },
7    ],
8    rows: [
9      {
10        name: "SKU",
11        value: "ABC123",
12      },
13      {
14        name: "Category",
15        value: "Semi-Finished",
16      },
17    ],
18  }}
19/>

Rich Content

Table cells support any React content, including links, badges, icons, and custom components.

Product

Status

Gold Sheet
Active
Silver Wire
Pending
1<Table
2  tableData={{
3    headers: [
4      { key: "product", label: "Product" },
5      { key: "status", label: "Status" },
6    ],
7    rows: [
8      {
9        product: "Gold Sheet",
10        status: (
11          <Badge variant="success">
12            Active
13          </Badge>
14        ),
15      },
16      {
17        product: "Silver Wire",
18        status: (
19          <Badge variant="warning">
20            Pending
21          </Badge>
22        ),
23      },
24    ],
25  }}
26/>

Advanced Usage

Use the table primitives when you need complete control over structure, styling, captions, or custom table sections.

Product

Price

Gold Sheet

£125.00

1import {
2  TablePrimitive,
3  TableHeaderPrimitive,
4  TableBodyPrimitive,
5  TableRowPrimitive,
6  TableHeadPrimitive,
7  TableCellPrimitive,
8} from "@ecos/ui";
9
10<TablePrimitive>
11  <TableHeaderPrimitive>
12    <TableRowPrimitive>
13      <TableHeadPrimitive>
14        Product
15      </TableHeadPrimitive>
16      <TableHeadPrimitive>
17        Price
18      </TableHeadPrimitive>
19    </TableRowPrimitive>
20  </TableHeaderPrimitive>
21
22  <TableBodyPrimitive>
23    <TableRowPrimitive>
24      <TableCellPrimitive>
25        Gold Sheet
26      </TableCellPrimitive>
27      <TableCellPrimitive>
28        £125.00
29      </TableCellPrimitive>
30    </TableRowPrimitive>
31  </TableBodyPrimitive>
32</TablePrimitive>

API Reference

Table

Property

Type

Default

Description

headlinestring-Optional heading displayed above the table.
headlineLevel"h2" | "h3""h2"Heading level used when rendering the table headline.
tableDataTableData-Table configuration containing headers and rows.
hideHeadersbooleanfalseHides the table header row when enabled.
removeBandingbooleanfalseRemoves alternating row background styling.
classNamestring-Additional classes applied to the table element.

TableData

Property

Type

Default

Description

headersTableHeaderType[]-Column definitions used to render the table structure.
rowsTableRowType[]-Array of row data mapped against header keys.

TableHeaderType

Property

Type

Default

Description

keystring-Unique identifier used to map row values to a column.
labelstring-Display label rendered in the table header.
isBoldbooleanfalseRenders values in the column using bold text.
isMutedbooleanfalseApplies muted text styling to all cells in the column.
align"left" | "center" | "right""left"Horizontal alignment applied to the header and column cells.

TablePrimitive

Property

Type

Default

Description

classNamestring-Additional classes applied to the table element.
childrenReactNode-Table content including header, body, footer, and rows.

TableHeaderPrimitive

Property

Type

Default

Description

childrenReactNode-Header rows rendered within the table head section.

TableBodyPrimitive

Property

Type

Default

Description

childrenReactNode-Table rows rendered within the table body section.

TableRowPrimitive

Property

Type

Default

Description

childrenReactNode-Cells rendered within the table row.

TableHeadPrimitive

Property

Type

Default

Description

childrenReactNode-Table column heading content.

TableCellPrimitive

Property

Type

Default

Description

childrenReactNode-Content rendered within a table cell.

TableFooterPrimitive

Property

Type

Default

Description

childrenReactNode-Content rendered within the table footer section.

TableCaptionPrimitive

Property

Type

Default

Description

childrenReactNode-Accessible caption describing the table contents.

Visual Reference

Example

Preview

Default

Name

Value

ProductGold Sheet
Centered Content

Status

Active
No Banding

Feature

Plain rows