Table

Powerful responsive data table with sticky headers, smooth scrolling, sorting, and pagination.

Loading...

Installation

npx shadcn@latest add @scrollxui/table 

Usage

// Basic Usage
import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from '@/components/ui/table';
<Table>
  <TableCaption>A list of your recent invoices.</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead className='w-25'>Invoice</TableHead>
      <TableHead>Status</TableHead>
      <TableHead>Method</TableHead>
      <TableHead className='text-right'>Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell className='font-medium'>INV001</TableCell>
      <TableCell>Paid</TableCell>
      <TableCell>Credit Card</TableCell>
      <TableCell className='text-right'>$250.00</TableCell>
    </TableRow>
  </TableBody>
</Table>
// DataTable Example
<DataTable
  columns={[
    { accessorKey: 'invoice', header: createSortableHeader('Invoice') },
    { accessorKey: 'status', header: 'Status' },
    { accessorKey: 'method', header: 'Method' },
    {
      accessorKey: 'amount',
      header: 'Amount',
      cell: ({ row }) => `$${row.original.amount}`,
    },
  ]}
  data={[
    { invoice: 'INV001', status: 'Paid', method: 'Credit Card', amount: 250 },
    { invoice: 'INV002', status: 'Pending', method: 'PayPal', amount: 150 },
  ]}
  pageSize={5}
  searchable
  pagination
/>

Examples


DataTable

Loading...

Scrollable

Loading...

Checkbox

Loading...

API Reference

Table

Powerful responsive data table with sticky headers, smooth scrolling, sorting, and pagination.

Props

PropertyTypeDefaultDescription
columnsColumnDef<any>[][]
Defines the table columns and their configuration.
dataany[][]
Array of data objects to display in the table.
enableScrollbooleanfalse
Enables vertical and horizontal scrolling with sticky header.
scrollHeightstring | number"400px"
Max height for vertical scroll when scrolling is enabled.
enableAnimationsbooleanfalse
Adds smooth animations for row transitions.
staggerDelaynumber0.05
Delay between row animations when animating rows.
paginationbooleanfalse
Enables pagination controls for the table.
showPageSizeSelectorbooleantrue
Shows dropdown to select rows per page when pagination is enabled.
rowClassNamestring
Custom class name applied to each table row.
cellClassNamestring
Custom class name applied to each table cell.
emptyMessagestring | ReactNode"No results"
Message displayed when there are no rows to show.
onRowClick(rowData: any) => void
Callback fired when a row is clicked, receives row data.
tableClassNamestring
Custom class name applied to the table element.
...propsHTMLDivElement attributes
Supports all standard div props and events.

Built withby Ahdeetai.