Table
Overview
Tables
are used to display data related to a single subject, across one or more rows and columns.
When to use:
- When you have multiple objects of the same type you would like to display information about.
- When you need to rapidly add multiple items to a parent object.
Implementation
Sku | Name | Stock |
---|---|---|
SM13 | [Sample] Smith Journal 13 | 25 |
DPB | [Sample] Dustpan & Brush | 34 |
OFSUC | [Sample] Utility Caddy | 45 |
CLC | [Sample] Canvas Laundry Cart | 2 |
CGLD | [Sample] Laundry Detergent | 29 |
Edit the code below to see your changes live!
<Table columns={[ { header: 'Sku', hash: 'sku', tooltip: 'Header tooltip', render: ({ sku }) => sku, }, { header: 'Name', hash: 'name', render: ({ name }) => name }, { header: 'Stock', hash: 'stock', render: ({ stock }) => stock }, ]} items={[ { sku: 'SM13', name: '[Sample] Smith Journal 13', stock: 25 }, { sku: 'DPB', name: '[Sample] Dustpan & Brush', stock: 34 }, { sku: 'OFSUC', name: '[Sample] Utility Caddy', stock: 45 }, { sku: 'CLC', name: '[Sample] Canvas Laundry Cart', stock: 2 }, { sku: 'CGLD', name: '[Sample] Laundry Detergent', stock: 29 }, ]} stickyHeader />
Props
Prop name | Type | Default | Description |
---|---|---|---|
render * | React.ComponentType<Item> |
| Component used to render a column. |
header * | string |
| Header title. |
hideHeader | boolean | false | Hides individual header values in the header row. Header is only visually hidden to keep with accessibility best practices. |
align | left | center | right | left | Sets alignment for column. |
display | table-cell | none |
| Sets the CSS display property of a column. |
hash * | string |
| Unique identifier for column. |
isSortable | boolean | false | Defines if the column is sortable. |
verticalAlign | top | middle | top | Sets vertical alignment for column (td only). |
tooltip | string |
| Tooltip for the table column header. |
width | string | number |
| Sets column width. |
withPadding | boolean |
| Toggles padding on td elements. |
Props ending with * are required
Do's and Don'ts
Do |
---|
Keep column headers to one or two words. |
Add pagination controls if the user is likely to have 5+ rows of data to view. |
Don't |
---|
Don’t use this when you need to have complex interactions (e.g. filter) with the data in the Table . |
Don’t put unrelated objects in the same Table . |
If using Table s in cramped places like modals, avoid placing too many columns. |