Shadcn Data Grid

Custom Shadcn Data Grid for React and Tailwind CSS. A powerful TanStack Table v8 data grid with sorting, filtering, pagination, footer rows, drag-and-drop, virtualization, infinite scroll, and row pinning.

"use client"

import { useMemo, useState } from "react"

The current data-grid package ships the shared grid context, table renderers, pagination, column controls, drag-and-drop helpers, virtualization, infinite scroll, footer helpers, and row-pinning support. Footer components (DataGridTableFoot, DataGridTableFootRow, DataGridTableFootRowCell) and the DataGridTableRowPin toggle are exported from data-grid-table.tsx.

In the base build, data-grid-scroll-area.tsx is also included and exports DataGridScrollArea for dedicated scroll handling around sticky-header or wide tables.

Installation

pnpm dlx shadcn@latest add @reui/data-grid

Usage

import {
  DataGrid,
  DataGridContainer,
  DataGridPagination,
  DataGridTable,
  DataGridTableFootRow,
  DataGridTableFootRowCell,
} from "@/components/reui/data-grid"
const footer = (
  <DataGridTableFootRow>
    <DataGridTableFootRowCell colSpan={columns.length}>
      Showing {data.length} rows
    </DataGridTableFootRowCell>
  </DataGridTableFootRow>
)
 
const table = useReactTable({
  data,
  columns,
  getCoreRowModel: getCoreRowModel(),
})
 
return (
  <DataGrid
    table={table}
    recordCount={data.length}
    tableLayout={{ rowsPinnable: true }}
  >
    <DataGridContainer>
      <DataGridTable footerContent={footer} />
    </DataGridContainer>
    <DataGridPagination />
  </DataGrid>
)

Use DataGridTableRowPin inside a column definition to let users pin rows, swap in DataGridTableVirtual when you need virtualization or infinite scroll, and wrap sticky-header tables with DataGridScrollArea when you want the dedicated base scroll wrapper. When rows can be pinned or virtualized, provide a stable getRowId so row identity stays intact across reordering.

Examples

Cell Border

"use client"

import { useMemo, useState } from "react"

Dense Table

"use client"

import { useMemo, useState } from "react"

Light Table

"use client"

import { useMemo, useState } from "react"

Striped Table

"use client"

import { useMemo, useState } from "react"

Auto Width

"use client"

import { useMemo, useState } from "react"

Row Selection

"use client"

import { useEffect, useMemo, useState } from "react"

Expandable Row

"use client"

import { useMemo, useState } from "react"

Sub Data Grid

"use client"

import { useMemo, useState } from "react"

Column Icons

"use client"

import { useMemo, useState } from "react"

Sortable Columns

"use client"

import { useMemo, useState } from "react"

Movable Columns

"use client"

import { useMemo, useState } from "react"

Draggable Columns

"use client"

import { useMemo, useState } from "react"

Draggable Rows

"use client"

import { useMemo, useState } from "react"

Resizable Columns

"use client"

import { useMemo, useState } from "react"

Pinnable Columns

"use client"

import { useMemo, useState } from "react"
"use client"

import { useMemo, useState } from "react"

Column Controls

"use client"

import { useMemo, useState } from "react"

Card Container

"use client"

import { useMemo, useState } from "react"

Column Visibility

"use client"

import { useMemo, useState } from "react"

Loading Skeleton

"use client"

import { useMemo, useState } from "react"

CRUD

"use client"

import { useMemo, useState } from "react"

CRUD in Frame

"use client"

import { useMemo, useState } from "react"
"use client"

import { useMemo, useState } from "react"
"use client"

import { useMemo, useState } from "react"
"use client"

import { useMemo, useState } from "react"

Infinite Scroll (Local)

"use client"

import { useMemo, useState } from "react"

Infinite Scroll (Remote)

"use client"

import { useCallback, useEffect, useMemo, useRef, useState } from "react"

Row Pinning

"use client"

import { useMemo, useState } from "react"

API Reference

DataGrid

The root component that provides the table context.

