Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

DataGrid

Free25.2 KB gzipped

An interactive data table (WAI-ARIA APG "Data Grid"): sortable columns (with Shift for multi-column sorts), search filtering, single or multiple row selection, pagination, and a full keyboard model. Works with client-side data, or server-side data with manual.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys, Home and 11 more · Full report

More in Pro

This DataGrid is free. DataGridPro, in the paid Pro add-on, takes every prop on this page and adds column tools, filters, grouping, editing, and copy and paste. CSV and Excel export, also in Pro, downloads exactly what the grid shows.

Import

tsx
import { DataGrid } from "@vjdesigns/vjdesigns-ui";

Importing only DataGrid adds about 25.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

The grid is one tab stop: arrow keys move between cells, Enter on a header sorts (Shift+Enter adds a second sort), and screen readers hear sort changes. rowHeader makes that column name its rows.

Jordan ReyesGuard18.47.1
Avery ChenForward15.22.4
Sam OkaforCenter12.91.8
Riley ParkGuard11.65.3
Morgan DiazForward9.82.9
Casey LinGuard8.74.4
Taylor BrooksCenter7.51.1
tsx
import { DataGrid } from "@vjdesigns/vjdesigns-ui";

const roster = [
  { id: 1, name: "Jordan Reyes", position: "Guard", ppg: 18.4, apg: 7.1 },
  { id: 2, name: "Avery Chen", position: "Forward", ppg: 15.2, apg: 2.4 },
  { id: 3, name: "Sam Okafor", position: "Center", ppg: 12.9, apg: 1.8 },
  { id: 4, name: "Riley Park", position: "Guard", ppg: 11.6, apg: 5.3 },
  { id: 5, name: "Morgan Diaz", position: "Forward", ppg: 9.8, apg: 2.9 },
  { id: 6, name: "Casey Lin", position: "Guard", ppg: 8.7, apg: 4.4 },
  { id: 7, name: "Taylor Brooks", position: "Center", ppg: 7.5, apg: 1.1 },
];

const rosterColumns = [
  { key: "name", header: "Player", sortable: true, rowHeader: true },
  { key: "position", header: "Position", sortable: true },
  { key: "ppg", header: "Points", sortable: true, numeric: true },
  { key: "apg", header: "Assists", sortable: true, numeric: true },
];

export function Basic() {
  return <DataGrid aria-label="Roster" rows={roster} columns={rosterColumns} getRowId={(p) => p.id} />;
}

Search and selection

filter searches the rows, and the result count is announced. selectionMode="multiple" adds checkboxes: Space selects a row, Shift+Space a range, Ctrl/⌘+A every row. pageSize adds pagination.

Jordan ReyesGuard18.47.1
Avery ChenForward15.22.4
Sam OkaforCenter12.91.8
Riley ParkGuard11.65.3
Morgan DiazForward9.82.9
tsx
import { useState } from "react";
import {
  DataGrid,
  Field,
  SearchInput,
  Stack,
  type DataGridRowId,
} from "@vjdesigns/vjdesigns-ui";

const roster = [
  { id: 1, name: "Jordan Reyes", position: "Guard", ppg: 18.4, apg: 7.1 },
  { id: 2, name: "Avery Chen", position: "Forward", ppg: 15.2, apg: 2.4 },
  { id: 3, name: "Sam Okafor", position: "Center", ppg: 12.9, apg: 1.8 },
  { id: 4, name: "Riley Park", position: "Guard", ppg: 11.6, apg: 5.3 },
  { id: 5, name: "Morgan Diaz", position: "Forward", ppg: 9.8, apg: 2.9 },
  { id: 6, name: "Casey Lin", position: "Guard", ppg: 8.7, apg: 4.4 },
  { id: 7, name: "Taylor Brooks", position: "Center", ppg: 7.5, apg: 1.1 },
];

const rosterColumns = [
  { key: "name", header: "Player", sortable: true, rowHeader: true },
  { key: "position", header: "Position", sortable: true },
  { key: "ppg", header: "Points", sortable: true, numeric: true },
  { key: "apg", header: "Assists", sortable: true, numeric: true },
];

export function SearchAndSelection() {
  const [query, setQuery] = useState("");
  const [selected, setSelected] = useState<DataGridRowId[]>([]);

  return (
    <Stack gap={4} style={{ width: "100%" }}>
      <Field label="Search players">
        <SearchInput value={query} onValueChange={setQuery} />
      </Field>
      <DataGrid
        aria-label="Roster"
        rows={roster}
        columns={rosterColumns}
        getRowId={(p) => p.id}
        filter={query}
        selectionMode="multiple"
        selected={selected}
        onSelectedChange={setSelected}
        pageSize={5}
      />
    </Stack>
  );
}

