Table
Render table with theme styles
Source
LLM docs
Docs
Package
Usage
Table data for all examples:
| Element position | Element name | Symbol | Atomic mass |
|---|---|---|---|
| 6 | Carbon | C | 12.011 |
| 7 | Nitrogen | N | 14.007 |
| 39 | Yttrium | Y | 88.906 |
| 56 | Barium | Ba | 137.33 |
| 58 | Cerium | Ce | 140.12 |
data prop
You can use the data prop to automatically generate table rows from an array of React nodes.
The data prop accepts an object with the following properties:
head– an array of React nodes (React.ReactNode[]) to renderTable.ThinTable.Theadfoot– an array of React nodes (React.ReactNode[]) to renderTable.ThinTable.Tfootbody- an array of arrays of React nodes (React.ReactNode[][]) to renderTable.TdinTable.Tbodycaption– a React node to renderTable.Caption
| Element position | Atomic mass | Symbol | Element name |
|---|---|---|---|
| 6 | 12.011 | C | Carbon |
| 7 | 14.007 | N | Nitrogen |
| 39 | 88.906 | Y | Yttrium |
| 56 | 137.33 | Ba | Barium |
| 58 | 140.12 | Ce | Cerium |
Sticky header
Set stickyHeader to make the table header sticky. To customize the top position of the header, use the stickyHeaderOffset prop:
it is useful when you have a fixed header in your application. For example, the Mantine documentation website has a fixed
header with 60px height:
| Element position | Element name | Symbol | Atomic mass |
|---|---|---|---|
| 6 | Carbon | C | 12.011 |
| 7 | Nitrogen | N | 14.007 |
| 39 | Yttrium | Y | 88.906 |
| 56 | Barium | Ba | 137.33 |
| 58 | Cerium | Ce | 140.12 |
Spacing
To control spacing, use the horizontalSpacing and verticalSpacing props. Both props support spacing from theme.spacing and any valid CSS value to set cell padding:
| Position | Name | Symbol |
|---|---|---|
| 6 | Carbon | C |
| 7 | Nitrogen | N |
| 39 | Yttrium | Y |
| 56 | Barium | Ba |
| 58 | Cerium | Ce |
Caption and tfoot
Table supports tfoot and caption elements. Set the captionSide prop (top or bottom) to change the caption position.
| Element position | Element name | Symbol | Atomic mass |
|---|---|---|---|
| 6 | Carbon | C | 12.011 |
| 7 | Nitrogen | N | 14.007 |
| 39 | Yttrium | Y | 88.906 |
| 56 | Barium | Ba | 137.33 |
| 58 | Cerium | Ce | 140.12 |
| Element position | Element name | Symbol | Atomic mass |
Striped and rows hover
| Element position | Element name | Symbol | Atomic mass |
|---|---|---|---|
| 6 | Carbon | C | 12.011 |
| 7 | Nitrogen | N | 14.007 |
| 39 | Yttrium | Y | 88.906 |
| 56 | Barium | Ba | 137.33 |
| 58 | Cerium | Ce | 140.12 |
Scroll container
To prevent viewport overflow, wrap Table with Table.ScrollContainer.
The component accepts a minWidth prop which sets the minimum width below which the table will be scrollable.
By default, Table.ScrollContainer uses ScrollArea, you can change it
to native scrollbars by setting type="native":
| Element position | Element name | Symbol | Atomic mass |
|---|---|---|---|
| 6 | Carbon | C | 12.011 |
| 7 | Nitrogen | N | 14.007 |
| 39 | Yttrium | Y | 88.906 |
| 56 | Barium | Ba | 137.33 |
| 58 | Cerium | Ce | 140.12 |
You can also set the maxHeight prop on Table.ScrollContainer to limit the table height:
Vertical variant
Set variant="vertical" to render the table with a vertical layout:
| Epic name | 7.x migration |
|---|---|
| Status | Open |
| Total issues | 135 |
| Total story points | 874 |
| Last updated at | September 26, 2024 17:41:26 |
Tabular numbers
Set the tabularNums prop to render numbers in tabular style. It sets
font-variant-numeric: tabular-nums which makes numbers have equal width.
This is useful when you have columns with numbers and you want them to be aligned:
| Product | Units sold |
|---|---|
| Apples | 2,214,411,234 |
| Oranges | 9,983,812,411 |
| Bananas | 1,234,567,890 |
| Pineapples | 9,948,810,000 |
| Pears | 9,933,771,111 |
Example: Table with row selection
| Element position | Element name | Symbol | Atomic mass | |
|---|---|---|---|---|
| 6 | Carbon | C | 12.011 | |
| 7 | Nitrogen | N | 14.007 | |
| 39 | Yttrium | Y | 88.906 | |
| 56 | Barium | Ba | 137.33 | |
| 58 | Cerium | Ce | 140.12 |