Skip to main content

Data Table

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The DataTable component provides a powerful, feature-rich table for displaying and managing large datasets. Built with advanced functionality including sorting, filtering, searching, pagination, row selection, and data export. Perfect for admin panels, user management, analytics dashboards, and any interface requiring complex data presentation.

Basic Usage

ID
Name
Email
Role
1John Doejohn@example.comAdmin
2Jane Smithjane@example.comUser
3Bob Johnsonbob@example.comEditor
4Alice Wilsonalice@example.comManager
5Charlie Browncharlie@example.comUser
Showing 1 to 5 of 5 results

With Custom Renderers

Name
Email
Phone
Status
Role
John Doe
john@example.com
+1 (555) 123-4567
active
Admin
Jane Smith
jane@example.com
+1 (555) 234-5678
inactive
User
Bob Johnson
bob@example.com
+1 (555) 345-6789
pending
Editor
Showing 1 to 3 of 3 results

With Filters and Actions

Name
Email
Status
Role
Department
Actions
John Doe
john@example.com
active
AdminEngineering
Jane Smith
jane@example.com
active
UserMarketing
Bob Johnson
bob@example.com
inactive
EditorEngineering
Alice Wilson
alice@example.com
pending
ManagerSales
Showing 1 to 4 of 4 results

Loading State

Analytics Dashboard

Analytics Overview
Metric
Value
Change
Category
Page Views
12,543
+12.5%
Traffic
Unique Visitors
8,921
+8.2%
Users
Bounce Rate
34.2%
-2.1%
Engagement
Conversion Rate
3.8%
+0.5%
Sales
Showing 1 to 4 of 4 results

Properties

DataTable

PropertyTypeDescription
dataT[]Array of data objects to display in the table.
columnsDataTableColumn<T>[]Column configuration array.
searchFields(keyof T)[]Fields to include in search functionality.
filtersDataTableFilter<T>[]Filter configuration array.
pageSizenumberNumber of rows per page. Default is 40.
loadingbooleanWhether the table is in loading state.
classNamestringAdditional CSS classes for the table container.
activeFiltersRecord<string, string>Default active filters.
toolsDataTableToolsConfiguration for table tools and features.

DataTableColumn

PropertyTypeDescription
keykeyof TData field key for this column.
titlestringColumn header title.
sortablebooleanWhether this column is sortable.
widthstringCSS width value for the column.
align"left" | "center" | "right"Text alignment for the column.
hiddenbooleanWhether the column is hidden.
headerClassNamestringAdditional CSS classes for the header cell.
customRenderer(value: any, row: T) => ReactNodeCustom render function for cell content.

DataTableFilter

PropertyTypeDescription
fieldkeyof TData field to filter on.
labelstringDisplay label for the filter.
optionsFilterOption[]Available filter options.

FilterOption

PropertyTypeDescription
labelstringDisplay label for the option.
valuestringValue to filter by.

DataTableTools

PropertyTypeDescription
search{ hide?: boolean; placeholder?: string }Search tool configuration.
export{ hide?: boolean; label?: string }Export tool configuration.
columnSelector{ hide?: boolean }Column visibility tool configuration.
clearFilters{ hide?: boolean; label?: string }Clear filters tool configuration.
rowSelector{ hide?: boolean }Row selection tool configuration.
pagination{ label?: string }Pagination tool configuration.

Ref Methods

The DataTable component exposes several methods through a ref:

MethodTypeDescription
getSelectedItems() => T[]Get array of currently selected items.
clearSelection() => voidClear all row selections.
getSelectionCount() => numberGet count of selected rows.
selectItems(ids: string[]) => voidSelect specific items by ID.
getFilteredData() => T[]Get current filtered dataset.
resetFilters() => voidReset all filters and search.
exportData(filename?: string) => voidExport current data to CSV.
goToPage(page: number) => voidNavigate to specific page.
refresh() => voidRefresh the table data.

Accessibility

The DataTable component includes comprehensive accessibility features:

  • Keyboard Navigation - Full keyboard support for sorting, filtering, and selection
  • Screen Reader Support - Proper ARIA labels and table semantics
  • Focus Management - Clear focus indicators and logical tab order
  • Sort Indicators - Visual and audible sort direction indicators
  • Loading States - Proper loading announcements for screen readers
  • Selection States - Clear indication of selected rows and bulk actions

Common Use Cases

The DataTable component is perfect for:

  • User Management - Admin panels with user lists and actions
  • Analytics Dashboards - Metrics and performance data display
  • Content Management - Articles, posts, and media management
  • E-commerce - Product catalogs and order management
  • Financial Data - Transaction lists and financial reports
  • System Logs - Error logs and activity monitoring
  • Inventory Management - Stock levels and product tracking

Best Practices

  1. Performance - Use pagination for large datasets (1000+ rows)
  2. Search Fields - Include relevant fields in search configuration
  3. Custom Renderers - Use for complex data formatting and actions
  4. Loading States - Always show loading indicators for async operations
  5. Error Handling - Implement proper error states and retry mechanisms
  6. Responsive Design - Consider mobile layouts and horizontal scrolling
  7. Export Functionality - Provide data export for user convenience
  8. Accessibility - Test with keyboard navigation and screen readers