Row details

renderRowDetail adds a full-width row under a row (master-detail), or nothing when it returns null. Controls in it are outside the arrow-key grid: Tab from the row moves into them. Grids with detail rows don't virtualize, so pair them with pageSize.

Jordan ReyesGuard18.47.1
Avery ChenForward15.22.4

Ankle sprain. Day to day, expected back for Friday's game.

Sam OkaforCenter12.91.8
Riley ParkGuard11.65.3
Morgan DiazForward9.82.9

Concussion protocol. Cleared for non-contact practice.

tsx
import { DataGrid, Text } from "@vjdesigns/vjdesigns-ui";

const roster = [
  { id: 1, name: "Jordan Reyes", position: "Guard", ppg: 18.4, apg: 7.1 },
  { id: 2, name: "Avery Chen", position: "Forward", ppg: 15.2, apg: 2.4 },
  { id: 3, name: "Sam Okafor", position: "Center", ppg: 12.9, apg: 1.8 },
  { id: 4, name: "Riley Park", position: "Guard", ppg: 11.6, apg: 5.3 },
  { id: 5, name: "Morgan Diaz", position: "Forward", ppg: 9.8, apg: 2.9 },
  { id: 6, name: "Casey Lin", position: "Guard", ppg: 8.7, apg: 4.4 },
  { id: 7, name: "Taylor Brooks", position: "Center", ppg: 7.5, apg: 1.1 },
];

const rosterColumns = [
  { key: "name", header: "Player", sortable: true, rowHeader: true },
  { key: "position", header: "Position", sortable: true },
  { key: "ppg", header: "Points", sortable: true, numeric: true },
  { key: "apg", header: "Assists", sortable: true, numeric: true },
];

const injuries: Record<number, string> = {
  2: "Ankle sprain. Day to day, expected back for Friday's game.",
  5: "Concussion protocol. Cleared for non-contact practice.",
};

export function RowDetails() {
  return (
    <DataGrid
      aria-label="Roster with injury notes"
      rows={roster}
      columns={rosterColumns}
      getRowId={(p) => p.id}
      pageSize={5}
      renderRowDetail={(p) => (injuries[p.id] ? <Text size="sm">{injuries[p.id]}</Text> : null)}
    />
  );
}

Large data

100,000 rows. Above 100 rows the grid renders only the rows in view (virtualize="auto"), so scrolling, sorting, searching and selecting stay instant. Screen readers still hear the full count and each row's position. Search ignores accents: "zoe" finds "Zoë". Ctrl+End jumps to the last row.

Jordan Reyes 1Guard00
Quinn Novak 2Forward3.71.1
Casey Alvarez 3Center7.42.2
Avery Nakamura 4Guard11.13.3
José Okafor 5Forward14.84.4
Drew Larsen 6Center18.55.5
Sam Ibáñez 7Guard22.26.6
Zoë Chen 8Forward25.97.7
Jamie Patel 9Center29.68.8
Riley Silva 10Guard3.39.9
Jordan Reyes 11Forward71
Quinn Novak 12Center10.72.1
Casey Alvarez 13Guard14.43.2
Avery Nakamura 14Forward18.14.3
José Okafor 15Center21.85.4
Drew Larsen 16Guard25.56.5
Sam Ibáñez 17Forward29.27.6
Zoë Chen 18Center2.98.7
Jamie Patel 19Guard6.69.8
Riley Silva 20Forward10.30.9
Jordan Reyes 21Center142
Quinn Novak 22Guard17.73.1
Casey Alvarez 23Forward21.44.2
Avery Nakamura 24Center25.15.3
José Okafor 25Guard28.86.4
Drew Larsen 26Forward2.57.5
Sam Ibáñez 27Center6.28.6
Zoë Chen 28Guard9.99.7
Jamie Patel 29Forward13.60.8
Riley Silva 30Center17.31.9
tsx
import { useState } from "react";
import { DataGrid, Field, SearchInput, Stack } from "@vjdesigns/vjdesigns-ui";

const firstNames = ["Jordan", "Avery", "Sam", "Riley", "Casey", "Drew", "Jamie", "Quinn", "José", "Zoë"];
const lastNames = ["Reyes", "Chen", "Okafor", "Novak", "Patel", "Larsen", "Alvarez", "Silva", "Ibáñez", "Nakamura"];
const positions = ["Guard", "Forward", "Center"];

