Skip to content

DataTable

Stable

The numbers behind a chart, in a plain table with digits lined up.

Also known as table, data grid, grid table

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Wait times by shop

Wait times by shop, last 7 days
ShopTypical (min)Slowest (min)Orders
North shop287748,200
East shop246631,450
West shop184112,030

Number columns line up on the right. Values are already formatted.

When to use it

The numbers behind a chart, in a plain table. Numbers line up on the right with equal-width digits, so a column can be compared at a glance.

Made of: Caption · Column headings (sortable) · Row names · Number cells · Up or down marker · Scrolling area

Use it for

  • The table view of a chart, inside ChartFrame.
  • A small set of numbers that people need to read and compare exactly.
  • Giving every value that a chart shows only in a pop-up a place to be read.
  • A watchlist, a positions list or any list of numbers people sort and scan: turn on sortable headings, dense rows and the up or down marker.

Not for

  • Laying out a page or a form.
  • A side-by-side comparison of products or plans: use ComparisonTable.
  • One headline number: use StatTile.

Do and avoid

Open invoices
ClientAmount ($)
Lee Studio1,240.00
Park Cafe86.50
Ruiz & Co312.00

Do. Names on the left, amounts on the right, easy to compare.
Open invoices
ClientAmount ($)
Lee Studio1,240.00
Park Cafe86.50
Ruiz & Co312.00

Avoid. Names pushed to the right are slow to scan and read.

Do

  • Put the unit in each number column heading.
  • Use commas in big numbers and the same decimals down a column.
  • Include every number the chart shows, even ones that only appear in a pop-up.
  • Mark missing values with words such as "No data".

Avoid

  • Don't line text up on the right.
  • Don't merge cells or stack headings. Keep one row of headings.
  • Don't use it to lay out a page. It is for data.

On a phone

  • By default the table keeps its columns and scrolls sideways inside its own box, so the page itself never scrolls sideways.
  • Set responsive="stack" and a narrow container turns each row into a card with the column name before each value, so nothing scrolls.
  • Sort buttons in the header and the first-column row button are 44px tall on touch screens.
  • Tapping anywhere on a row calls onRowClick, so there is no hover state to rely on.

Seen in products

  • The UK Analysis Function charts checklist asks for a text alternative that can be a data table, and puts y-axis values right-aligned with commas as thousands separators.
  • Highcharts' accessibility module offers a data-table view of the chart.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started