Support CoreUI Development

CoreUI is an MIT-licensed open source project and is completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

You can support our Open Source software development in the following ways:

  • Buy the CoreUI PRO, and get access to PRO components, and dedicated support.
  • Became a sponsor, and get your logo on BACKERS.md/README.md files or each site of this documentation
  • Give us a star ⭐️ on Github.

React Table Component

Documentation and examples for opt-in styling of tables.

How to use React Table Component#

Due to the widespread use of <CTable> elements across third-party widgets like calendars and date pickers, CoreUI's react tables are opt-in. All table styles are not inherited in CoreUI, meaning any nested tables can be styled independent from the parent.

Using the most basic table CoreUI, here's how <CTable>-based tables look in CoreUI.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter

In version 4.3.0 we introduced a new way to create a table, similarly to our Smart Table component.

1const columns = [
2 {
3 key: 'id',
4 label: '#',
5 _props: { scope: 'col' },
6 },
7 {
8 key: 'class',
9 _props: { scope: 'col' },
10 },
11 {
12 key: 'heading_1',
13 label: 'Heading',
14 _props: { scope: 'col' },
15 },
16 {
17 key: 'heading_2',
18 label: 'Heading',
19 _props: { scope: 'col' },
20 },
21]
22const items = [
23 {
24 id: 1,
25 class: 'Mark',
26 heading_1: 'Otto',
27 heading_2: '@mdo',
28 _cellProps: { id: { scope: 'row' } },
29 },
30 {
31 id: 2,
32 class: 'Jacob',
33 heading_1: 'Thornton',
34 heading_2: '@fat',
35 _cellProps: { id: { scope: 'row' } },
36 },
37 {
38 id: 3,
39 class: 'Larry the Bird',
40 heading_2: '@twitter',
41 _cellProps: { id: { scope: 'row' }, class: { colSpan: 2 } },
42 },
43]
44return <CTable columns={columns} items={items} />

You can also put all table components together manually as hitherto.

1<CTable>
2 <CTableHead>
3 <CTableRow>
4 <CTableHeaderCell scope="col">#</CTableHeaderCell>
5 <CTableHeaderCell scope="col">Class</CTableHeaderCell>
6 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
7 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
8 </CTableRow>
9 </CTableHead>
10 <CTableBody>
11 <CTableRow>
12 <CTableHeaderCell scope="row">1</CTableHeaderCell>
13 <CTableDataCell>Mark</CTableDataCell>
14 <CTableDataCell>Otto</CTableDataCell>
15 <CTableDataCell>@mdo</CTableDataCell>
16 </CTableRow>
17 <CTableRow>
18 <CTableHeaderCell scope="row">2</CTableHeaderCell>
19 <CTableDataCell>Jacob</CTableDataCell>
20 <CTableDataCell>Thornton</CTableDataCell>
21 <CTableDataCell>@fat</CTableDataCell>
22 </CTableRow>
23 <CTableRow>
24 <CTableHeaderCell scope="row">3</CTableHeaderCell>
25 <CTableDataCell colSpan="2">Larry the Bird</CTableDataCell>
26 <CTableDataCell>@twitter</CTableDataCell>
27 </CTableRow>
28 </CTableBody>
29</CTable>

Both methods produce the same html code.

Variants#

Use contextual classes to color react tables, table rows or individual cells.

