Skip to content

Data Grid

DataMIT
View in Storybook

Data grid with row selection and inline cell editing.

bun add @otfdashkit/ui

Preview

Data Grid
Loading Storybook preview…

Code

import { DataGrid } from '@otfdashkit/ui'

interface User {
  id: string
  name: string
  email: string
  role: 'Admin' | 'Member' | 'Viewer'
  status: 'Active' | 'Inactive' | 'Pending'
  createdAt: string
}

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 <DataGrid<User> data={makeUsers(20)} />
}

Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the DataGrid source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
columnsrequiredColumnDef<T, any>[]
datarequiredT[]
classNamestring
editableboolean
onDataChange(data: T[]) => void