Skip to content

Data grid

A spreadsheet-style grid: pinned first column, sortable and reorderable columns, inline cell editing (a bottom sheet on phones), selection and add-row.

The first column is pinned and stays in view while the others scroll under it. rows draw in the order given until a sort is chosen; with no rows the grid draws nothing, so show an @khaeli/empty state in its place. Below 768px the same props draw a list instead of a grid: a tap edits the row's first editable cell in a bottom sheet, and a long press opens a menu of every editable column.

Sortable columns

Harbor mobile app
To do
15 Jan 2027
€73,000
Atlas redesign
In progress
4 Dec 2026
€48,000
Orchard API
In progress
18 Dec 2026
€64,000
Billing migration
In review
24 Nov 2026
€122,500
Lumen help centre
Done
30 Oct 2026
€18,500
5 projects
€326,000
Harbor mobile app
15 Jan 2027€73,000
To do
Atlas redesign
4 Dec 2026€48,000
In progress
Orchard API
18 Dec 2026€64,000
In progress
Billing migration
24 Nov 2026€122,500
In review
Lumen help centre
30 Oct 2026€18,500
Done
5 projects

Inline editing

Task
Status
Estimate (days)
Due
Reference
Write the migration guide
In review
3
24 Nov 2026
T-318
Add keyboard shortcuts to the editor
In progress
5
2 Dec 2026
T-317
Fix the export time zone
To do
2
No date
T-314
3 tasks
Write the migration guide
324 Nov 2026
In review
Add keyboard shortcuts to the editor
52 Dec 2026
In progress
Fix the export time zone
2T-314
To do
3 tasks

Row selection

Invoice
Project
Due
Amount
INV-1042
Atlas redesign
30 Nov 2026
€4,800
INV-1041
Billing migration
24 Nov 2026
€12,250
INV-1040
Harbor mobile app
15 Nov 2026
€7,300
INV-1039
Orchard API
8 Nov 2026
€9,100
1 of 4 selected
INV-1042
30 Nov 2026€4,800
Atlas redesign
INV-1041
24 Nov 2026€12,250
Billing migration
INV-1040
15 Nov 2026€7,300
Harbor mobile app
INV-1039
8 Nov 2026€9,100
Orchard API
1 of 4 selected

Manual order

Step
Team
Freeze the release branch
Platform
Publish the release notes
Product
Run the database migration
Platform
Announce release 4.2.0
Marketing
4 steps
Freeze the release branch
Platform
Publish the release notes
Product
Run the database migration
Platform
Announce release 4.2.0
Marketing
4 steps

Adding a row

Release
Channel
4.2.0
Stable
4.3.0-beta.1
Beta
2 releases
4.2.0
Stable
4.3.0-beta.1
Beta
2 releases

Installation

npx shadcn@latest add @khaeli/data-grid

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @dnd-kit/core ^6.3.1
  • @dnd-kit/sortable ^10.0.0
  • @dnd-kit/utilities ^3.2.2
  • @keyline-icons/react ^2.2.0

Keyboard

Tab
Enters at the sort buttons (one tab stop for the header row), then at the active cell. Inside the body Tab and Shift+Tab move one cell at a time, wrapping from row to row, and leave the grid only from its last and first cell.
EnterSpace
On a sort button: sorts ascending, then descending, then returns to the order given. The column header takes aria-sort and the change is read out, as in Sorted by Project, ascending.
ArrowLeftArrowRightHomeEnd
On a sort button: move to the previous, next, first or last sortable column. On a cell: the arrows move one cell, Home and End go to the first and last cell of the row.
ArrowUpArrowDown
Move the active cell one row.
EnterF2
Open the editor of an editable cell. A read-only cell is marked aria-readonly and does not open.
Any character
Opens the editor with that character in place of the old value. In a date cell it opens the editor with the date kept.
BackspaceDelete
Open the editor empty, ready to clear the cell with Enter. A required column ignores them.
EnterTabEscape
In an editor: Enter saves and returns to the cell, Tab saves and moves to the next cell, Escape discards. An empty required cell stays open with a message such as Task is required. A select editor filters as you type, ArrowUp and ArrowDown move the highlight and Enter chooses; a date editor takes YYYY-MM-DD or a day from its calendar.
Shift+Space
With selectable: selects the focused cell's row, or deselects it. Focus stays on the cell and no editor opens.
Alt+ArrowUpAlt+ArrowDown
With onReorder and no sort chosen: move the focused cell's row one place and keep focus on the cell. The grip is for pointers and is not a tab stop.
Escape
On a cell: removes the active ring; focus stays on the cell. On a cell of the new row: discards the row and moves focus to the button that adds one.
TabEnterSpace
In the list below 768px: every row is a tab stop, and Enter or Space opens the sheet for its first editable cell with focus in the field.
Context menu key
In the list: opens the row's menu with focus on its first entry. ArrowUp and ArrowDown move through the entries and wrap, Home and End go to the first and last, and Enter opens the sheet for that column. Escape or Tab closes the menu and returns focus to the row.

Accessible name

  • The grid takes its name from aria-label, which is required.
  • A sort button is named Sort by and the header, then Sort by Project, currently ascending. When a header is not plain text, give the column a sortLabel.
  • With selectable, the header checkbox is named Select all rows and every row's checkbox Select row.
  • A row's grip is named Move and the text of its pinned cell, so keep that cell's text meaningful.
  • An editor's input is named by its column's header, as in Task or Estimate (days), on the desktop and in the phone sheet. A placeholder is a hint only.
  • On a phone the sheet is a dialog named Edit and the column's header, with buttons named Cancel and Save.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/data-grid.json