Ir al contenido
Español
Tabla virtual viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • 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.

Busca otra opción cuando

  • 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.

Uso

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` },
      ]}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
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.

Accesibilidad

  • 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.

Movimiento

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

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

VirtualTable.jsxvirtual-table.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Tablas
Tabla comparativa viene con Pro. La vista previa aparece al desbloquearlo.
Tabla con barras de datos viene con Pro. La vista previa aparece al desbloquearlo.