本文へ移動
日本語
「仮想スクロール表」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

One scroll box holds a sticky, slightly frosted header and a body as tall as every row together; only the rows in view plus a few either side are rendered, each placed with translateY on a shared grid template, so scrolling never lays out the rest. Scroll position is read once per animation frame. While scrolling, a dark chip with the visible range rises at the bottom on a spring and sinks away 700ms after the scroll stops. Overscroll is contained so the page does not move when the list reaches an end, and the box is focusable for keyboard scrolling.

向いている場面

  • Logs, events, ledgers and exports with thousands of rows that people scroll through.
  • Any table where rendering every row at once would make the page slow.

向かない場面

  • Rows of different heights: this layout needs a fixed row height.
  • When people need the browser's find-in-page over every row: off-screen rows do not exist in the page.

使い方

import { VirtualTable } from './VirtualTable.jsx'

export function RequestLog({ entries }) {
  return (
    <VirtualTable
      label="Request log"
      rows={entries}
      rowHeight={40}
      height={420}
      columns={[
        { key: 'id', title: 'Request', width: 120 },
        { key: 'path', title: 'Endpoint' },
        { key: 'status', title: 'Status', width: 72 },
        { key: 'ms', title: 'Duration', width: 84, align: 'right', render: (r) => `${r.ms} ms` },
      ]}
    />
  )
}

プロパティ

プロパティ型既定値説明
rows | rowCount + getRowobject[] | number + (index) => object—Either the full array, or a count and a function that returns one row, so very large or computed data never becomes one array.
columns{ key, title, width?: number | string, align?: 'left' | 'right', render?: (row, index) => ReactNode, hideBelow?: boolean }[]—Widths are grid tracks (px numbers or any track such as '2fr'); the default is a flexible track. hideBelow drops a column under 460px.
rowHeight / height / overscannumber40 / 360 / 6Fixed row height, viewport height, and rows rendered beyond each edge.
zebrabooleanfalseAlternate row fills.
label / labelsstring / { range(first, last, total) }'Table'Accessible name of the table and the wording of the range chip.

アクセシビリティ

  • The box has role table with aria-rowcount for the full count, and every rendered row carries aria-rowindex, so screen readers report the real position.
  • Header cells are columnheaders and the first cell of each row is a rowheader.
  • The scroll box is focusable; arrow keys, Page Up/Down, Home and End scroll it natively.
  • The range chip is decorative; reduced motion makes it fade without rising.

モーション

Range chip: 200ms fade and a 320ms spring rise while scrolling, gone 700ms after it stops. Row hover: 160ms.

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

VirtualTable.jsxvirtual-table.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

テーブル
「比較テーブル」は Pro に含まれます。解除するとプレビューが表示されます。
「データバー付きテーブル」は Pro に含まれます。解除するとプレビューが表示されます。