PropTypeDefaultDescription
tableTable<TData>-Required. The TanStack Table instance.
recordCountnumber-Required. Total number of records.
isLoadingbooleanfalseWhether the table is in a loading state.
loadingMode"skeleton" | "spinner""skeleton"The visual style of the loading state.
loadingMessageReactNode | string"Loading..."Message to display when loadingMode is "spinner".
fetchingMoreMessageReactNode | stringloadingMessageMessage to display while DataGridTableVirtual is fetching more rows.
allRowsLoadedMessageReactNode | string"All records loaded"Message to display when virtual infinite scroll reaches the end.
emptyMessageReactNode | string"No data available"Message to display when the table is empty.
onRowClick(row: TData) => void-Callback function triggered when a row is clicked.
tableLayoutDataGridTableLayout-Configuration for table layout and features.
tableClassNamesDataGridTableClassNames-Custom CSS classes for various table parts.
classNamestring-Additional CSS classes for the root grid component.

DataGridTableLayout

Configuration object for the table's behavior and appearance.

PropertyTypeDefaultDescription
densebooleanfalseWhether to use dense padding for cells.
cellBorderbooleanfalseWhether to show vertical borders between cells.
rowBorderbooleantrueWhether to show horizontal borders between rows.
rowRoundedbooleanfalseWhether to add rounded corners to rows.
strippedbooleanfalseWhether to use zebra-striping for rows.
headerBackgroundbooleantrueWhether to show a background color for the header.
headerBorderbooleantrueWhether to show a border below the header.
headerStickybooleanfalseWhether the header should be sticky during scroll.
width"auto" | "fixed""fixed"The table layout algorithm (table-auto vs table-fixed).
columnsVisibilitybooleanfalseEnables column visibility toggling.
columnsResizablebooleanfalseEnables column resizing.
columnsPinnablebooleanfalseEnables column pinning.
columnsMovablebooleanfalseEnables moving columns via menu.
columnsDraggablebooleanfalseEnables drag-and-drop for columns.
rowsDraggablebooleanfalseEnables drag-and-drop for rows.
rowsPinnablebooleanfalseEnables row pinning (top/bottom).

DataGridTableClassNames

Custom CSS classes for different parts of the table.

PropertyTypeDefaultDescription
basestring-CSS classes for the <table> element.
headerstring-CSS classes for the <thead> element.
headerRowstring-CSS classes for header rows.
headerStickystring-CSS classes for sticky header state.
bodystring-CSS classes for the <tbody> element.
bodyRowstring-CSS classes for body rows.
footerstring-CSS classes for the <tfoot> element.
edgeCellstring-CSS classes for the first and last cells in a row.

DataGridContainer

A scrollable container for the table.

PropTypeDefaultDescription
borderbooleantrueWhether to show a border around the container.
classNamestring-Additional CSS classes for the container.

DataGridScrollArea

Dedicated scroll wrapper for wide grids and sticky headers.

PropTypeDefaultDescription
childrenReactNode-Required. The grid content to wrap.
orientation"horizontal" | "vertical" | "both""both"Which scrollbars to render.
classNamestring-Additional CSS classes for the wrapper.

DataGridTable

The component that renders the actual HTML table. It automatically handles data rendering, loading states (skeletons/spinners), empty states, footer rows, and pinned rows when rowsPinnable is enabled on the parent DataGrid.

PropTypeDefaultDescription
footerContentReactNode-Optional footer content rendered inside <tfoot>.
renderHeaderbooleantrueWhether to render the table header.

DataGridPagination

The component for table pagination controls.

PropTypeDefaultDescription
sizesnumber[][5, 10, 25, 50, 100]Array of available page sizes.
sizesLabelstring"Show"Label for the page size selector.
sizesDescriptionstring"per page"Description following the page size selector.
rowsPerPageLabelstring"Rows per page"Accessible label for the rows per page selector.
infostring"{from} - {to} of {count}"Template for displaying record info.
morebooleanfalseWhether to show ellipsis for more pages.
moreLimitnumber5The number of page buttons to show before truncating.
previousPageLabelstring"Go to previous page"Accessible label for the previous page button.
nextPageLabelstring"Go to next page"Accessible label for the next page button.
ellipsisTextstring"..."Text to display for the ellipsis button.
classNamestring-Additional CSS classes for the pagination container.

