Skip to main content

Table

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Table component provides a flexible and accessible way to display tabular data. Built with semantic HTML elements and responsive design, it supports sorting, filtering, and various data presentation patterns. Perfect for data grids, user lists, product catalogs, and any structured information display.

Basic Usage

First NameLast NameUsername
JohnDoe@johndoe
SallyRoss@sallyross
JaneDoe@janedoe
BobRoss@bobross
A list of your recent invoices.
InvoiceStatusMethodAmount
INV001PaidCredit Card$250.00
INV002PendingPayPal$150.00
INV003UnpaidBank Transfer$350.00
INV004PaidCredit Card$450.00
Total$1,200.00

User Management Table

UserRoleStatusActions
JD
John Doe
john@example.com
Admin
Active
JS
Jane Smith
jane@example.com
Editor
Active
MJ
Mike Johnson
mike@example.com
Viewer
Inactive
SW
Sarah Wilson
sarah@example.com
Editor
Pending

Sortable Table

Alice Johnson28Engineering$75,000
Bob Smith34Marketing$65,000
Carol Davis29Design$70,000
David Wilson31Engineering$80,000

Table with Search and Filter

ProductCategoryPriceStock
Laptop ProElectronics$129915
Wireless MouseElectronics$2950
Office ChairFurniture$1998
Desk LampFurniture$4925
NotebookStationery$12100
Pen SetStationery$1575
Showing 6 of 6 products

Selectable Rows

TaskStatusPriority
Task 1CompletedHigh
Task 2In ProgressMedium
Task 3PendingLow
Task 4CompletedHigh

Properties

Table

PropertyTypeDescription
classNamestringAdditional CSS classes for the table container.
childrenReactNodeTable content (header, body, footer, caption).

TableHeader

PropertyTypeDescription
classNamestringAdditional CSS classes for the table header.
childrenReactNodeHeader content (typically TableRow with TableHead cells).

TableBody

PropertyTypeDescription
classNamestringAdditional CSS classes for the table body.
childrenReactNodeBody content (TableRow elements with TableCell).

TableFooter

PropertyTypeDescription
classNamestringAdditional CSS classes for the table footer.
childrenReactNodeFooter content (typically summary rows).

TableRow

PropertyTypeDescription
classNamestringAdditional CSS classes for the table row.
childrenReactNodeRow content (TableHead or TableCell elements).

TableHead

PropertyTypeDescription
classNamestringAdditional CSS classes for the header cell.
childrenReactNodeHeader cell content.
colSpannumberNumber of columns the cell should span.
rowSpannumberNumber of rows the cell should span.

TableCell

PropertyTypeDescription
classNamestringAdditional CSS classes for the table cell.
childrenReactNodeCell content.
colSpannumberNumber of columns the cell should span.
rowSpannumberNumber of rows the cell should span.

TableCaption

PropertyTypeDescription
classNamestringAdditional CSS classes for the table caption.
childrenReactNodeCaption text.

Accessibility

The Table component includes comprehensive accessibility features:

  • Semantic HTML - Uses proper table elements (table, thead, tbody, th, td)
  • Screen Reader Support - Proper table structure announced to screen readers
  • Keyboard Navigation - Tab navigation through interactive elements
  • ARIA Support - Can be enhanced with ARIA labels and descriptions
  • Responsive Design - Horizontal scrolling on smaller screens
  • Focus Management - Clear focus indicators for interactive elements

Common Use Cases

The Table component is perfect for:

  • Data Grids - Displaying structured data with sorting and filtering
  • User Management - User lists with actions and status indicators
  • Product Catalogs - E-commerce product listings with details
  • Financial Data - Invoices, transactions, and financial reports
  • Analytics Dashboards - Metrics and performance data
  • Content Management - Articles, posts, and content listings
  • System Logs - Error logs, activity feeds, and system events

Best Practices

  1. Semantic Structure - Use proper table elements for accessibility
  2. Clear Headers - Provide descriptive column headers
  3. Consistent Alignment - Align numeric data to the right, text to the left
  4. Row Identification - Use unique keys for each row
  5. Loading States - Show loading indicators for async data
  6. Empty States - Provide helpful messages when no data is available
  7. Mobile Responsiveness - Consider horizontal scrolling or alternative layouts
  8. Performance - Implement pagination or virtualization for large datasets