const lastNames = ["Reyes", "Chen", "Okafor", "Novak", "Patel", "Larsen", "Alvarez", "Silva", "Ibáñez", "Nakamura"];
const positions = ["Guard", "Forward", "Center"];

const positions = ["Guard", "Forward", "Center"];

const manyPlayers = Array.from({ length: 100_000 }, (_, i) => ({
  id: i + 1,
  name: `${firstNames[(i * 7) % firstNames.length]} ${lastNames[(i * 13) % lastNames.length]} ${i + 1}`,
  position: positions[i % positions.length],
  ppg: ((i * 37) % 300) / 10,
  apg: ((i * 11) % 100) / 10,
}));

const sizedColumns = [
  { key: "name", header: "Player", sortable: true, rowHeader: true, width: "40%" },
  { key: "position", header: "Position", sortable: true },
  { key: "ppg", header: "Points", sortable: true, numeric: true },
  { key: "apg", header: "Assists", sortable: true, numeric: true },
];

export function LargeData() {
  const [query, setQuery] = useState("");

  return (
    <Stack gap={4} style={{ width: "100%" }}>
      <Field label="Search 100,000 players">
        <SearchInput value={query} onValueChange={setQuery} />
      </Field>
      <DataGrid
        aria-label="All players"
        rows={manyPlayers}
        columns={sizedColumns}
        getRowId={(p) => p.id}
        filter={query}
        selectionMode="multiple"
        maxHeight={400}
      />
    </Stack>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

Jordan ReyesGuard18.47.1
Avery ChenForward15.22.4
Sam OkaforCenter12.91.8
Riley ParkGuard11.65.3
Morgan DiazForward9.82.9
Casey LinGuard8.74.4
Taylor BrooksCenter7.51.1
tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

Usage notes

Keyboard: the grid is one Tab stop. Arrow keys move between cells (mirrored in RTL), Home / End go to the row's first or last cell, Ctrl+Home / Ctrl+End to the first or last cell of the grid, Page Up / Page Down move ten rows. On a header, Enter sorts (Shift+Enter adds a secondary sort). Space selects the row, Shift+click or Shift+Space selects a range, and Ctrl/⌘+A selects every row. A cell with a single button, link, or checkbox focuses it directly; for cells with several controls or a text field, Enter or F2 moves into the cell, Tab cycles inside it, and Escape returns to the grid.

Screen readers hear sort changes and filter result counts; the grid is a real <table role="grid"> with aria-sort, aria-selected, aria-rowcount, and aria-rowindex.

tsx
<DataGrid
  aria-label="Roster"
  rows={players}
  columns={[
    { key: "name", header: "Player", sortable: true, rowHeader: true },
    { key: "ppg", header: "PPG", sortable: true, numeric: true },
  ]}
  selectionMode="multiple"
  pageSize={10}
/>

API reference

DataGrid

New in 1.5.0
DataGrid props
PropTypeDefault
rowsRequired

The data. Sorting, filtering, and paging work on a copy; this array is never mutated.

readonly T[]—
columnsRequired

The columns, in display order.

readonly DataGridColumn<T>[]—
getRowId

A stable id for each row.

(row: T) => DataGridRowId(row) => row.id
getRowLabel

Readable name of a row, for its checkbox ("Select Jordan Reyes"). Defaults to the rowHeader column's value, then the first column's.

(row: T) => string—
aria-label

Accessible name of the grid. Required unless aria-labelledby is given.

string—
aria-labelledby

Id of a visible heading that names the grid.

string—
aria-describedby

Id of text that describes the grid.

string—
sort

Active sort, primary first (controlled).

DataGridSortItem[]—
defaultSort

Initial sort when uncontrolled.

DataGridSortItem[][]
onSortChange

Called with the next sort.

(sort: DataGridSortItem[]) => void—
multiSort

Shift+click (or Shift+Enter) on a header adds it as a secondary sort.

booleantrue
filter

Search text: rows are kept when their filterable columns contain every word (case- and diacritic-insensitive). Render your own search field (e.g. SearchInput) and pass its text here.

string—
selectionMode

How rows are selected.

"none""single""multiple""none"
selected

Selected row ids (controlled).

DataGridRowId[]—
defaultSelected

Initially selected row ids when uncontrolled.

DataGridRowId[][]
onSelectedChange

Called with the next selected ids.

(selected: DataGridRowId[]) => void—
isRowSelectable

Rows that can't be selected (their checkbox is disabled).

(row: T) => boolean—
pageSize

Rows per page. Shows a footer with the range and Pagination. Without it, every row shows.

number—
virtualize

Render only the rows in view (plus a few above and below), so grids of 100,000+ rows scroll, sort, filter, and select without delay. "auto" turns it on when more than 100 rows show at once. While it's on, the body scrolls inside the grid (its height is maxHeight, 70% of the window by default) and the table uses fixed layout unless you set layout, so columns keep their widths while you scroll; give columns a width to size them. Screen readers still get the full count (aria-rowcount) and each row's position (aria-rowindex).

falsetrue"auto""auto"
page

Current page, starting at 1 (controlled).

number—
defaultPage

Initial page when uncontrolled.

number1
onPageChange

Called with the next page.

(page: number) => void—
manual

Server-side data: the grid doesn't sort, filter, or page rows itself. It shows them as given and reports sort, filter, and page changes for you to fetch. Pass rowCount for the total.

booleanfalse
rowCount

Total rows on the server, with manual.

numberrows.length
onRowActivate

Called when a row is activated: Enter on one of its cells, or a click on a non-interactive part of it.

(row: T) => void—
loading

Shows a loading state and marks the grid aria-busy.

booleanfalse
emptyState

Shown when there are no rows. Defaults to "No rows" (or "No matching rows" while filtering).

ReactNode—
density

Row height and padding.

"compact""comfortable""spacious""comfortable"
variant

Visual style.

"plain""striped""outline""outline"
hoverable

Highlight rows under the pointer.

booleantrue
stickyHeader

Keep the header row visible while scrolling.

booleantrue
maxHeight

Maximum height of the scrolling body (CSS length, or px as a number).

CSSProperties["maxHeight"]—
layout

Table layout. fixed makes column widths exact (content wraps or clips instead of widening a column).

"auto""fixed""auto" ("fixed" while virtualized)
tableStyle

Style for the <table> (for example a total width when columns are resized).

CSSProperties—
className

Class name for the outer frame.

string—
style

Style for the outer frame.

CSSProperties—
ref

Ref to the <table role="grid">.

Ref<HTMLTableElement>—
treegrid

Rows form a hierarchy (groups, a tree): the table becomes a role="treegrid" and each row takes the level and expanded from getRowProps.

booleanfalse
getRowProps

Per-row level, expanded state, and class name.

(row: T) => DataGridRowProps—
renderRowDetail

Content for a full-width row under a row (master-detail), or null for none. Its controls are outside the grid's arrow-key navigation: Tab from the row moves into them. A grid with detail rows doesn't virtualize, so pair it with pageSize for long lists.

(row: T) => ReactNode—
onRowsShown

Called with the rows the grid shows, sorted, filtered, and paged, in display order, whenever they change (to copy a cell range, or export exactly what's on screen).

(rows: readonly T[]) => void—
onVisibleRangeChange

Called with the range of shown rows (indexes into them, inclusive) that are rendered in view. With virtualization this follows scrolling, which is what "load more while scrolling" needs.

(range: { start: number; end: number; }) => void—

See what changed in each version in the Changelog.

Accessibility report

DataGrid targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabThe grid is one tab stop; Tab moves in and out of it.
Arrow keysMove between cells (mirrored right to left).
HomeEndFirst or last cell in the row.
Ctrl+HomeCtrl+EndFirst or last cell in the grid.
Page UpPage DownMove ten rows.
EnterOn a header: sorts by it (Shift+Enter adds a second sort). On a row: onRowActivate. In a cell with controls: moves into the cell.
F2Moves into a cell with several controls or a text field; Tab then cycles inside it.
EscapeReturns from inside a cell to the grid.
SpaceSelects the row (Shift+Space: a range).
Ctrl+A⌘+AMultiple selection: selects every row.

A cell with a single button, link or checkbox focuses that control directly. Above 100 rows only the rows in view are rendered; the focused row stays rendered while you scroll away, so focus is never lost, and Ctrl+End scrolls to the last row and focuses it.

Roles and states

Roles and states
ElementRoleStates and properties
<table>grid (treegrid with treegrid)aria-label, aria-rowcount (the full count, also while virtualized)
Header cellcolumnheaderaria-sort on the sorted column
Rowrowaria-rowindex (its position in the full list), aria-selected when rows are selectable, aria-level and aria-expanded from getRowProps in a treegrid
Detail rowrowA full-width cell under its row (renderRowDetail); Tab from the row moves into its controls
Cellgridcell / rowheaderThe rowHeader column names each row
Live regionstatusAnnounces sort changes and filter result counts

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)