Skip to Content

ProTable

An advanced data table built on Mantine React Table  with customized styling, pagination, sorting, and expansion support.

Import

import { ProTable, useProTable, TablePagination } from '@tidbcloud/uikit/biz'

Basic Usage

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' const data = [ { id: 1, name: 'John', email: 'john@example.com', status: 'Active' }, { id: 2, name: 'Jane', email: 'jane@example.com', status: 'Inactive' } ] const columns = [ { accessorKey: 'id', header: 'ID' }, { accessorKey: 'name', header: 'Name' }, { accessorKey: 'email', header: 'Email' }, { accessorKey: 'status', header: 'Status' } ] function Demo() { const table = useProTable({ data, columns }) return <ProTable table={table} /> }

With Pagination

Client-side Pagination

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data, columns, enablePagination: true }) return <ProTable table={table} /> }

Server-side Pagination

import { useState } from 'react' import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 }) const table = useProTable({ data, columns, manualPagination: true, onPaginationChange: setPagination, rowCount: totalCount, // Total rows from server enablePagination: true, state: { pagination } }) return <ProTable table={table} /> }

Pagination UI Options

const table = useProTable({ data, columns, enablePagination: true, pagination: { rowsPerPageOptions: ['10', '20', '50', '100'], showRowsPerPage: true, showTotal: true, localization: { total: 'Total:' } } })

With Sorting

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data, columns, enableSorting: true }) return <ProTable table={table} /> }

With Row Expansion

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data, columns, enableExpanding: true, renderDetailPanel: ({ row }) => <div>Details for {row.original.name}</div> }) return <ProTable table={table} /> }

With Virtual Scrolling

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data: largeDataset, columns, enableRowVirtualization: true }) return <ProTable table={table} /> }
import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data, columns, enableStickyHeader: true }) return <ProTable table={table} /> }

Loading State

import { ProTable, useProTable } from '@tidbcloud/uikit/biz' function Demo() { const table = useProTable({ data: [], columns, loading: true }) return <ProTable table={table} /> }

Props

PropTypeDefaultDescription
tableMRT_TableInstance-Table instance from useProTable
dataT[]-Table data
columnsMRT_ColumnDef[]-Column definitions
withBorderbooleantrueShow table border
emptyTextstring-Empty state message
errorTextstring-Error state message
loadingbooleanfalseLoading state
enablePaginationbooleanfalseEnable pagination
enableSortingbooleanfalseEnable sorting
enableExpandingbooleanfalseEnable row expansion
enableStickyHeaderboolean-Sticky header
enableStickyFooterboolean-Sticky footer
enableRowVirtualizationbooleanfalseVirtual scrolling
paginationPaginationConfig-Pagination configuration
wrapperPropsBoxProps-Wrapper props

Pagination Config

PropTypeDefaultDescription
rowsPerPageOptionsstring[]['5','10','15','20','25','30','50','100']Page size options
showRowsPerPagebooleanfalseShow page size selector
showTotalbooleanfalseShow total count
wrapperPropsFlexProps-Wrapper props
localization.totalstring'Total:'Total label text

Exports

ExportDescription
ProTableMain table component
useProTableHook for creating table instance
TablePaginationStandalone pagination component

ProTable supports all Mantine React Table  options.

Last updated on