React playground

Nova v3.37.0

Preview

React

Table

nv-table

Nova styling and column resizing for your own semantic HTML table.

Parts

Live demo

Use nv-table to give a native HTML table Nova's look: header and body rows, hover and selected rows, and columns people can resize by dragging a header edge. You write the table, caption, th and td elements, and your application owns the data, sorting and selection. For built-in sorting, filtering and pagination, use a datatable.

Anatomy

A table with two callouts: 1 marks the header row with a checkbox, a help icon, sort arrows and an Action column; 2 marks the body row with a checkbox, monospaced text, text, a link and a more-actions button.

The header row and a body row, from the Datatable design.
  1. Header row: th cells with scope="col". Wrap a heading in a table header to make it sortable.
  2. Body rows: td cells. Add data-selected to a row to highlight it.

Look and feel

Spark and Ocean use the same table structure. Rows have default, hover and selected appearances; selection needs an actual selection state, not a hover colour used as a substitute.

Cell types

Headers can contain a column label or a select-all checkbox. Sorting controls cycle through ascending, descending and unsorted states; a help icon can add context to an unfamiliar heading.

The design provides seven body-cell patterns:

PatternUse
ActionOne or two controls for actions on that row.
AvatarA person's image or initials.
BadgeA short category, priority or status.
CheckboxSelect a row for a later action.
LinkOpen the record or a related destination.
Monospaced textIdentifiers, codes or numbers that benefit from consistent spacing.
Text and subtitleA main value with optional supporting detail.

Composing a table

Figma supplies column, row and cell partials. Its column partials contain ten editable body cells across nine preset variations; row partials have fourteen editable cells. Those are design-template capacities, not limits on rows or columns in code. Individual header and body cell partials offer the most control over a custom layout.

Custom cell content

In Figma, replace a body-cell slot with a local component. With nv-table, write the corresponding markup inside td: native links, nv-avatar, nv-tag for categories, nv-statusindicator for status, nv-fieldcheckbox or action buttons. There are no separate nv-table row or cell components and no built-in selection state. Use data-selected only when your application has selected that row.

Make custom controls keyboard operable and name selection checkboxes and icon-only actions. A checkbox in the header needs application logic to select rows; it is not a property of nv-tableheader.

Columns

Drag the right edge of a header cell to resize its column; add data-no-resize to a th to keep it fixed. data-sticky-left, data-sticky-right and data-sticky-top pin cells while scrolling.

Guidelines

  • Always give the table a caption that says what it contains.
  • Align numbers to the right and use a monospaced font for identifiers.
  • Keep row actions in the last column.
DoGive every table a caption that says what it contains.
Don'tAvoid tables without a caption.

Sources