Table
Table shows rows of data in columns. Use it for records users scan and compare, such as invoices. Sorting, selection and pagination logic stay in your app.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
With footer
Add a TableFooter row for totals, on a muted fill.
| Invoice | Status | Amount |
|---|---|---|
| INV001 | Paid | $250.00 |
| INV002 | Pending | $150.00 |
| INV003 | Unpaid | $350.00 |
| INV004 | Paid | $450.00 |
| INV005 | Paid | $550.00 |
| Total | $1,750.00 | |
Selectable rows
Put a Checkbox in each row with TableSelectionHead and TableSelectionCell.
| Invoice | Status | Amount | |
|---|---|---|---|
| INV001 | Paid | $250.00 | |
| INV002 | Pending | $150.00 | |
| INV003 | Unpaid | $350.00 | |
| INV004 | Paid | $450.00 | |
| INV005 | Paid | $550.00 |
This example also needs: Checkbox.
With actions
Add a trailing column of row actions with text buttons.
| Invoice | Status | Actions |
|---|---|---|
| INV001 | Paid | |
| INV002 | Pending | |
| INV003 | Unpaid |
This example also needs: Button.
Striped
Set striped to tint every other row, with hover and selection on top.
| Invoice | Status | Amount |
|---|---|---|
| INV001 | Paid | $250.00 |
| INV002 | Pending | $150.00 |
| INV003 | Unpaid | $350.00 |
| INV004 | Paid | $450.00 |
Sticky header
Set stickyHeader and a max height so the header stays visible while rows scroll.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Credit Card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
Sortable header
Put a button in a TableHead and set aria-sort from your sort state.
| Invoice | |
|---|---|
| INV002 | $150.00 |
| INV001 | $250.00 |
| INV003 | $350.00 |
| INV004 | $450.00 |
| INV005 | $550.00 |
This example also needs:
Props
Table
| Prop | Type | Default | Description |
|---|---|---|---|
containerClassName | string | No default documented | Classes for the scroll container, such as a max height. |
density | "comfortable" | "compact" | "comfortable" | Row height.
|
stickyHeader | boolean | false | Keeps the header row in view while the body scrolls. Set a max height with |
striped | boolean | false | Tints every other body row. Hover and selection colors win over the stripe. |
variant | "default" | "grid" | "borderless" | "default" | Lines inside the table.
|
TableBody
TableBody adds no props of its own; it accepts the props of the element or primitive it wraps.
TableCaption
TableCaption adds no props of its own; it accepts the props of the element or primitive it wraps.
TableCell
TableCell adds no props of its own; it accepts the props of the element or primitive it wraps.
TableFooter
TableFooter adds no props of its own; it accepts the props of the element or primitive it wraps.
TableHead
TableHead adds no props of its own; it accepts the props of the element or primitive it wraps.
TableHeader
TableHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
TableRow
TableRow adds no props of its own; it accepts the props of the element or primitive it wraps.
TableRowHeader
TableRowHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
TableSelectionCell
TableSelectionCell adds no props of its own; it accepts the props of the element or primitive it wraps.
TableSelectionHead
TableSelectionHead adds no props of its own; it accepts the props of the element or primitive it wraps.
Table shows rows of data in columns. Use it for records users scan and compare, such as invoices. Sorting, selection and pagination logic stay in your app.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/table/Table.vue components/table/TableBody.vue components/table/TableCaption.vue components/table/TableCell.vue components/table/TableFooter.vue components/table/TableHead.vue components/table/TableHeader.vue components/table/TableRow.vue components/table/TableRowHeader.vue components/table/TableSelectionCell.vue components/table/TableSelectionHead.vue components/table/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
With footer
Add a TableFooter row for totals, on a muted fill.
Selectable rows
Put a Checkbox in each row with TableSelectionHead and TableSelectionCell.
This example also needs: Checkbox.
With actions
Add a trailing column of row actions with text buttons.
This example also needs: Button.
Striped
Set striped to tint every other row, with hover and selection on top.
Sticky header
Set sticky-header and a max height so the header stays visible while rows scroll.
Sortable header
Put a button in a TableHead and set aria-sort from your sort state.
This example also needs:
Props
Table
| Prop | Type | Default | Description |
|---|---|---|---|
containerClassName | string | No default documented | Classes for the scroll container, such as a max height. |
density | "comfortable" | "compact" | "comfortable" | Row height.
|
stickyHeader | boolean | false | Keeps the header row in view while the body scrolls. Set a max height with |
striped | boolean | false | Tints every other body row. Hover and selection colors win over the stripe. |
variant | "default" | "borderless" | "grid" | "default" | Lines inside the table.
|
TableBody
TableBody adds no props of its own; it accepts the props of the element or primitive it wraps.
TableCaption
TableCaption adds no props of its own; it accepts the props of the element or primitive it wraps.
TableCell
TableCell adds no props of its own; it accepts the props of the element or primitive it wraps.
TableFooter
TableFooter adds no props of its own; it accepts the props of the element or primitive it wraps.
TableHead
TableHead adds no props of its own; it accepts the props of the element or primitive it wraps.
TableHeader
TableHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
TableRow
TableRow adds no props of its own; it accepts the props of the element or primitive it wraps.
TableRowHeader
TableRowHeader adds no props of its own; it accepts the props of the element or primitive it wraps.
TableSelectionCell
TableSelectionCell adds no props of its own; it accepts the props of the element or primitive it wraps.
TableSelectionHead
TableSelectionHead adds no props of its own; it accepts the props of the element or primitive it wraps.