React Smart Table Component (DataTable) API
Smart Table (DataTable) API
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.
Explore the API reference for the React Smart Table component and discover how to effectively utilize its props for customization.
CSmartTable#
import { CSmartTable } from '@coreui/react-pro'// orimport CSmartTable from '@coreui/react-pro/src/components/smart-table/CSmartTable'
Property | Default | Type |
---|---|---|
activePage# | 1 | number |
Sets active page. If 'pagination' prop is enabled, activePage is set only initially. | ||
cleaner# | - | boolean |
When set, displays table cleaner above table, next to the table filter (or in place of table filter if | ||
clickableRows# | - | boolean |
Style table items as clickable. | ||
columnFilter# | - | boolean , ColumnFilter |
When set, displays additional filter row between table header and items, allowing filtering by specific column.
| ||
columnFilterValue# | - | ColumnFilterValue |
Value of table filter. To set pass object where keys are column names and values are filter strings e.g.: | ||
columns# | - | (string | Column)[] |
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. '_classes') In columns prop each array item represents one column. Item might be specified in two ways:
| ||
columnSorter# | - | boolean , Sorter |
Enables table sorting by column value. Sorting will be performed corectly only if values in column are of one type: string (case insensitive) or number. Sorter can be customized, by passing prop as object with additional options as keys. Available options:
| ||
elementCover#4.9.0+ | - | ReactNode |
ReactNode for passing custom CElementCover content. | ||
footer# | - | boolean , (string | FooterItem)[] |
If Example items: | ||
header# | true | boolean |
Set to false to remove table header. | ||
items#4.9.0+ | [] | Item[] |
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: | ||
itemsNumber# | - | number |
The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items. | ||
itemsPerPage# | 10 | number |
Number of items per site, when pagination is enabled. | ||
itemsPerPageLabel# | Items per page: | string |
Label for items per page selector. | ||
itemsPerPageOptions# | [5, 10, 20, 50] | number[] |
Items per page selector options. | ||
itemsPerPageSelect# | - | boolean , ItemsPerPageSelect |
Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values:
| ||
loading# | - | boolean |
When set, table will have loading style: loading spinner and reduced opacity. | ||
noItemsLabel# | No items found | ReactNode |
ReactNode or string for passing custom noItemsLabel texts. | ||
onActivePageChange# | - | (value: number) => void |
Page change callback. | ||
onColumnFilterChange# | - | (value: ColumnFilterValue) => void |
Column filter change callback. | ||
onFilteredItemsChange# | - | (items: Item[]) => void |
Filtered items change callback. | ||
onItemsPerPageChange# | - | (value: number) => void |
Pagination change callback. | ||
onRowClick# | - | (item: Item, index: number, columnName: string, event: boolean | MouseEvent<Element, MouseEvent>) => void |
Row click callback. | ||
onSelectAll#4.9.0+ | - | () => void |
Select all callback. | ||
onSelectedItemsChange# | - | (items: Item[]) => void |
Selected items change callback. | ||
onSorterChange# | - | (value: SorterValue | SorterValue[]) => void |
Sorter value change callback. | ||
onTableFilterChange# | - | (value?: string) => void |
Table filter change callback. | ||
pagination# | - | boolean , Pagination |
Enables default pagination. Set to true for default setup or pass an object with additional CPagination props. Default pagination will always have the computed number of pages that cannot be changed. The number of pages is generated based on the number of passed items and 'itemsPerPage' prop. If this restriction is an obstacle, you can make external CPagination instead. | ||
paginationProps# | - | CSmartPaginationProps |
Properties to | ||
scopedColumns# | - | ScopedColumns |
Scoped columns. | ||
selectable# | - | boolean |
Add checkboxes to make table rows selectable. | ||
selectAll#4.9.0+ | true | boolean , { external?: boolean; } |
Enables select all checkbox displayed in the header of the table. Can be customized, by passing prop as object with additional options as keys. Available options:
| ||
selected#4.9.0+ | - | Item[] |
Array of selected objects, where each object represents one item - row in table. Example item: | ||
sorterValue# | - | SorterValue , SorterValue[] |
State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. | ||
sortingIcon# | <CIcon width={18} icon={cilSwapVertical} key="csv" /> | ReactNode |
Sorter icon when items are unsorted. | ||
sortingIconAscending# | <CIcon width={18} icon={cilArrowTop} key="cat" /> | ReactNode |
Sorter icon when items are sorted ascending. | ||
sortingIconDescending# | <CIcon width={18} icon={cilArrowBottom} key="cab" /> | ReactNode |
Sorter icon when items are sorted descending. | ||
tableBodyProps# | - | CTableBodyProps |
Properties to | ||
tableFilter# | - | boolean , TableFilter |
When set, displays table filter above table, allowing filtering by specific column. Column filter can be customized, by passing prop as object with additional options as keys. Available options:
| ||
tableFilterLabel# | Filter: | string |
The element represents a caption for a component. | ||
tableFilterPlaceholder# | type string... | string |
Specifies a short hint that is visible in the search input. | ||
tableFilterValue# | - | string |
Value of table filter. | ||
tableFootProps# | - | CTableFootProps |
Properties to | ||
tableHeadProps# | - | CTableHeadProps |
Properties to | ||
tableProps# | - | CTableProps |
Properties to |