使用 TS/JS、React、Vue、Solid、Svelte、Qwik、Angular 和 Lit 加强您的表格或从头开始构建数据网格,同时保留对标记和样式的 100% 控制权。
开始使用import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table'
const data = [{ id: 1, name: 'Ada' }]
const columns = [{ accessorKey: 'name', header: 'Name' }]
export default function SimpleTable() {
const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel() })
return (
<table>
<thead>
{table.getHeaderGroups().map((hg) => (
<tr key={hg.id}>
{hg.headers.map((header) => (
<th key={header.id}>
{flexRender(header.column.columnDef.header, header.getContext())}
</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
))}
</tbody>
</table>
)
}看看团队在说什么
"推出带有分页、行选择、排序、过滤器、行操作和键盘导航的 Table 和 Data Table 组件。由 TanStack Table 提供支持。"
"我使用 React Aria 组件制作了一个版本,具有箭头键导航、多选、屏幕阅读器公告等。它也很好地与 TanStack Table 配合使用!"
"如果您需要轻量级、无主见且完全可定制的解决方案,TanStack Table 是完美的选择。它赋予您力量,并将演示留给您。"
"使用 shadcn 和 TanStack Table 的线性风格表格过滤器。开源。您可以使用它作为 Data Table 组件的附加组件。"
"推出带有分页、行选择、排序、过滤器、行操作和键盘导航的 Table 和 Data Table 组件。由 TanStack Table 提供支持。"
"我使用 React Aria 组件制作了一个版本,具有箭头键导航、多选、屏幕阅读器公告等。它也很好地与 TanStack Table 配合使用!"
"如果您需要轻量级、无主见且完全可定制的解决方案,TanStack Table 是完美的选择。它赋予您力量,并将演示留给您。"
"使用 shadcn 和 TanStack Table 的线性风格表格过滤器。开源。您可以使用它作为 Data Table 组件的附加组件。"
使用一些基本样式、一些表格标记和几个列,你已经走上了一条创建功能强大的表格的道路。