Table
Render table with theme styles
Import
Source
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 data
prop to automatically generate table rows from array of React nodes.
data
prop accepts an object with the following properties:
head
– an array of React nodes (React.ReactNode[]
) to renderTable.Th
inTable.Thead
foot
– an array of React nodes (React.ReactNode[]
) to renderTable.Th
inTable.Tfoot
body
- an array of arrays of React nodes (React.ReactNode[][]
) to renderTable.Td
inTable.Tbody
caption
– 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 table header sticky. To customize top position of the header use stickyHeaderOffset
prop:
it is useful when you have a fixed header in your application. For example, 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 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 support tfoot and caption elements. Set captionSide
prop (top or bottom) to change 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 minWidth
prop which sets minimum width below which 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 |
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 |