ClassHeadingHeading
DefaultCellCell
PrimaryCellCell
SecondaryCellCell
SuccessCellCell
DangerCellCell
WarningCellCell
InfoCellCell
LightCellCell
DarkCellCell
1<CTable>
2 <CTableHead>
3 <CTableRow>
4 <CTableHeaderCell scope="col">Class</CTableHeaderCell>
5 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
6 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
7 </CTableRow>
8 </CTableHead>
9 <CTableBody>
10 <CTableRow>
11 <CTableHeaderCell scope="row">Default</CTableHeaderCell>
12 <CTableDataCell>Cell</CTableDataCell>
13 <CTableDataCell>Cell</CTableDataCell>
14 </CTableRow>
15 <CTableRow color="primary">
16 <CTableHeaderCell scope="row">Primary</CTableHeaderCell>
17 <CTableDataCell>Cell</CTableDataCell>
18 <CTableDataCell>Cell</CTableDataCell>
19 </CTableRow>
20 <CTableRow color="secondary">
21 <CTableHeaderCell scope="row">Secondary</CTableHeaderCell>
22 <CTableDataCell>Cell</CTableDataCell>
23 <CTableDataCell>Cell</CTableDataCell>
24 </CTableRow>
25 <CTableRow color="success">
26 <CTableHeaderCell scope="row">Success</CTableHeaderCell>
27 <CTableDataCell>Cell</CTableDataCell>
28 <CTableDataCell>Cell</CTableDataCell>
29 </CTableRow>
30 <CTableRow color="danger">
31 <CTableHeaderCell scope="row">Danger</CTableHeaderCell>
32 <CTableDataCell>Cell</CTableDataCell>
33 <CTableDataCell>Cell</CTableDataCell>
34 </CTableRow>
35 <CTableRow color="warning">
36 <CTableHeaderCell scope="row">Warning</CTableHeaderCell>
37 <CTableDataCell>Cell</CTableDataCell>
38 <CTableDataCell>Cell</CTableDataCell>
39 </CTableRow>
40 <CTableRow color="info">
41 <CTableHeaderCell scope="row">Info</CTableHeaderCell>
42 <CTableDataCell>Cell</CTableDataCell>
43 <CTableDataCell>Cell</CTableDataCell>
44 </CTableRow>
45 <CTableRow color="light">
46 <CTableHeaderCell scope="row">Light</CTableHeaderCell>
47 <CTableDataCell>Cell</CTableDataCell>
48 <CTableDataCell>Cell</CTableDataCell>
49 </CTableRow>
50 <CTableRow color="dark">
51 <CTableHeaderCell scope="row">Dark</CTableHeaderCell>
52 <CTableDataCell>Cell</CTableDataCell>
53 <CTableDataCell>Cell</CTableDataCell>
54 </CTableRow>
55 </CTableBody>
56</CTable>

Since version 4.3.0 also this way.

1const columns = [
2 { key: 'class', _props: { scope: 'col' } },
3 { key: 'heading_1', label: 'Heading', _props: { scope: 'col' } },
4 { key: 'heading_2', label: 'Heading', _props: { scope: 'col' } },
5]
6const items = [
7 {
8 class: 'Default',
9 heading_1: 'Cell',
10 heading_2: 'Cell',
11 _cellProps: { class: { scope: 'row' } },
12 },
13 {
14 class: 'Primary',
15 heading_1: 'Cell',
16 heading_2: 'Cell',
17 _cellProps: { class: { scope: 'row' } },
18 _props: { color: 'primary' },
19 },
20 {
21 class: 'Secondary',
22 heading_1: 'Cell',
23 heading_2: 'Cell',
24 _cellProps: { class: { scope: 'row' } },
25 _props: { color: 'secondary' },
26 },
27 {
28 class: 'Success',
29 heading_1: 'Cell',
30 heading_2: 'Cell',
31 _cellProps: { class: { scope: 'row' } },
32 _props: { color: 'success' },
33 },
34 {
35 class: 'Danger',
36 heading_1: 'Cell',
37 heading_2: 'Cell',
38 _cellProps: { class: { scope: 'row' } },
39 _props: { color: 'danger' },
40 },
41 {
42 class: 'Warning',
43 heading_1: 'Cell',
44 heading_2: 'Cell',
45 _cellProps: { class: { scope: 'row' } },
46 _props: { color: 'warning' },
47 },
48 {
49 class: 'Info',
50 heading_1: 'Cell',
51 heading_2: 'Cell',
52 _cellProps: { class: { scope: 'row' } },
53 _props: { color: 'info' },
54 },
55 {
56 class: 'Light',
57 heading_1: 'Cell',
58 heading_2: 'Cell',
59 _cellProps: { class: { scope: 'row' } },
60 _props: { color: 'light' },
61 },
62 {
63 class: 'Dark',
64 heading_1: 'Cell',
65 heading_2: 'Cell',
66 _cellProps: { class: { scope: 'row' } },
67 _props: { color: 'dark' },
68 },
69]
70return <CTable columns={columns} items={items} />

