Back to Components

Data

Table

Data-driven HTML table with sticky header, sortable columns, and striping options. For richer interactions use DataTable (later wave).

Examples

Sortable

The Selfish GeneDawkins360
Gödel, Escher, BachHofstadter777
Thinking, Fast and SlowKahneman499
The Code BookSingh432
<Table
  columns={[
    {key: 'title', label: 'Title', sortable: true},
    {key: 'author', label: 'Author', sortable: true},
    {key: 'pages', label: 'Pages', align: 'right', sortable: true},
  ]}
  rows={books}
  bind:sort
  striped
/>

Props

PropTypeDefaultDescription
columns{key, label, align?, width?, sortable?}[]Column definitions.
rowsRecord<string, unknown>[]Row data (looked up by column key).
sort{key, dir} | undefinedBindable sort state.
stripedbooleanfalseZebra rows.
hoverablebooleantrueHighlight on hover.
density'compact' | 'comfortable''comfortable'Cell padding tier.

Install

CLI

npx @a3tai/mittsu add table