Table

Bảng dữ liệu đầy đủ tính năng: sort, fixed columns, inner scroll, custom colors, pagination.

Playground
#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending
size
bordered
striped
hoverable
loading
rounded
<Table
  columns={columns}
  data={data}
  rowKey="id"
  hoverable
/>

Basic

Chỉ cần columns và data. Bảng tự sort nội bộ khi đặt sortable: true trên cột.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending

onSort callback

Dùng onSort để nhận key và hướng sort mỗi khi người dùng click vào header có sortable: true. Hữu ích cho server-side sorting.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending
onSort log:chưa có — hãy click vào cột Name hoặc Score

Custom colors

headerBg / headerColor thay đổi header. bodyBg đổi nền body. bodyColor đổi màu chữ body. hoverBg đổi màu hover hàng. Click vào ô màu để chọn màu.

Opacity: 8%
#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending

Fixed columns

Đặt fixed: 'left' hoặc fixed: 'right' trên cột. Cần khai báo width để tính offset đúng. Cuộn ngang để thấy hiệu ứng.

#NameDepartmentEmailPhoneCityManagerScoreSalaryStatus
1Alice NguyenEngineeringalice.nguyen@company.com+84 91111111Hà NộiAlice Nguyen92$3,200Active
2Bob TranDesignbob.tran@company.com+84 92222222HCMBob Tran87$2,800Active
3Carol LeManagementcarol.le@company.com+84 93333333Đà NẵngCarol Le76$4,100Inactive
4David PhamEngineeringdavid.pham@company.com+84 94444444HuếAlice Nguyen95$3,500Active
5Eva HoangQAeva.hoang@company.com+84 95555555Cần ThơBob Tran68$2,400Pending
6Frank BuiEngineeringfrank.bui@company.com+84 96666666Hà NộiCarol Le81$3,100Active
7Grace DoMarketinggrace.do@company.com+84 97777777HCMAlice Nguyen74$2,600Active
8Hank VuDesignhank.vu@company.com+84 98888888Đà NẵngBob Tran90$2,900Inactive
9Iris NgoQAiris.ngo@company.com+84 99999999HuếCarol Le83$2,500Active
10Jack DinhEngineeringjack.dinh@company.com+84 1111110Cần ThơAlice Nguyen97$3,800Active
11Karen NguyenHRkaren.nguyen@company.com+84 2222221Hà NộiBob Tran72$2,700Pending
12Leo TrinhMarketingleo.trinh@company.com+84 3333332HCMCarol Le88$2,600Active

Inner scroll (scrollY)

scrollY giới hạn chiều cao phần body và bật cuộn dọc. Header tự động sticky.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending
6Frank BuiEngineering81Active
7Grace DoMarketing74Active
8Hank VuDesign90Inactive
9Iris NgoQA83Active
10Jack DinhEngineering97Active
11Karen NguyenHR72Pending
12Leo TrinhMarketing88Active

Auto width

fullWidth={false} làm bảng co lại theo nội dung thay vì kéo dài 100%.

#NameScore
1Alice Nguyen92
2Bob Tran87
3Carol Le76
4David Pham95

Pagination

Truyền pagination prop để bật phân trang nội bộ. Table tự slice data theo trang hiện tại.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
1–4 / 12

Pagination: page size selector

pageSizeOptions hiển thị dropdown cho phép đổi số hàng mỗi trang.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
1–4 / 12

Kết hợp: scrollY + fixed columns + pagination

Các tính năng hoạt động cùng nhau: cuộn dọc giới hạn, cột ghim, phân trang.

#NameDepartmentEmailPhoneCityScoreSalaryStatus
1Alice NguyenEngineeringalice.nguyen@company.com+84 91111111Hà Nội92$3,200Active
2Bob TranDesignbob.tran@company.com+84 92222222HCM87$2,800Active
3Carol LeManagementcarol.le@company.com+84 93333333Đà Nẵng76$4,100Inactive
4David PhamEngineeringdavid.pham@company.com+84 94444444Huế95$3,500Active
5Eva HoangQAeva.hoang@company.com+84 95555555Cần Thơ68$2,400Pending
6Frank BuiEngineeringfrank.bui@company.com+84 96666666Hà Nội81$3,100Active
1–6 / 12

Loading state

loading={true} thay thế nội dung bằng skeleton rows với hiệu ứng pulse.

#NameDepartmentScoreStatus
1Alice NguyenEngineering92Active
2Bob TranDesign87Active
3Carol LeManagement76Inactive
4David PhamEngineering95Active
5Eva HoangQA68Pending
6Frank BuiEngineering81Active
7Grace DoMarketing74Active
8Hank VuDesign90Inactive
9Iris NgoQA83Active
10Jack DinhEngineering97Active
11Karen NguyenHR72Pending
12Leo TrinhMarketing88Active

Table API

PropertyTypeDefaultDescription
columns*TableColumn<T>[]Column definitions
data*T[]Row data array
rowKeystring | (row) => string | numberUnique key per row
loadingbooleanfalseShow skeleton rows
loadingRowsnumber5Skeleton row count
borderedbooleanfalseBorder every cell and the table outline
stripedbooleanfalseAlternate even-row background
hoverablebooleanfalseHighlight rows on hover
size'sm' | 'md' | 'lg''md'Cell padding preset
emptyReactNode'Không có dữ liệu'Empty-state content
captionstringCaption below the table
stickyHeaderbooleanfalsePin header row (auto-on with scrollY)
onSort(key: string, dir: TableSortDir) => voidCallback fired when a sortable column header is clicked. Receives the column key and new direction
headerBgstringCustom header background colour
headerColorstringCustom header text colour
bodyBgstringCustom table body background colour
bodyColorstringCustom table body text colour
hoverBgstringCustom row hover background colour
scrollYstring | numberMax height for inner scroll, activates vertical overflow
fullWidthbooleantrueStretch table to fill container width
paginationTablePaginationConfigEnable pagination bar
rounded'none' | 'sm' | 'md' | 'lg' | 'full'Border-radius preset, visible when bordered={true}
classNamestringExtra className on the wrapper

TableColumn API

PropertyTypeDefaultDescription
key*stringUnique column id, used as fallback dataIndex
title*ReactNodeHeader content
dataIndexstringRow field to read
render(value, row, index) => ReactNodeCustom cell renderer
widthstring | numberColumn width, required for fixed columns
align'left' | 'center' | 'right''left'Cell text alignment
sortablebooleanfalseEnable click-to-sort
fixed'left' | 'right'Pin column to left or right edge. Requires width

TablePaginationConfig API

PropertyTypeDefaultDescription
pageSizenumber10Rows per page
totalnumberOverride total count for server-side pagination
showTotalbooleantrueShow "X–Y / Z" counter
pageSizeOptionsnumber[]Render a page-size selector with these values
onChange(page, pageSize) => voidCalled on page or size change