DataGridColumnHeader

A flexible column header component with built-in support for sorting, pinning, and moving columns.

PropTypeDefaultDescription
columnColumn<TData, TValue>-Required. The TanStack Column instance.
titlestring-The title to display in the header.
iconReactNode-Optional icon to display next to the title.
filterReactNode-Optional filter component to display in the header menu.
visibilitybooleanfalseWhether to include column visibility controls in the menu.

DataGridColumnFilter

A popover-based multi-select filter for columns.

PropTypeDefaultDescription
columnColumn<TData, TValue>-The TanStack Column instance to filter.
titlestring-The title for the filter trigger and placeholder.
optionsArray<{ label: string, value: string, icon?: ComponentType }>-Required. The list of options to filter by.

DataGridColumnVisibility

A dropdown component to toggle column visibility.

PropTypeDefaultDescription
tableTable<TData>-Required. The TanStack Table instance.
triggerReactElement-Required. The trigger element for the visibility menu.

DataGridTableDnd

Used for enabling column drag-and-drop reordering with optional footer rendering.

PropTypeDefaultDescription
handleDragEnd(event: DragEndEvent) => void-Required. Callback triggered when a column drag operation ends.
footerContentReactNode-Optional footer content rendered inside <tfoot>.

DataGridTableDndRows

Used for enabling row drag-and-drop reordering with optional footer rendering.

PropTypeDefaultDescription
dataIdsUniqueIdentifier[]-Required. Array of unique identifiers for the current page data.
handleDragEnd(event: DragEndEvent) => void-Required. Callback triggered when a row drag operation ends.
footerContentReactNode-Optional footer content rendered inside <tfoot>.

DataGridTableVirtual

A virtualized table renderer using @tanstack/react-virtual for row virtualization, infinite scroll, optional footer rows, and pinned rows when rowsPinnable is enabled. The wrapper manages row count and the scroll element for you, while virtualizerOptions lets you customize the underlying TanStack Virtual instance.

PropTypeDefaultDescription
heightnumber | string-Optional fixed height when not using an outer scroll container.
estimateSizenumber48Estimated row height in pixels for the virtualizer.
overscannumber10Number of rows to render outside the visible area.
footerContentReactNode-Optional footer content rendered inside <tfoot>.
renderHeaderbooleantrueWhether to render the table header.
onFetchMore() => void-Callback triggered when user scrolls near the bottom.
isFetchingMoreboolean-Whether additional data is currently being loaded.
hasMoreboolean-Whether there are more records available to fetch.
fetchMoreOffsetnumber0How many rows before the end should trigger onFetchMore.
virtualizerOptionsDataGridTableVirtualizerOptions<TData>-Optional passthrough for TanStack Virtual settings like enabled, getItemKey, measureElement, rangeExtractor, and onChange.

DataGridTableRowPin

A pin/unpin toggle button for use in column definitions to enable row pinning.

PropTypeDefaultDescription
rowRow<TData>-Required. The TanStack Table row instance.

DataGridTableFoot

Wrapper component for the table footer (<tfoot>).


DataGridTableFootRow

A row inside the table footer.


DataGridTableFootRowCell

A cell inside a footer row.

PropTypeDefaultDescription
colSpannumber-Column span for the footer cell.
classNamestring-Additional CSS classes.
childrenReactNode-Content of the footer cell.

More Shadcn Data Grid components

Browse 29 production-ready Shadcn Data Grid components for dashboards, forms, and product UI. These examples use Base UI primitives from @base-ui/react and stay fully compatible with Shadcn Create so radius, color, and typography match your configured theme.

Browse all 29 Shadcn Data Grid components for copy-ready layouts, dashboards, and forms built with Tailwind CSS in the ReUI library.