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

getting-started

できること

このスキルは、TanStack Tableを使って、Litのウェブコンポーネントの中に表を作る方法を示します。Litで再利用できるコンポーネントを作る開発者向けです。

使う場面

  • ✓項目の一覧を表で表示するLitのウェブコンポーネントを作っているとき。
  • ✓コンポーネントのデータが変わったときに、表を再描画する必要があるとき。
  • ✓Litのアプリで同じ表の設定を何度も繰り返し、再利用できる版が欲しいとき。

スキルのリンク

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

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“人の一覧を表で表示するLitのウェブコンポーネントを作っています。どう設定すればよいですか。”

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

仕組み

表のコントローラーがコンポーネントにどう取り付けられるか、描画の間に表をどう作るか、そしてFlexRenderのヘルパーでヘッダーと行をどう表示するかを説明します。

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

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

Load intent load @tanstack/table-core#core first for the headless model, stable inputs, and column inference.

Setup

import { LitElement, html } from 'lit'
import { customElement, state } from 'lit/decorators.js'
import { repeat } from 'lit/directives/repeat.js'
import {
  FlexRender,
  TableController,
  createColumnHelper,
  tableFeatures,
} from '@tanstack/lit-table'

type Person = { id: string; name: string }

const features = tableFeatures({})
const columnHelper = createColumnHelper<typeof features, Person>()
const columns = columnHelper.columns([
  columnHelper.accessor('name', { header: 'Name' }),
])

@customElement('people-table')
export class PeopleTable extends LitElement {
  @state() private people: Array<Person> = [{ id: '1', name: 'Ada' }]
  private tableController = new TableController<typeof features, Person>(this)

  protected render() {
    const table = this.tableController.table({
      features,
      columns,
      data: this.people,
      getRowId: (row) => row.id,
    })

    return html`<table>
      <thead>
        ${repeat(
          table.getHeaderGroups(),
          (group) => group.id,
          (group) =>
            html`<tr>
              ${repeat(
                group.headers,
                (header) => header.id,
                (header) =>
                  html`<th>
                    ${header.isPlaceholder ? null : FlexRender({ header })}
                  </th>`,
              )}
            </tr>`,
        )}
      </thead>
      <tbody>
        ${repeat(
          table.getRowModel().rows,
          (row) => row.id,
          (row) =>
            html`<tr>
              ${repeat(
                row.getAllCells(),
                (cell) => cell.id,
                (cell) => html`<td>${FlexRender({ cell })}</td>`,
              )}
            </tr>`,
        )}
      </tbody>
    </table>`
  }
}

Construction and rendering

Keep one TableController as a host field. V9 takes only the host in its constructor; pass current options to controller.table(...) during every render. Recreating the controller repeats lifecycle and subscription work.

Keep features, columns, and data stable across host updates. Use FlexRender({ cell }), FlexRender({ header }), or FlexRender({ footer }) in Lit templates. The application owns semantic markup, accessibility, widths, and sticky positioning.

The controller selects all registered state by default. Narrow selected state only when host update cost requires it; use table-state for selectors and template subscriptions.

Read for the task

  • When adding or configuring optional features, load intent load @tanstack/table-core#table-features and 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.
  • When virtualizing rows or columns, read with-tanstack-virtual.
  • When upgrading v8 code, read migrate-v8-to-v9.

API discovery

Inspect node_modules/@tanstack/lit-table/dist/index.d.ts, then TableController.d.ts, flexRender.d.ts, or the relevant exported declaration. Core feature APIs are in node_modules/@tanstack/table-core/dist/features/.

よくある質問

表のコントローラーは何をしますか?

コンポーネントのために表を作り、表が使っている状態が変わったときにコンポーネントの更新を求めます。

Litのテンプレートの仕組みを知っている必要がありますか?

基本的なLitの知識があると役立ちます。例ではLitのhtmlテンプレートとrepeatのディレクティブを使うからです。

Litだけが対象ですか?

はい、TanStack Table v9のLit版を扱います。

詳細

作者による元の説明

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

repo: TanStack/table

人気

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

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

0

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

コメント

  • …

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

似ているスキル