Table
Bảng dữ liệu đầy đủ tính năng: sort, fixed columns, inner scroll, custom colors, pagination.
<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.
Custom colors
headerBg / headerColor thay đổi header. bodyBg đổi nền body. hoverBg đổi màu hover hàng. Click vào ô màu để chọn màu.
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.
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.
Auto width
fullWidth={false} làm bảng co lại theo nội dung thay vì kéo dài 100%.
Pagination
Truyền pagination prop để bật phân trang nội bộ. Table tự slice data theo trang hiện tại.
Pagination — page size selector
pageSizeOptions hiển thị dropdown cho phép đổi số hàng mỗi trang.
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.
Loading state
loading={true} thay thế nội dung bằng skeleton rows với hiệu ứng pulse.
Table API
| Property | Type | Default | Description |
|---|
columns* | TableColumn<T>[] | — | Column definitions |
data* | T[] | — | Row data array |
rowKey | string | (row) => string | number | — | Unique key per row |
loading | boolean | false | Show skeleton rows |
loadingRows | number | 5 | Skeleton row count |
bordered | boolean | false | Border every cell and the table outline |
striped | boolean | false | Alternate even-row background |
hoverable | boolean | false | Highlight rows on hover |
size | 'sm' | 'md' | 'lg' | 'md' | Cell padding preset |
empty | ReactNode | 'Không có dữ liệu' | Empty-state content |
caption | string | — | Caption below the table |
stickyHeader | boolean | false | Pin header row (auto-on with scrollY) |
onSort | (key, dir) => void | — | Sort callback |
headerBg | string | — | Custom header background colour |
headerColor | string | — | Custom header text colour |
bodyBg | string | — | Custom table body background colour |
hoverBg | string | — | Custom row hover background colour |
scrollY | string | number | — | Max height for inner scroll — activates vertical overflow |
fullWidth | boolean | true | Stretch table to fill container width |
pagination | TablePaginationConfig | — | Enable pagination bar |
className | string | — | Extra className on the wrapper |
TableColumn API
| Property | Type | Default | Description |
|---|
key* | string | — | Unique column id, used as fallback dataIndex |
title* | ReactNode | — | Header content |
dataIndex | string | — | Row field to read |
render | (value, row, index) => ReactNode | — | Custom cell renderer |
width | string | number | — | Column width — required for fixed columns |
align | 'left' | 'center' | 'right' | 'left' | Cell text alignment |
sortable | boolean | false | Enable click-to-sort |
fixed | 'left' | 'right' | — | Pin column to left or right edge — requires width |
TablePaginationConfig API
| Property | Type | Default | Description |
|---|
pageSize | number | 10 | Rows per page |
total | number | — | Override total count for server-side pagination |
showTotal | boolean | true | Show "X–Y / Z" counter |
pageSizeOptions | number[] | — | Render a page-size selector with these values |
onChange | (page, pageSize) => void | — | Called on page or size change |