Table

This component presents data and components in a grid format. It cannot contain another Table component within itself.

Usage

1
import ForgeUI, { Table, Head, Row, Cell } from '@forge/ui';

Props

NameTypeRequiredDescription
TableHead | Array<Row>YesTop-level component of a table.
HeadArray<Cell>YesContainer of cells for the heading row of the table. A table can only contain one Head.
RowArray<Cell>YesContainer of cells for a row of the table.
CellForgeComponentYesCell can contain any value or component, except a Table component.

Example

A table app displaying issue keys and status.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import ForgeUI, { render, Macro, Table, Head, Cell, Text, Row } from '@forge/ui';

const issues = [
  {
    key: 'XEN-1',
    status: 'In Progress',
  },
  {
    key: 'XEN-2',
    status: 'To Do',
  },
];

const App = () => (
  <Table>
    <Head>
      <Cell>
        <Text content="Issue Key" />
      </Cell>
      <Cell>
        <Text content="Status" />
      </Cell>
    </Head>
    {issues.map(issue => (
      <Row>
        <Cell>
          <Text content={issue.key} />
        </Cell>
        <Cell>
          <Text content={issue.status} />
        </Cell>
      </Row>
    ))}
  </Table>
);

export const run = render(<Macro app={<App />} />);

Preview

Screenshot of the rendered table