Accented tables#

Striped rows#

Use striped property to add zebra-striping to any react table row within the <CTableBody>.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable striped>
2 ...
3</CTable>

Striped columns#

Use stripedColumns boolean property to add zebra-striping to any table column.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable stripedColumns>
2 ...
3</CTable>

These classes can also be added to react table variants:

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="dark" striped>
2 ...
3</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="dark" stripedColumns>
2 ...
3</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="success" striped>
2 ...
3</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="success" stripedColumns>
2 ...
3</CTable>

Hoverable rows#

Use hover property to enable a hover state on react table rows within a <CTableBody>.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable hover>
2 ...
3</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="dark" hover>
2 ...
3</CTable>

These hoverable rows can also be combined with the striped variant:

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable striped hover>
2 ...
3</CTable>

Active tables#

Highlight a table row or cell by adding a active property.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter

As mentioned before since version 4.3.0 we have two ways to generate tables, also with custom properties for rows, and cells.

1const columns = [
2 {
3 key: 'id',
4 label: '#',
5 _props: { scope: 'col' },
6 },
7 {
8 key: 'class',
9 _props: { scope: 'col' },
10 },
11 {
12 key: 'heading_1',
13 label: 'Heading',
14 _props: { scope: 'col' },
15 },
16 {
17 key: 'heading_2',
18 label: 'Heading',
19 _props: { scope: 'col' },
20 },
21]
22const items = [
23 {
24 id: 1,
25 class: 'Mark',
26 heading_1: 'Otto',
27 heading_2: '@mdo',
28 _props: { active: true },
29 _cellProps: { id: { scope: 'row' } },
30 },
31 {
32 id: 2,
33 class: 'Jacob',
34 heading_1: 'Thornton',
35 heading_2: '@fat',
36 _cellProps: { id: { scope: 'row' } },
37 },
38 {
39 id: 3,
40 class: 'Larry the Bird',
41 heading_2: '@twitter',
42 _cellProps: { id: { scope: 'row' }, class: { active: true, colSpan: 2 } },
43 },
44]
45return <CTable columns={columns} items={items} />
1<CTable>
2 <CTableHead>
3 <CTableRow>
4 <CTableHeaderCell scope="col">#</CTableHeaderCell>
5 <CTableHeaderCell scope="col">Class</CTableHeaderCell>
6 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
7 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
8 </CTableRow>
9 </CTableHead>
10 <CTableBody>
11 <CTableRow active>
12 <CTableHeaderCell scope="row">1</CTableHeaderCell>
13 <CTableDataCell>Mark</CTableDataCell>
14 <CTableDataCell>Otto</CTableDataCell>
15 <CTableDataCell>@mdo</CTableDataCell>
16 </CTableRow>
17 <CTableRow>
18 <CTableHeaderCell scope="row">2</CTableHeaderCell>
19 <CTableDataCell>Jacob</CTableDataCell>
20 <CTableDataCell>Thornton</CTableDataCell>
21 <CTableDataCell>@fat</CTableDataCell>
22 </CTableRow>
23 <CTableRow>
24 <CTableHeaderCell scope="row">3</CTableHeaderCell>
25 <CTableDataCell colSpan="2" active>
26 Larry the Bird
27 </CTableDataCell>
28 <CTableDataCell>@twitter</CTableDataCell>
29 </CTableRow>
30 </CTableBody>
31</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1const columns = [
2 {
3 key: 'id',
4 label: '#',
5 _props: { scope: 'col' },
6 },
7 {
8 key: 'class',
9 _props: { scope: 'col' },
10 },
11 {
12 key: 'heading_1',
13 label: 'Heading',
14 _props: { scope: 'col' },
15 },
16 {
17 key: 'heading_2',
18 label: 'Heading',
19 _props: { scope: 'col' },
20 },
21]
22const items = [
23 {
24 id: 1,
25 class: 'Mark',
26 heading_1: 'Otto',
27 heading_2: '@mdo',
28 _props: { active: true },
29 _cellProps: { id: { scope: 'row' } },
30 },
31 {
32 id: 2,
33 class: 'Jacob',
34 heading_1: 'Thornton',
35 heading_2: '@fat',
36 _cellProps: { id: { scope: 'row' } },
37 },
38 {
39 id: 3,
40 class: 'Larry the Bird',
41 heading_2: '@twitter',
42 _cellProps: { id: { scope: 'row' }, class: { active: true, colSpan: 2 } },
43 },
44]
45return <CTable color="dark" columns={columns} items={items} />

Table borders#

Bordered tables#

Add bordered property for borders on all sides of the table and cells.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable bordered>
2 ...
3</CTable>

Border color utilities can be added to change colors:

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable bordered borderColor="primary">
2 ...
3</CTable>

Tables without borders#

Add borderless property for a react table without borders.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable borderless>
2 ...
3</CTable>
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable color="dark" borderless>
2 ...
3</CTable>

Small tables#

Add small property to make any <CTable> more compact by cutting all cell padding in half.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable small>
2 ...
3</CTable>

Vertical alignment#

Table cells of <CTableHead> are always vertical aligned to the bottom. Table cells in <CTableBody> inherit their alignment from <CTable> and are aligned to the the top by default. Use the align property to re-align where needed.

Heading 1Heading 2Heading 3Heading 4
This cell inherits vertical-align: middle; from the tableThis cell inherits vertical-align: middle; from the tableThis cell inherits vertical-align: middle; from the tableThis here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.
This cell inherits vertical-align: bottom; from the table rowThis cell inherits vertical-align: bottom; from the table rowThis cell inherits vertical-align: bottom; from the table rowThis here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.
This cell inherits vertical-align: middle; from the tableThis cell inherits vertical-align: middle; from the tableThis cell is aligned to the top.This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.

In version 4.3.0 we introduced a new way to create a table, similarly to our Smart Table component.

1const columns = [
2 {
3 key: 'heading_1',
4 _props: { className: 'w-25', scope: 'col' },
5 },
6 {
7 key: 'heading_2',
8 _props: { className: 'w-25', scope: 'col' },
9 },
10 {
11 key: 'heading_3',
12 _props: { className: 'w-25', scope: 'col' },
13 },
14 {
15 key: 'heading_4',
16 _props: { className: 'w-25', scope: 'col' },
17 },
18]
19const items = [
20 {
21 heading_1: <>This cell inherits <code>vertical-align: middle;</code> from the table</>,
22 heading_2: <>This cell inherits <code>vertical-align: middle;</code> from the table</>,
23 heading_3: <>This cell inherits <code>vertical-align: middle;</code> from the table</>,
24 heading_4: 'This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.',
25 },
26 {
27 heading_1: <>This cell inherits <code>vertical-align: bottom;</code> from the table row</>,
28 heading_2: <>This cell inherits <code>vertical-align: bottom;</code> from the table row</>,
29 heading_3: <>This cell inherits <code>vertical-align: bottom;</code> from the table row</>,
30 heading_4: 'This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.',
31 _props: { align: 'bottom' }
32 },
33 {
34 heading_1: <>This cell inherits <code>vertical-align: middle;</code> from the table</>,
35 heading_2: <>This cell inherits <code>vertical-align: middle;</code> from the table</>,
36 heading_3: 'This cell is aligned to the top.',
37 heading_4: 'This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.',
38 _cellProps: { heading_3: { align: 'top' }},
39 },
40]
41return <CTable align="middle" columns={columns} items={items} />

You can also put all table components together manually as hitherto.

