Skip to content

Commit 7fa1bb7

Browse files
committed
docs: add docs for virtualized datatable
1 parent f3f95b3 commit 7fa1bb7

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

apps/www/src/content/docs/components/datatable/index.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,48 @@ import {
4444

4545
<auto-type-table path="./props.ts" name="DataTableContentProps" />
4646

47+
## DataTable.VirtualizedContent Props
48+
49+
<auto-type-table path="./props.ts" name="VirtualizedContentProps" />
50+
51+
### Virtualized Content
52+
53+
For large datasets, use `DataTable.VirtualizedContent` for better performance. Parent container must have a fixed height.
54+
55+
```tsx
56+
<div style={{ height: 400 }}>
57+
<DataTable
58+
data={data}
59+
columns={columns}
60+
defaultSort={{ name: "name", order: "asc" }}>
61+
<DataTable.Toolbar />
62+
<DataTable.VirtualizedContent rowHeight={44} />
63+
</DataTable>
64+
</div>
65+
```
66+
67+
#### Fixed Width Columns
68+
69+
By default, columns share equal width. For fixed width columns, use `flex: 'none'` with `width`:
70+
71+
```tsx
72+
const columns = [
73+
{
74+
accessorKey: "select",
75+
header: "",
76+
styles: {
77+
header: { width: 50, flex: "none" },
78+
cell: { width: 50, flex: "none" }
79+
}
80+
},
81+
{
82+
accessorKey: "name",
83+
header: "Name"
84+
// Uses flex: 1 1 0 by default (equal width)
85+
}
86+
];
87+
```
88+
4789
## Examples
4890

4991
### Basic Usage

apps/www/src/content/docs/components/datatable/props.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,49 @@ export interface DataTableContentProps {
118118
row?: string;
119119
};
120120
}
121+
122+
export interface VirtualizedContentProps {
123+
/**
124+
* Height of the virtualized container.
125+
* Parent must have a fixed height for percentage values to work.
126+
* @defaultValue "100%"
127+
*/
128+
height?: number | string;
129+
130+
/**
131+
* Height of each row in pixels.
132+
* @defaultValue 40
133+
*/
134+
rowHeight?: number;
135+
136+
/**
137+
* Height of group header rows in pixels.
138+
* Falls back to rowHeight if not specified.
139+
*/
140+
groupHeaderHeight?: number;
141+
142+
/**
143+
* Number of rows to render outside the visible area.
144+
* @defaultValue 5
145+
*/
146+
overscan?: number;
147+
148+
/**
149+
* Custom empty state shown when no results match after filters/search.
150+
*/
151+
emptyState?: React.ReactNode;
152+
153+
/**
154+
* Custom zero state shown when no data exists initially.
155+
*/
156+
zeroState?: React.ReactNode;
157+
158+
/** Custom class names for styling */
159+
classNames?: {
160+
root?: string;
161+
table?: string;
162+
header?: string;
163+
body?: string;
164+
row?: string;
165+
};
166+
}

0 commit comments

Comments
 (0)