本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)29k · #9831

getting-started

できること

SvelteアプリでTanStack Tableを使い、データのテーブルを作成して表示する方法を説明します。Svelte 5を使い、テーブルの見た目を自由に設定したいSvelte開発者向けです。

使う場面

  • ✓レコードを表示するSvelteコンポーネントを作っているとき。
  • ✓Svelteテーブルのデータがrunesで保持されていて、画面で更新される必要があるとき。
  • ✓Svelteテーブルにクエリや仮想化の機能を追加したいとき。

スキルのリンク

https://github.com/TanStack/table/blob/main/packages/svelte-table/skills/getting-started/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/TanStack/table/blob/main/packages/svelte-table/skills/getting-started/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ユーザー一覧をテーブルに表示するSvelte 5のページを作っています。設定方法を教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

列を定義し、createTableでテーブルを作成し、テンプレート内でヘッダー、行、セルをループ表示するコンポーネントを示します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Svelte Table setup and integration

Before starting, run intent load @tanstack/table-core#core for the shared headless model and stable-input rules.

Setup

Keep features and columns outside reactive work; expose changing rune values through getters.

<script lang="ts">
  import {
    createTable,
    FlexRender,
    tableFeatures,
  } from '@tanstack/svelte-table'

  type Person = { firstName: string; age: number }
  const features = tableFeatures({})
  const columns = [
    { accessorKey: 'firstName', header: 'First name' },
    { accessorKey: 'age', header: 'Age' },
  ]
  let data = $state<Person[]>([{ firstName: 'Ada', age: 36 }])

  const table = createTable({
    features,
    columns,
    get data() {
      return data
    },
  })
</script>

<table>
  <thead>
    {#each table.getHeaderGroups() as group (group.id)}
      <tr
        >{#each group.headers as header (header.id)}<th
            >{#if !header.isPlaceholder}<FlexRender {header} />{/if}</th
          >{/each}</tr
      >
    {/each}
  </thead>
  <tbody>
    {#each table.getRowModel().rows as row (row.id)}
      <tr
        >{#each row.getAllCells() as cell (cell.id)}<td
            ><FlexRender {cell} /></td
          >{/each}</tr
      >
    {/each}
  </tbody>
</table>

Essential constraints

V9 requires Svelte 5 and createTable. Expose changing runes through getters; data captured once cannot follow reassignment. Keep features and columns outside reactive work and use $derived for transformed arrays.

Table owns models and state. The application owns markup, CSS, interactions, and accessibility. Core-only tables use row.getAllCells(); visibility-aware methods need columnVisibilityFeature. Optional state and APIs require their features. Put row-model slots after their prerequisite features in tableFeatures().

Load by task

  • For repeated features, defaults, typed contexts, or component registries, read reusable app hooks.
  • For Query-backed data, server pages, sorting, filtering, or request keys, read TanStack Query integration.
  • For virtual rows, columns, dynamic measurement, or infinite scrolling, read TanStack Virtual integration.
  • For controlled state, tracked reads, or render subscriptions, read table state.
  • For feature registration, missing feature APIs, or processing ownership, run intent load @tanstack/table-core#table-features and read only references needed by the task.
  • For v8 code, read the migration checklist.

API discovery

Inspect node_modules/@tanstack/svelte-table/dist/index.d.ts, then the exported adapter declarations for the installed version. Inspect optional core APIs under node_modules/@tanstack/table-core/dist/features/.

よくある質問

このスキルにはどのSvelteのバージョンが必要ですか?

Table v9にはSvelte 5が必要だと、このスキルは説明しています。

データの変更はテーブルにどう伝わりますか?

runesの値をゲッター経由で渡すよう勧めています。そうすればテーブルは常に現在の値を読みます。

テーブルのヘッダーとセルは何で描画されますか?

FlexRenderコンポーネントがヘッダーとセルを描画します。

詳細

作者による元の説明

Create and render Table v9 with the svelte adapter. Route reusable createTableHook components, Query and Virtual integration, and framework setup; use table-state for reactive ownership.

repo: TanStack/table

人気

GitHubのスター
29k
ランキング
#9831
ライセンス
MIT
更新日
2026/10/21

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル