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

Server-side Pagination

When data is fetched page-by-page from an API, pass the serverPagination prop instead of relying on the built-in client-side slicing. The data prop must contain only the current page's rows; the table renders them as-is and delegates page navigation to your callback.

ID
Name
Email
Role
1User 1user1@example.comAdmin
2User 2user2@example.comUser
3User 3user3@example.comEditor
4User 4user4@example.comAdmin
5User 5user5@example.comUser
Showing 1 to 40 of 50 results
...

Localization

All text rendered by the table can be overridden through the labels prop. Every field is optional — omitted ones fall back to the English default. This is the recommended approach for i18n.

Priority: tools.*.label > labels.* > built-in default. Existing tools label fields keep working as before.

ID
Nome
E-mail
Status
Função
1João Silvajoao@exemplo.com.bractiveAdmin
2Maria Souzamaria@exemplo.com.brinactiveUser
3Carlos Limacarlos@exemplo.com.brpendingEditor
4Ana Costaana@exemplo.com.bractiveEditor
5Paulo Mendespaulo@exemplo.com.brpendingAdmin
Exibindo 1 a 5 de 5 registros

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.
labelsDataTableLabelsOverride any text rendered by the table. All fields optional; omitted ones fall back to English defaults.
serverPaginationServerPaginationConfigDelegates pagination to the caller. When provided, data must contain only the current page's items.

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 button configuration. Visible by default.
columnSelector{ hide?: boolean }Column visibility dropdown configuration. Visible by default.
clearFilters{ hide?: boolean; label?: string }Clear filters button configuration.
rowSelector{ hide?: boolean }Row selection checkboxes configuration.
pagination{ label?: string }Pagination counter template.

DataTableLabels

Override any text displayed by the table. All fields are optional.

FieldDefaultDescription
searchPlaceholder'Search...'Search input placeholder.
exportButton'Export CSV'Export button label.
clearAllButton'Clear All'Clear-all-filters button label.
paginationCounter'Showing {{startIndex}} to {{endIndex}} of {{totalItems}} results'Pagination counter template. Supports {{startIndex}}, {{endIndex}}, {{totalItems}}.
noDataAvailable'No data available.'Empty-state label when there is no data.
noResultsWithFilters'No results found for the current filters.'Empty-state label when filters produce no results.
searchBadgePrefix'Search'Prefix in the active-search badge.
sortBadgePrefix'Sort'Prefix in the active-sort badge.
columnsButton'Columns'Column-visibility dropdown trigger label.
toggleColumnsMenuLabel'Toggle columns'Column-visibility dropdown menu label.
resetColumnsButton'Reset columns'Reset column-visibility button label.
allFilterOption(filterLabel: string) => stringFactory for the "All" option in filter dropdowns. Default: returns "All {filterLabel}".
rowSelectedSingular'row selected'Selection info label (singular).
rowSelectedPlural'rows selected'Selection info label (plural).
clearSelectionButton'Clear selection'Clear-selection button label.

ServerPaginationConfig

PropertyTypeDescription
totalItemsnumberTotal number of items on the server.
totalPagesnumberTotal number of pages on the server.
currentPagenumberCurrent active page (controlled externally).
onPageChange(page: number) => voidCalled when the user navigates to a different page.

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. In server pagination mode, calls serverPagination.onPageChange.
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