Table
Table renders structured data with columns, sorting, filters, selection, and pagination.
@duskmoon-dev/components/table Usage
When to use
- Use it when users need to scan structured content and act on individual records.
- Prefer it over ad hoc markup when the content has repeatable fields, hierarchy, or navigation state.
Implementation notes
Features
Designed for repeated or hierarchical content where users scan, compare, and inspect details.
Documents the props that control sorting, selection, expansion, pagination, or value changes where available.
Table is most often configured through `columns`, `dataSource`, `rowKey`, `loading`.
Renders columns, dataSource, nested dataIndex, loading, and empty text
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
| Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Basic usage
Import the component stylesheet and Table from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function Example() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Renders columns, dataSource, nested dataIndex, loading, and empty text
test-backedTable scenario from the component test coverage: renders columns, datasource, nested dataindex, loading, and empty text.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function TableRendersColumnsDataSourceNestedDemo() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Sorts data and emits onChange sorter information
test-backedTable scenario from the component test coverage: sorts data and emits onchange sorter information.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function TableSortsDataAndEmitsDemo() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Filters rows and emits filter changes
test-backedTable scenario from the component test coverage: filters rows and emits filter changes.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function TableFiltersRowsAndEmitsDemo() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Supports row selection and expandable rows
test-backedTable scenario from the component test coverage: supports row selection and expandable rows.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function TableSupportsRowSelectionAndDemo() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Supports pagination config, summary, Column, and ColumnGroup
test-backedTable scenario from the component test coverage: supports pagination config, summary, column, and columngroup.
import "@duskmoon-dev/components/styles.css";
import { Table } from "@duskmoon-dev/components/table";
export function TableSupportsPaginationConfigSummaryDemo() {
return (<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>);
} | Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
| Name | Status | Owner |
|---|---|---|
| Design tokens | Ready | Luna |
| Components | Review | Kai |
Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>
</div>
<div data-theme="moonlight">
<Table
columns={[
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Status", dataIndex: "status", key: "status" },
{ title: "Owner", dataIndex: "owner", key: "owner" }
]}
dataSource={[
{ key: 1, name: "Design tokens", status: "Ready", owner: "Luna" },
{ key: 2, name: "Components", status: "Review", owner: "Kai" }
]}
pagination={false}
bordered
/>
</div> API
The API reference below lists every parsed exported type or interface for Table. Start with `columns`, `dataSource`, `rowKey`, `loading` for common usage.
packages/components/src/components/table/Table.types.ts
Scenarios: packages/components/src/components/table/Table.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
columns | TableColumnsType<T> | No | columns configures Table. |
dataSource | T[] | No | dataSource configures Table. |
rowKey | TableRowKey<T> | No | rowKey configures Table. |
loading | boolean | { spinning?: boolean; indicator?: ReactNode } | No | loading configures Table. |
bordered | boolean | No | bordered configures Table. |
size | TableSize | No | size configures Table. |
pagination | false | TablePaginationConfig | No | pagination configures Table. |
rowSelection | TableRowSelection<T> | No | rowSelection configures Table. |
expandable | TableExpandableConfig<T> | No | expandable configures Table. |
summary | (pageData: readonly T[]) => ReactNode | No | summary configures Table. |
locale | TableLocale | No | locale configures Table. |
tableLayout | CSSProperties["tableLayout"] | No | tableLayout configures Table. |
scroll | { x?: number | string | true; y?: number | string } | No | scroll configures Table. |
onChange | ( | No | onChange configures Table. |
pagination | TablePaginationConfig, | Yes | pagination configures Table. |
filters | Record<string, FilterValue | null>, | Yes | filters configures Table. |
sorter | SorterResult<T>, | Yes | sorter configures Table. |
extra | TableCurrentDataSource<T>, | Yes | extra configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
title | ReactNode | No | title configures Table. |
dataIndex | DataIndex | No | dataIndex configures Table. |
key | TableKey | No | key configures Table. |
width | string | number | No | width configures Table. |
align | "left" | "center" | "right" | No | align configures Table. |
className | string | No | className configures Table. |
fixed | "left" | "right" | boolean | No | fixed configures Table. |
ellipsis | boolean | No | ellipsis configures Table. |
render | (value: unknown, record: T, index: number) => ReactNode | No | render configures Table. |
sorter | TableSorter<T> | No | sorter configures Table. |
sortOrder | SortOrder | No | sortOrder configures Table. |
defaultSortOrder | SortOrder | No | defaultSortOrder configures Table. |
sortDirections | SortOrder[] | No | sortDirections configures Table. |
filters | TableFilterItem[] | No | filters configures Table. |
filteredValue | FilterValue | null | No | filteredValue configures Table. |
defaultFilteredValue | FilterValue | null | No | defaultFilteredValue configures Table. |
filterMultiple | boolean | No | filterMultiple configures Table. |
onFilter | (value: string | number | boolean | null, record: T) => boolean | No | onFilter configures Table. |
children | TableColumnsType<T> | No | children configures Table. |
onCell | (record: T, index: number) => ComponentProps<"td"> | No | onCell configures Table. |
onHeaderCell | (column: TableColumnType<T>) => ComponentProps<"th"> | No | onHeaderCell configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
current | number | No | current configures Table. |
defaultCurrent | number | No | defaultCurrent configures Table. |
pageSize | number | No | pageSize configures Table. |
defaultPageSize | number | No | defaultPageSize configures Table. |
total | number | No | total configures Table. |
disabled | boolean | No | disabled configures Table. |
hideOnSinglePage | boolean | No | hideOnSinglePage configures Table. |
showTotal | (total: number, range: [number, number]) => ReactNode | No | showTotal configures Table. |
onChange | (page: number, pageSize: number) => void | No | onChange configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
text | ReactNode | Yes | text configures Table. |
value | string | number | boolean | Yes | value configures Table. |
children | TableFilterItem[] | No | children configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
children | TableColumnsType<T> | Yes | children configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
column | TableColumnType<T> | No | column configures Table. |
columnKey | TableKey | No | columnKey configures Table. |
field | DataIndex | No | field configures Table. |
order | SortOrder | No | order configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
currentDataSource | T[] | Yes | currentDataSource configures Table. |
action | "paginate" | "sort" | "filter" | Yes | action configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
type | "checkbox" | "radio" | No | type configures Table. |
selectedRowKeys | TableKey[] | No | selectedRowKeys configures Table. |
defaultSelectedRowKeys | TableKey[] | No | defaultSelectedRowKeys configures Table. |
hideSelectAll | boolean | No | hideSelectAll configures Table. |
columnTitle | ReactNode | No | columnTitle configures Table. |
getCheckboxProps | (record: T) => ComponentProps<"input"> | No | getCheckboxProps configures Table. |
renderCell | ( | No | renderCell configures Table. |
checked | boolean, | Yes | checked configures Table. |
record | T, | Yes | record configures Table. |
index | number, | Yes | index configures Table. |
originNode | ReactNode, | Yes | originNode configures Table. |
onChange | (selectedRowKeys: TableKey[], selectedRows: T[]) => void | No | onChange configures Table. |
onSelect | ( | No | onSelect configures Table. |
record | T, | Yes | record configures Table. |
selected | boolean, | Yes | selected configures Table. |
selectedRows | T[], | Yes | selectedRows configures Table. |
nativeEvent | Event, | Yes | nativeEvent configures Table. |
onSelectAll | ( | No | onSelectAll configures Table. |
selected | boolean, | Yes | selected configures Table. |
selectedRows | T[], | Yes | selectedRows configures Table. |
changedRows | T[], | Yes | changedRows configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
expandedRowKeys | TableKey[] | No | expandedRowKeys configures Table. |
defaultExpandedRowKeys | TableKey[] | No | defaultExpandedRowKeys configures Table. |
expandedRowRender | ( | No | expandedRowRender configures Table. |
record | T, | Yes | record configures Table. |
index | number, | Yes | index configures Table. |
indent | number, | Yes | indent configures Table. |
expanded | boolean, | Yes | expanded configures Table. |
rowExpandable | (record: T) => boolean | No | rowExpandable configures Table. |
expandRowByClick | boolean | No | expandRowByClick configures Table. |
columnTitle | ReactNode | No | columnTitle configures Table. |
onExpand | (expanded: boolean, record: T) => void | No | onExpand configures Table. |
onExpandedRowsChange | (expandedKeys: TableKey[]) => void | No | onExpandedRowsChange configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
emptyText | ReactNode | No | emptyText configures Table. |
| Prop | Type | Required | Description |
|---|---|---|---|
fixed | boolean | "top" | "bottom" | No | fixed configures Table. |
string | number Record<string, unknown> string | number | readonly (string | number)[] "ascend" | "descend" | null Array<string | number | boolean | null> "small" | "middle" | "large" ComponentProps<"tr"> ComponentProps<"td"> & { index?: number ForwardRefExoticComponent< TableColumnProps & RefAttributes<HTMLTableCellElement> > ForwardRefExoticComponent< TableColumnGroupProps & RefAttributes<HTMLTableCellElement> > ForwardRefExoticComponent< TableSummaryProps & RefAttributes<HTMLTableSectionElement> > & { Row: ForwardRefExoticComponent< TableSummaryRowProps & RefAttributes<HTMLTableRowElement> > (<T = TableRecord>( props: TableProps<T> & RefAttributes<HTMLDivElement>, ) => ReactElement | null) & { Column: TableColumnComponent