Skip to content
synccn

Data Table

Sorting, search, column visibility, selection and paging.

M
Michaelmichael@example.com
OwnerActive$1,240
R
Rileyriley@example.com
AdminActive$860
J
Jaydenjayden@example.com
EditorInvited$0
0 of 3 selected

Installation

$ pnpm dlx shadcn@latest add @synccn/data-table

First time in this project? Connect synccn with one command.

Usage

import { DataTable } from "@/components/ui/data-table";<DataTable columns={columns} data={rows} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

DataTable

Sorting, global search, column visibility, row selection and pagination. columns: [{ key, header, cell?(row), sortable?, align?, hideable? }]

  • columnsrequired
    DataTableColumn<T>[]

    Column definitions.

  • datarequired
    T[]

    Rows.

  • pageSize
    number

    Default 5

    Rows per page.

  • searchKeys
    (keyof T & string)[]

    Fields the search box matches. Defaults to every column.

  • rowKey
    keyof T & string

    Default "id"

    Field that uniquely identifies a row.

  • toolbar
    React.ReactNode

    Extra controls next to the Columns menu.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Components

Helpers

npm packages

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA attributes: aria-label, aria-sort