Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Data Table

    A table you can use as it is, built on TanStack Table: sortable columns, row selection, search, a column menu, pagination, and loading and empty states. Define columns the way shadcn's data table examples do.

    Install

    npx shadcn@latest add @nelumbo/data-table

    Team

    Click a header to sort (again to reverse, once more to clear). Tick rows to get the selection bar; the select-all box shows a dash when only some of the page is selected. Search nonsense such as “zzz” to see the empty state, and use the switches to try loading and compact rows.

    Actions
    Maya Kowalski
    maya.kowalski@nelumbo.testDesignerActive$250.00
    Kenji Watanabe
    kenji.watanabe@nelumbo.testEngineerSuspended$8,169.37
    Léa Martin
    lea.martin@nelumbo.testEngineerActive$7,088.74
    Omar Haddad
    omar.haddad@nelumbo.testEngineerInvited$6,008.11
    Sofía Ramírez
    sofia.ramirez@nelumbo.testEngineerActive$4,927.48
    Tomás Novák
    tomas.novak@nelumbo.testResearcherActive$3,846.85
    Aisha Bello
    aisha.bello@nelumbo.testWriterActive$2,766.22
    Ravi Iyer
    ravi.iyer@nelumbo.testAnalystSuspended$1,683.00
    Noor Bello
    noor.bello@nelumbo.testDesignerActive$602.37
    Elif Nair
    elif.nair@nelumbo.testProduct managerInvited$8,521.74
    Rows per page
    1–10 of 48

    Empty

    With no rows, the table shows an empty state. Pass emptyState for your own.

    Nothing here yet

    There are no rows to show.

    Usage

    import type { ColumnDef } from "@tanstack/react-table"import { DataTable, DataTableColumnHeader } from "@/components/ui/data-table"​type Member = { id: string; name: string; email: string; amount: number }​const columns: ColumnDef<Member>[] = [  {    accessorKey: "name",    header: ({ column }) => <DataTableColumnHeader column={column} title="Name" />,  },  { accessorKey: "email", header: "Email", enableSorting: false },  {    accessorKey: "amount",    meta: { align: "end" },    header: ({ column }) => <DataTableColumnHeader column={column} title="Amount" />,    cell: ({ row }) => <span className="tabular-nums">{money.format(row.original.amount)}</span>,  },]​<DataTable  aria-label="Team members"  columns={columns}  data={members}  getRowId={(m) => m.id}  selectable  getRowLabel={(m) => m.name}  loading={isLoading}  bulkActions={({ rows, clear }) => (    <Button size="sm" variant="ghost" onClick={() => { remove(rows); clear() }}>Remove</Button>  )}/>​// Define columns outside the component (or memoize them), like any TanStack table.// Format numbers and dates with a fixed locale so server and client agree.

    Props

    PropTypeDefaultNotes
    columnsColumnDef<TData>[]TanStack column definitions
    dataTData[]
    getRowId(row, index) => stringindexStable ids keep selection through sorting and new data
    selectable / getRowLabelboolean / (row) => stringfalseCheckbox column; getRowLabel names each box
    onSelectionChange(rows) => voidSelected rows that match the search
    bulkActions({ rows, table, clear }) => ReactNodeButtons shown in the selection bar
    search / searchPlaceholderboolean / stringtrue / "Search"Global filter over every column
    columnMenubooleantrueThe Columns menu
    toolbarReactNodeExtra toolbar content, before the Columns menu
    pagination / pageSize / pageSizeOptionsboolean / number / number[]true / 10 / [5, 10, 20, 50]
    initialSorting / initialColumnVisibilitySortingState / VisibilityState
    loadingbooleanfalseSkeleton rows, aria-busy
    emptyStateReactNodeReplaces the default empty state
    density / stickyHeader"comfortable" / falseAs Table
    column meta{ align, label, className, headerClassName }Alignment, menu name and cell classes
    DataTableColumnHeader{ column, title }Sort button for a header; the cell gets aria-sort
    DataTablePagination, DataTableViewOptions, selectColumnThe parts, for tables you wire up yourself