Live demo
Demo source
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.
- Header row:
thcells withscope="col". Wrap a heading in a table header to make it sortable. - Body rows:
tdcells. Adddata-selectedto 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:
| Pattern | Use |
|---|---|
| Action | One or two controls for actions on that row. |
| Avatar | A person's image or initials. |
| Badge | A short category, priority or status. |
| Checkbox | Select a row for a later action. |
| Link | Open the record or a related destination. |
| Monospaced text | Identifiers, codes or numbers that benefit from consistent spacing. |
| Text and subtitle | A 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
captionthat says what it contains. - Align numbers to the right and use a monospaced font for identifiers.
- Keep row actions in the last column.