1<CTable align="middle" responsive>
2 <CTableHead>
3 <CTableRow>
4 <CTableHeaderCell scope="col" className="w-25">
5 Heading 1
6 </CTableHeaderCell>
7 <CTableHeaderCell scope="col" className="w-25">
8 Heading 2
9 </CTableHeaderCell>
10 <CTableHeaderCell scope="col" className="w-25">
11 Heading 3
12 </CTableHeaderCell>
13 <CTableHeaderCell scope="col" className="w-25">
14 Heading 4
15 </CTableHeaderCell>
16 </CTableRow>
17 </CTableHead>
18 <CTableBody>
19 <CTableRow>
20 <CTableDataCell>
21 This cell inherits <code>vertical-align: middle;</code> from the table
22 </CTableDataCell>
23 <CTableDataCell>
24 This cell inherits <code>vertical-align: middle;</code> from the table
25 </CTableDataCell>
26 <CTableDataCell>
27 This cell inherits <code>vertical-align: middle;</code> from the table
28 </CTableDataCell>
29 <CTableDataCell>
30 This here is some placeholder text, intended to take up quite a bit of vertical space, to
31 demonstrate how the vertical alignment works in the preceding cells.
32 </CTableDataCell>
33 </CTableRow>
34 <CTableRow align="bottom">
35 <CTableDataCell>
36 This cell inherits <code>vertical-align: bottom;</code> from the table row
37 </CTableDataCell>
38 <CTableDataCell>
39 This cell inherits <code>vertical-align: bottom;</code> from the table row
40 </CTableDataCell>
41 <CTableDataCell>
42 This cell inherits <code>vertical-align: bottom;</code> from the table row
43 </CTableDataCell>
44 <CTableDataCell>
45 This here is some placeholder text, intended to take up quite a bit of vertical space, to
46 demonstrate how the vertical alignment works in the preceding cells.
47 </CTableDataCell>
48 </CTableRow>
49 <CTableRow>
50 <CTableDataCell>
51 This cell inherits <code>vertical-align: middle;</code> from the table
52 </CTableDataCell>
53 <CTableDataCell>
54 This cell inherits <code>vertical-align: middle;</code> from the table
55 </CTableDataCell>
56 <CTableDataCell align="top">This cell is aligned to the top.</CTableDataCell>
57 <CTableDataCell>
58 This here is some placeholder text, intended to take up quite a bit of vertical space, to
59 demonstrate how the vertical alignment works in the preceding cells.
60 </CTableDataCell>
61 </CTableRow>
62 </CTableBody>
63</CTable>

Nesting#

Border styles, active styles, and react table component variants are not inherited by nested tables.

#ClassHeadingHeading
1MarkOtto@mdo
HeaderHeaderHeader
AFirstLast
BFirstLast
CFirstLast
3Larry the Bird@twitter
1<CTable striped>
2 <CTableHead>
3 <CTableRow>
4 <CTableHeaderCell scope="col">#</CTableHeaderCell>
5 <CTableHeaderCell scope="col">Class</CTableHeaderCell>
6 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
7 <CTableHeaderCell scope="col">Heading</CTableHeaderCell>
8 </CTableRow>
9 </CTableHead>
10 <CTableBody>
11 <CTableRow>
12 <CTableHeaderCell scope="row">1</CTableHeaderCell>
13 <CTableDataCell>Mark</CTableDataCell>
14 <CTableDataCell>Otto</CTableDataCell>
15 <CTableDataCell>@mdo</CTableDataCell>
16 </CTableRow>
17 <CTableRow>
18 <CTableHeaderCell colSpan="4">
19 <CTable>
20 <CTableHead>
21 <CTableRow>
22 <CTableHeaderCell scope="col">Header</CTableHeaderCell>
23 <CTableHeaderCell scope="col">Header</CTableHeaderCell>
24 <CTableHeaderCell scope="col">Header</CTableHeaderCell>
25 </CTableRow>
26 </CTableHead>
27 <CTableBody>
28 <CTableRow>
29 <CTableHeaderCell scope="row">A</CTableHeaderCell>
30 <CTableDataCell>First</CTableDataCell>
31 <CTableDataCell>Last</CTableDataCell>
32 </CTableRow>
33 <CTableRow>
34 <CTableHeaderCell scope="row">B</CTableHeaderCell>
35 <CTableDataCell>First</CTableDataCell>
36 <CTableDataCell>Last</CTableDataCell>
37 </CTableRow>
38 <CTableRow>
39 <CTableHeaderCell scope="row">C</CTableHeaderCell>
40 <CTableDataCell>First</CTableDataCell>
41 <CTableDataCell>Last</CTableDataCell>
42 </CTableRow>
43 </CTableBody>
44 </CTable>
45 </CTableHeaderCell>
46 </CTableRow>
47 <CTableRow>
48 <CTableHeaderCell scope="row">3</CTableHeaderCell>
49 <CTableDataCell colSpan="2">Larry the Bird</CTableDataCell>
50 <CTableDataCell>@twitter</CTableDataCell>
51 </CTableRow>
52 </CTableBody>
53</CTable>

