getting-started
它能做什么
这项技能展示如何在使用 Alpine.js 构建的网页中,借助 TanStack Table 库创建并显示数据表格。适合希望自己设计表格样式的无头表格网页开发者。
适用场景
- ✓当你在构建一个需要结构化记录表格的 Alpine.js 页面的时候。
- ✓当你的表格数据随时间变化,表格必须在屏幕上同步更新的时候。
- ✓当你想用 FlexRender 辅助函数渲染表头和单元格的时候。
技能链接
https://github.com/TanStack/table/blob/main/packages/alpine-table/skills/getting-started/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我正在做一个 Alpine.js 页面,用表格列出客户。应该如何用 TanStack Table 设置它?”
每周 5 个新技能,1 分钟读完。
工作原理
它提供根据列定义和数据创建表格的代码模式,然后展示如何用 Alpine 的模板循环在页面中渲染表头和行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Load intent load @tanstack/table-core#core first for the headless model, stable inputs, and column inference.
Setup
import Alpine from 'alpinejs'
import {
FlexRender,
createTable,
tableFeatures,
type ColumnDef,
} from '@tanstack/alpine-table'
type Person = { id: string; name: string }
const features = tableFeatures({})
const columns: Array<ColumnDef<typeof features, Person>> = [
{ accessorKey: 'name', header: 'Name' },
]
Alpine.data('peopleTable', () => {
const local = Alpine.reactive({
data: [{ id: '1', name: 'Ada' }] as Array<Person>,
})
const table = createTable({
features,
columns,
get data() {
return local.data
},
getRowId: (row) => row.id,
})
return { table, FlexRender }
})
window.Alpine = Alpine
Alpine.start()
Render real table structure with x-for; use x-html="FlexRender({ header })" or x-html="FlexRender({ cell })" only for renderer output.
Construction and rendering
Wrap changing data in Alpine.reactive and expose it with get data(). The adapter tracks option getters; data: local.data captures a snapshot and does not follow later array replacements. Keep static columns and features outside getters.
The returned table is a reactive proxy. Read Table APIs directly in x-text, x-for, x-if, or bound attributes; no Subscribe component is needed.
Build table structure and interactive controls as real Alpine markup. Use x-html="FlexRender({ header })" or x-html="FlexRender({ cell })" for renderer output. Alpine does not initialize directives inside x-html strings; use templates or Alpine.bind bundles for buttons and inputs.
Read for the task
- When adding or configuring optional features, load
intent load @tanstack/table-core#table-featuresand read only references for the requested behavior. - For state ownership or reactive reads, read table-state.
- When tables share features, defaults, or reusable UI, read create-table-hook.
API discovery
Inspect node_modules/@tanstack/alpine-table/dist/index.d.ts, createTable.d.ts, and reactivity.d.ts. Core feature APIs are in node_modules/@tanstack/table-core/dist/features/.
常见问题
我需要先熟悉 TanStack Table 吗?
不需要深入了解。这项技能指向核心指南获取背景知识,然后讲解 Alpine 特有的设置。
如何让表格与变化的数据保持同步?
这项技能建议把数据包装在 Alpine 的响应式 store 中,并通过 getter 暴露出来。
它只适用于 Alpine.js 吗?
是的,它涵盖 Table v9 的 Alpine 版本,其他框架有各自的指南。
详情
作者的原始描述
Create and render Table v9 with the alpine adapter. Route reusable createTableHook defaults, and framework setup; use table-state for reactive ownership.
repo: TanStack/table
热度
- GitHub 星标
- 29k
- 排名
- #9805
- 许可证
- MIT
- 更新时间
- 2026/10/21
评论
- …
同一仓库的更多技能
table-state
29k教你的智能体如何在 Alpine.js 中读取和控制表格状态,例如当前页码,使状态变化时屏幕能够更新。
devtools
29k教你的智能体如何把 Angular 表格注册到 TanStack Devtools 面板中,使开发者在构建应用时能检查每个表格。
getting-started
29k教你的智能体如何在 Angular 中创建并显示 TanStack 表格,涵盖 injectTable 设置、模板渲染和行数据的更新。
migrate-v8-to-v9
29k帮你的智能体把 Angular 表格从 TanStack Table v8 迁移到 v9,并依据迁移清单检查设置、渲染、状态和钩子。