Table

A native table that scrolls sideways on narrow screens.

Usage

tsx
<Table>
  <Table.Head>
    <Table.Row>
      <Table.HeadCell>prop</Table.HeadCell>
      <Table.HeadCell>type</Table.HeadCell>
      <Table.HeadCell>default</Table.HeadCell>
    </Table.Row>
  </Table.Head>
  <Table.Body>
    <Table.Row>
      <Table.Cell>active</Table.Cell>
      <Table.Cell>boolean</Table.Cell>
      <Table.Cell>false</Table.Cell>
    </Table.Row>
    <Table.Row>
      <Table.Cell>as</Table.Cell>
      <Table.Cell>ElementType</Table.Cell>
      <Table.Cell>"div"</Table.Cell>
    </Table.Row>
  </Table.Body>
</Table>
proptypedefault
activebooleanfalse
asElementType"div"

Rows from data

tsx
<Table.Body>
  <List
    array={rows}
    itemExtractor={({ row }) => (
      <Table.Row key={row.id}>
        <Table.Cell>{row.name}</Table.Cell>
      </Table.Row>
    )}
  />
</Table.Body>

Long text

Cells don't wrap. Allow it on the columns that hold sentences.

tsx
<Table.Cell className="whitespace-normal">{row.description}</Table.Cell>

Reference

Every part takes the same props.

proptypedefault
as?ElementType—the element or component to render; see the parts below
className?string—added after the component's own class: what you set wins
…restprops of as—typed against the chosen element
part
Tabletable, inside a bordered div that scrolls sideways
Table.Headthead
Table.Bodytbody
Table.Rowtr
Table.HeadCellth
Table.Celltd