Anatomy#

Table head#

Similar to tables and dark tables, use the modifier prop color="light" or color="dark" to make <CTableHead>s appear light or dark gray.

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable>
2 <CTableHead color="light">
3 ...
4 </CTableHead>
5 <CTableBody>
6 ...
7 </CTableBody>
8</CTable>

If you generate a table using the new method incorporated in version 4.3.0, you have to use tableHeadProps property to pass properties to the table header component.

1const columns = [...]
2const items = [...]
3
4return <CTable columns={columns} items={items} tableHeadProps={{ color: 'light' }} />
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable>
2 <CTableHead color="dark">
3 ...
4 </CTableHead>
5 <CTableBody>
6 ...
7 </CTableBody>
8</CTable>

Starting from version 4.3.0 also this way.

1const columns = [...]
2const items = [...]
3
4return <CTable columns={columns} items={items} tableHeadProps={{ color: 'light' }} />

Table foot#

#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
FooterFooterFooterFooter
1<CTable>
2 <CTableHead color="light">
3 ...
4 </CTableHead>
5 <CTableBody>
6 ...
7 <CTableHead>
8 <CTableRow>
9 <CTableDataCell>Footer</CTableDataCell>
10 <CTableDataCell>Footer</CTableDataCell>
11 <CTableDataCell>Footer</CTableDataCell>
12 <CTableDataCell>Footer</CTableDataCell>
13 </CTableRow>
14 </CTableHead>
15</CTable>

Starting from version 4.3.0 also this way.

1const columns = [...]
2const footer = [
3 'Footer',
4 'Footer',
5 'Footer',
6 'Footer',
7]
8const items = [...]
9
10return <CTable columns={columns} footer={footer} items={items} tableHeadProps={{ color: 'light' }}/>

Captions#

A <CTableCaption> functions like a heading for a table. It helps users with screen readers to find a table and understand what it's about and decide if they want to read it.

List of users
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable>
2 <CTableCaption>List of users</CTableCaption>
3 <CTableHead>
4 ...
5 </CTableHead>
6 <CTableBody>
7 ...
8 </CTableBody>
9</CTable>

Starting from version 4.3.0 also this way.

1const columns = [...]
2const items = [...]
3
4return <CTable caption="List of users" columns={columns} items={items} />

You can also put the <CTableCaption> on the top of the table with caption="top".

List of users
#ClassHeadingHeading
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
1<CTable caption="top">
2 <CTableCaption>List of users</CTableCaption>
3 <CTableHead>
4 ...
5 </CTableHead>
6 <CTableBody>
7 ...
8 </CTableBody>
9</CTable>

Since version 4.3.0 also this way.

1const columns = [...]
2const items = [...]
3
4return <CTable captionTop="List of users" columns={columns} items={items} />

Responsive tables#

Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by adding a responsive property. Or, pick a maximum breakpoint with which to have a responsive table up to by using responsive="{-sm|-md|-lg|-xl|-xxl}".

