Skip to content

Data table

Shows rows with search, filters, sorting, selection, and pagination.

Projects

ProjectOwnerStatusOpen tasksBudget
Studio NorthMaya ChenIn progress12$24,800
AtlasSam RiveraReview8$18,500
Field NotesJo ParkPublished3$9,600
SignalMaya ChenIn progress18$42,000
MorrowAlex KimReview5$13,200
OrbitSam RiveraPublished21$31,800
GrainJo ParkOn hold0$6,800
HorizonAlex KimIn progress14$27,300
Showing 1–8 of 24 rows
data-table-demo.tsx

Installation

The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.

Column filters

A filtered column also needs sortValue.

Invoices

Region
Status
InvoiceCustomerRegionStatusAmount
INV-1048Acme StudioAmericasPaid$2,400
INV-1049Northstar LabsEuropeOverdue$1,180
INV-1050Fieldwork Co.Asia PacificPending$3,750
INV-1051Meridian HealthAmericasPaid$890
INV-1052PaperplaneEuropePending$1,560
INV-1053Atlas WorksAsia PacificOverdue$4,200
INV-1054GoodsideAmericasPaid$640
Showing 1–7 of 22 rows
data-table-column-filters-demo.tsx

Resizable columns and row actions

Set width on a column to set its starting width. onRowAction runs when a user clicks a row or presses Enter on it.

Support tickets

TicketTitleRequesterPriority
T-311Export fails for reports with more than 10,000 rowsMaya ChenHigh
T-312Add a dark theme to the invoice PDFSam RiveraLow
T-313Password reset email arrives lateJo ParkMedium
T-314Team invite link expires too soonAlex KimMedium
Showing 1–4 of 4 rows
Select a row to open the ticket.
data-table-resizable-demo.tsx

API reference

vip/ui adds or changes the props below. For all other props, see React Aria Table (opens in a new tab).

DataTable

label: stringRequired
Names the table and its search and pagination controls.
rows: readonly T[]Required
All the rows. The table searches, filters, sorts, and pages them in the browser.
columns: readonly DataTableColumn<T>[]Required
Column definitions. The first column labels each row.
getRowId: (row: T) => KeyRequired
Returns a unique, stable key for each row.
getSearchText: (row: T) => string
Shows a search field. Return all the text that search can find in a row.
pageSize: number = 5
Rows on each page.
selectable: boolean = true
Shows a selection checkbox in each row. Select all selects only the rows on the current page.
selectedKeys: Iterable<Key>
The selected row keys, controlled. The selection stays when the page, search, or filters change.
defaultSelectedKeys: Iterable<Key>
The row keys that are selected at first, uncontrolled. Without it, no rows are selected.
onSelectionChange: (keys: Set<Key>) => void
Receives selected row keys, including keys on other pages.
disabledKeys: Iterable<Key>
Rows that cannot be selected or focused.
onRowAction: (key: Key) => void
Called when a user clicks a row or presses Enter on it. The checkbox still selects the row.
resizable: boolean = false
Adds a resize handle to each column header.

DataTableColumn

id: stringRequired
A stable key for the column.
header: stringRequired
The visible column header. A column filter uses it as its label.
cell: (row: T) => ReactNodeRequired
Renders the cell for a row.
sortValue: (row: T) => string | number
Turns on sorting for the column. Return a string or a number. Column filters use this value too.
align: "start" | "end" = "start"
Aligns the header and cells. Use end for numbers.
width: number | string
Starting width in pixels, a percentage, or a fraction such as "2fr".
minWidth: number | string
Smallest width the column can resize to.
filter: { type: "text" } | { type: "select"; options: readonly SelectOption[] }
Adds a text or single-choice filter for a column with sortValue. Filters combine with search before sorting and pagination.