Home/Components/DataTable

DataTable Component

A comprehensive data table component with sorting, filtering, pagination, and responsive design.

Live Preview

Name
Email
Role
Status
Created At
John Doejohn@example.comADMINActive2025-11-03
Alice Chenalice@example.comUSERActive2025-10-26
Brian Wangbrian@example.comMODERATORInactive2025-10-18
Cynthia Lincynthia@example.comUSERActive2025-10-11
Cynthia Lincynthia@example.comUSERActive2025-10-11
Total5/6 Active6 rows
每頁顯示
6 筆資料
跳至

Usage

import { DataTable } from '@featherstudio/react-daisyui-kit';

export default function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', sortable: true },
    { key: 'email', title: 'Email', dataIndex: 'email', filterable: true },
  ];

  const data = [
    { name: 'John', email: 'john@example.com' },
  ];

  return (
    <DataTable
      columns={columns}
      dataSource={data}
      pagination={{
        current: 1,
        pageSize: 10,
        showSizeChanger: true,
      }}
    />
  );
}
const summary = {
  show: true,
  fixed: true,
  columns: [
    { key: 'name', type: 'custom', render: () => <strong>Total</strong> },
    {
      key: 'isActive',
      type: 'custom',
      render: (data) =>
        data.filter((item) => item.isActive).length + '/' + data.length + ' Active'
    },
    { key: 'createdAt', type: 'count', suffix: ' rows' },
  ],
};

<DataTable
  columns={columns}
  dataSource={data}
  summary={summary}
  pagination={{ current: 1, pageSize: 10 }}
/>;

Features

Sorting

Enable sorting per column with sortable: true.

Pagination

Built-in page size switcher and quick jumper via pagination config.

Filtering

Per-column filtering via filterable: true.

Summary Row

Supports sum, avg, count and custom summary renderers.

Props

PropTypeDefaultDescription
columnsColumn[]-Column configuration
dataSourceRecord<string, unknown>[]-Table data
paginationPaginationConfig | false{ current: 1, pageSize: 10, ... }Pagination behavior configuration
summarySummaryConfigundefinedShow summary row with sum/avg/count/custom
emptyTextstring暫無資料Text displayed when there is no data
Back to Components