• Docs
  • Components
  • Blocks
  • Admin
CtrlK
Get Started
  • Introduction
  • Setup
  • CLI
  • VS Code Extension
  • Figma Code Connect
  • MCP Server
  • llms.txt
  • Changelog
Foundations
  • Design Tokens
  • Theming & Modes
  • Semantic Colors
  • Spacing
  • Typography
Testing
  • Test Guide
  • Performance Tests
  • Visual Regression
Components
  • Accordion
  • Activity Feed
  • Alert
  • Avatar
  • Badge
  • Breadcrumbs
  • Button
  • Card
  • Carousel
  • Checkbox
  • Collapsible
  • Combobox
  • Command Palette
  • Context Menu
  • Date Picker
  • Dialog
  • Dropdown Menu
  • File Upload
  • Hover Card
  • Input
  • Kbd
  • Label
  • Menubar
  • Metric Card
  • Multi Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Quick Actions
  • Radio
  • Rating
  • Resizable
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Skeleton
  • Slider
  • Spinner
  • Split Button
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree View
Blocks
  • Activity Feed
  • App Shell
  • Authentication Block
  • Benefits Section
  • Cta Section
  • Data Table
  • Empty State
  • Faq Section
  • Feature Grid Section
  • Footer Section
  • Hero Section
  • Kpi Dashboard
  • Kpi Strip
  • Link Card
  • Metric Card
  • Navigation Header
  • Pagination Footer
  • Pricing Table
  • Quick Actions
  • Settings Screen
Resources
  • API Reference
Cta SectionEmpty State
Cta SectionEmpty State
Cta SectionEmpty State

Data Table

A complete table setup for data-heavy screens.

Default Data Table

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Brownalice@example.comAdmin
Charlie Wilsoncharlie@example.comUser

Code Examples

import { DataTable } from "@fragment_ui/blocks";

const data = [
  { id: 1, name: "John Doe", email: "john@example.com" },
  { id: 2, name: "Jane Smith", email: "jane@example.com" },
];

const columns = [
  {
    id: "name",
    header: "Name",
    accessor: (row) => row.name,
    sortable: true,
  },
  {
    id: "email",
    header: "Email",
    accessor: (row) => row.email,
    sortable: true,
  },
];

<DataTable
  data={data}
  columns={columns}
  pageSize={10}
  searchable={true}
  searchPlaceholder="Search users..."
  onRowClick={(row) => console.log(row)}
/>

Props

  • data - Array of data objects (required)
  • columns - Array of column definitions with id, header, accessor, and optional sortable (required)
  • pageSize - Number of items per page (default: 10)
  • searchable - Enable search functionality (default: true)
  • searchPlaceholder - Search input placeholder (default: "Search...")
  • onRowClick - Callback when row is clicked (optional)
  • className - Additional CSS classes

Features

  • Sortable columns
  • Search/filter functionality
  • Pagination with page info
  • Clickable rows
  • Responsive design
  • Empty state handling
  • Fully accessible

Install

npx shadcn@latest add /r/data-table.json

Accessibility

Data table includes proper ARIA attributes, keyboard navigation for sorting, and is fully accessible for screen readers. Compliant with WCAG 2.1.