#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive>
2 ...
3</CTable>
#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive="sm">
2 ...
3</CTable>
#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive="md">
2 ...
3</CTable>
#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive="lg">
2 ...
3</CTable>
#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive="xl">
2 ...
3</CTable>
#HeadingHeadingHeadingHeadingHeadingHeadingHeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
1<CTable responsive="xxl">
2 ...
3</CTable>

API#

CTable#

1import { CTable } from '@coreui/react'
2// or
3import CTable from '@coreui/react-pro/src/components/table/CTable'
PropertyDescriptionTypeDefault
alignSet the vertical aligment.'bottom' | 'middle' | 'top'-
borderColorSets the border color of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-
borderedAdd borders on all sides of the table and cells.boolean-
borderlessRemove borders on all sides of the table and cells.boolean-
captionPut the caption on the top if you set caption="top" of the table or set the text of the table caption.string-
captionTop
4.3.0+
Set the text of the table caption and the caption on the top of the table.string-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-
columns
4.3.0+
Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_props')

In columns prop each array item represents one column. Item might be specified in two ways:
String: each item define column name equal to item value.
Object: item is object with following keys available as column configuration:
- key (required)(String) - define column name equal to item key.
- label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word.
- _props (Object) - adds classes to all cels in column, ex. _props: { scope: 'col', className: 'custom-class' },
- _style (Object) - adds styles to the column header (useful for defining widths)
(string | Column)[]-
footer
4.3.0+
Array of objects or strings, where each element represents one cell in the table footer.

Example items:
['FooterCell', 'FooterCell', 'FooterCell']
or
[{ label: 'FooterCell', _props: { color: 'success' }, ...]
FooterItem[]-
hoverEnable a hover state on table rows within a <CTableBody>.boolean-
items
4.3.0+
Array of objects, where each object represents one item - row in table. Additionally, you can add style classes to each row by passing them by '_props' key and to single cell by '_cellProps'.

Example item:
{ name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}
Item[][]
responsiveMake any table responsive across all viewports or pick a maximum breakpoint with which to have a responsive table up to.boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'-
smallMake table more compact by cutting all cell padding in half.boolean-
stripedAdd zebra-striping to any table row within the <CTableBody>.boolean-
stripedColumns
4.3.0+
Add zebra-striping to any table column.boolean-
tableFootProps
4.3.0+
Properties that will be passed to the table footer component.CTableFootProps-
tableHeadProps
4.3.0+
Properties that will be passed to the table head component.CTableHeadProps-

CTableBody#

1import { CTableBody } from '@coreui/react'
2// or
3import CTableBody from '@coreui/react-pro/src/components/table/CTableBody'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-

CTableDataCell#

1import { CTableDataCell } from '@coreui/react'
2// or
3import CTableDataCell from '@coreui/react-pro/src/components/table/CTableDataCell'
PropertyDescriptionTypeDefault
activeHighlight a table row or cell.boolean-
alignSet the vertical aligment.'bottom' | 'middle' | 'top'-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-

CTableFoot#

1import { CTableFoot } from '@coreui/react'
2// or
3import CTableFoot from '@coreui/react-pro/src/components/table/CTableFoot'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-

CTableHead#

1import { CTableHead } from '@coreui/react'
2// or
3import CTableHead from '@coreui/react-pro/src/components/table/CTableHead'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-

CTableHeaderCell#

1import { CTableHeaderCell } from '@coreui/react'
2// or
3import CTableHeaderCell from '@coreui/react-pro/src/components/table/CTableHeaderCell'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-

CTableRow#

1import { CTableRow } from '@coreui/react'
2// or
3import CTableRow from '@coreui/react-pro/src/components/table/CTableRow'
PropertyDescriptionTypeDefault
activeHighlight a table row or cell..boolean-
alignSet the vertical aligment.'bottom' | 'middle' | 'top'-
classNameA string of all className you want applied to the component.string-
colorSets the color context of the component to one of CoreUI’s themed colors.'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string-