Skip to content

Table

Display tabular data in row format, built with React Table. Some examples use the following variables for brevity:

const columns = [
  {
    Header: 'First Name',
    accessor: 'first'
  },
  {
    Header: 'Last Name',
    accessor: 'last'
  },
  {
    Header: 'Email',
    accessor: 'email'
  }
]

const data = [
  {
    first: 'John',
    last: 'Doe',
    email: 'john@doe.com'
  },
  {
    first: 'Dorothy',
    last: 'Boe',
    email: 'dorothy@boe.com'
  },
  {
    first: 'Baby',
    last: 'Moe',
    email: 'baby@moe.com'
  }
]

Always provide a caption. Columns and data must be memoized.

A basic table.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor
A table with placeholder rows.
First Name
Last Name
Email
Code Editor

Use the same number of placeholder rows used while loading to avoid layout shift.

An empty table.
First Name
Last Name
Email
No rows to display. Import a project?
Code Editor

Set the align property to change text alignment. Left by default.

A table with right and left aligned columns.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Pass a number to change the minimum width of the table. Disable with a falsy value.

A table with minimum with of 1000px.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Passing columnClassName applies the class to all headers and cells of the column.

A basic table with columnClassName applied to the second column.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Ensures column widths are stable, regardless of cell contents.

A table with fixed layout.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Manually set a column width.

A table with fixed column widths.
First Name
Last Name
Email
ratioqueencows
dockpizzaskite
haircutcatplantation
Code Editor

Columns are still required, fixed widths are respected.

A table without a table header.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Enabled per column, long cell values are automatically truncated. Requires fixed layout.

A table that truncates long cells.
Column One
Column Two
Column Three
Column Four
jobless-sock-potato-definesecret-tiger-jump-reproducetacit-iron-print-excitesqueamish-eyes-summer-worry
wellgroomed-version-reward-activatesparkling-key-safety-proofreadlatter-garden-smell-choosenebulous-outcome-ray-accuse
lacking-blow-percentage-slitfederal-route-theory-chokeabusive-attention-brush-opendraconian-person-election-admire
wellgroomed-step-attitude-introduceawake-acoustics-book-breathelying-silk-technology-thankjuvenile-man-donkey-step
hard-cherry-iron-winrabid-curtain-quiet-gazecultural-science-performance-diverttalented-insurance-pies-battle
Code Editor

Specify a number to change the offset from 0.

A table with a sticky header.
First Name
Last Name
Email
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
JohnDoejohn@doe.com
DorothyBoedorothy@boe.com
BabyMoebaby@moe.com
Code Editor

Hold shift to sort by multiple columns. Columns can disable sorting.

A table with sortable columns.
First Name
Last Name
Email
cuparmynewspaper
thingssuitloaf
traycloverneed
Code Editor

Sort function must be memoized. Sorts alphanumerically by default.

A table with sortable columns.
First Name
Last Name
Age
JohnDoe36
DorothyBoe45
BabyMoe2
Code Editor

Hold shift to toggle many rows.

A table with selectable rows.
First Name
Last Name
Email
schoolestablishmentclouds
cavedesireglue
grandfathermusicsister
LOAD MORE
Code Editor

Disable items in rowActions for disabled rows as needed.

A table with selectable and disabled rows.
First Name
Last Name
Email
JohnDoejohn@doe.com
inventionchairachieve
inspectormotionwar
reactionthrillheart
LOAD MORE
Code Editor

Filter rows that already displayed. This is not used for server-side search. Common filter function like useTextFilter are provided.

A table with a search filter.
First Name
Last Name
Email
divisionwishtrick
wirepetshelp
workcabinetpollution
Code Editor

Only specify the first property to render full width content.

A table with expandable rows.
Item
Count
Unit Price
Price
Preview Deployment Suffix1$100$100
Additional Items
More Details
Code Editor

Filters should be memoized, and are applied sequentially.

A table with a search filter and selectable rows.
Project
URL
Deployed
Blogvercel.com/blog23h ago
Homevercel.com7d ago
Design Systemvercel.com/design30m ago
Homevercel.com14d ago
Code Editor