Advanced Data Grid
DataMITData grid with row selection, sorting, a column visibility menu, column resizing, and virtual scrolling for large datasets.
bun add @otfdashkit/ui
Preview
Advanced Data GridData
Loading Storybook preview…
Code
@otfdashkit/uiimport type { ColumnDef } from '@tanstack/react-table'
import { AdvancedDataGrid as DataGrid } from '@otfdashkit/ui'
interface User {
id: string
name: string
email: string
role: 'Admin' | 'Member' | 'Viewer'
status: 'Active' | 'Inactive' | 'Pending'
createdAt: string
}
const columns: ColumnDef<User, unknown>[] = [
{ accessorKey: 'name', header: 'Name', size: 160 },
{ accessorKey: 'email', header: 'Email', size: 220 },
{ accessorKey: 'role', header: 'Role', size: 100 },
{ accessorKey: 'status', header: 'Status', size: 100 },
{ accessorKey: 'createdAt', header: 'Created', size: 120 },
]
function makeUsers(n: number): User[] {
const roles: User['role'][] = ['Admin', 'Member', 'Viewer']
const statuses: User['status'][] = ['Active', 'Inactive', 'Pending']
return Array.from({ length: n }, (_, i) => ({
id: String(i + 1),
name: `User ${i + 1}`,
email: `user${i + 1}@example.com`,
role: roles[i % 3]!,
status: statuses[i % 3]!,
createdAt: new Date(Date.now() - i * 86400000).toLocaleDateString(),
}))
}
export function Example() {
return (
<div className="p-6">
<DataGrid
columns={columns}
data={makeUsers(20)}
columnVisibility
selectable
/>
</div>
)
}
Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.
Props
Props declared in the AdvancedDataGrid source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| columnsrequired | ColumnDef<T, unknown>[] | ||
| datarequired | T[] | ||
| className | string | ||
| columnVisibility | boolean | false | Enable column visibility toggle |
| emptyState | ReactNode | Slot rendered when data is empty | |
| filterable | boolean | false | Enable client-side column filtering |
| loading | boolean | false | Slot rendered while loading |
| onRowClick | (row: T) => void | Called on row click | |
| onSelectionChange | (rows: T[]) => void | Called when selection changes | |
| resizable | boolean | true | Enable column resize |
| rowHeight | number | 40 | Row height estimate for virtualizer (default 40) |
| selectable | boolean | false | Enable row checkboxes + bulk selection |
| skeletonRows | number | 5 | Number of skeleton rows to show while loading (default 5) |
| sortable | boolean | true | Enable column sorting |
| virtual | boolean | false | Virtualise rows for large datasets — enable when rows > ~100 |
| virtualHeight | number | 480 | Height of the scroll container when virtual=true (default 480) |