Skip to main content

DataTable

Enhanced

A powerful, feature-rich data table with sorting, filtering, pagination, and mobile responsiveness. Perfect for displaying complex datasets with full RTL support.

Preview

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Name
Sarah Abdullah
Email
sarah@example.com
Role
Editor
Name
Omar Ibrahim
Email
omar@example.com
Role
User

Installation

Terminalbash

Basic Usage

Reacttsx

Features

Sortable Columns

Click column headers to sort with RTL-aware indicators

Search & Filter

Built-in search with clear button and custom filtering

Pagination

Integrated pagination for large datasets

Loading States

Skeleton loading animation while fetching data

Mobile Responsive

Cards or horizontal scroll view on small screens

Custom Cells

Render custom components in any cell

Examples

Simple Sorting
New

Use enableSorting for automatic sorting without managing state yourself. Perfect for simple tables.

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Join Date
2024-01-15
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Join Date
2024-02-20
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Join Date
2024-03-10
Name
Omar Ibrahim
Email
omar@example.com
Role
User
Join Date
2024-04-05
Name
Sarah Abdullah
Email
sarah@example.com
Role
Editor
Join Date
2024-03-25
tsx

Sortable Columns

For advanced use cases where you need to control the sort state externally (e.g., URL sync, API integration).

Click any column header to sort. Click again to reverse, and once more to clear sorting.

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Join Date
2024-01-15
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Join Date
2024-02-20
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Join Date
2024-03-10
Name
Sarah Abdullah
Email
sarah@example.com
Role
Editor
Join Date
2024-03-25
Name
Omar Ibrahim
Email
omar@example.com
Role
User
Join Date
2024-04-05
tsx

Searchable Table

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Name
Sarah Abdullah
Email
sarah@example.com
Role
Editor
Name
Omar Ibrahim
Email
omar@example.com
Role
User
tsx

Paginated Table

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Page 1 of 2
tsx

Custom Cell Rendering

Name
Ahmed Ali
Email
ahmed@example.com
Status
Active
Actions
Name
Fatima Hassan
Email
fatima@example.com
Status
Active
Actions
Name
Mohammed Youssef
Email
mohammed@example.com
Status
Inactive
Actions
Name
Sarah Abdullah
Email
sarah@example.com
Status
Active
Actions
Name
Omar Ibrahim
Email
omar@example.com
Status
Active
Actions
tsx

Loading State

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Name
Sarah Abdullah
Email
sarah@example.com
Role
Editor
Name
Omar Ibrahim
Email
omar@example.com
Role
User
tsx

Complete Example

All features combined: sorting, searching, pagination, and custom cells.

Name
Ahmed Ali
Email
ahmed@example.com
Role
Admin
Join Date
2024-01-15
Name
Fatima Hassan
Email
fatima@example.com
Role
Editor
Join Date
2024-02-20
Name
Mohammed Youssef
Email
mohammed@example.com
Role
User
Join Date
2024-03-10
Page 1 of 2

Props

DataTable Props

NameTypeDefaultDescription
data
Required
T[]-Array of data to display in the table
columns
Required
ColumnDef<T>[]-Column definitions including headers, accessors, and cell renderers
isLoading
booleanfalseShow skeleton loading state
sortBy
stringundefinedCurrently sorted column ID
sortDirection
'asc' | 'desc' | nullnullCurrent sort direction
onSort
(columnId: string) => voidundefinedCallback when column header is clicked for sorting (external mode)
enableSorting
booleanfalseEnable internal sorting (auto-manages sort state). Use this for simple tables that don't need external state management
defaultSortBy
stringundefinedDefault column to sort by (requires enableSorting)
defaultSortDirection
'asc' | 'desc' | null'asc'Default sort direction (requires enableSorting)
searchable
booleanfalseEnable search input above table
searchPlaceholder
string'Search...'Placeholder text for search input (English)
searchValue
string''Controlled search value
onSearchChange
(value: string) => voidundefinedCallback when search value changes
pagination
booleanfalseEnable pagination controls
currentPage
number1Current page number
totalPages
number1Total number of pages
pageSize
number10Number of rows per page
onPageChange
(page: number) => voidundefinedCallback when page changes
mobileView
'table' | 'cards''cards'Mobile view type: stacked cards or horizontal scroll table
mobileSorting
booleantrueShow sort buttons on mobile card view (only applies to cards mode)
emptyMessage
string'No results found'Message to show when no data
striped
booleanfalseAlternate row background colors
hoverable
booleantrueShow hover effect on rows
compact
booleanfalseReduced padding for denser layout

ColumnDef Props

NameTypeDefaultDescription
id
Required
string-Unique column identifier
header
Required
string-Column header text (English)
headerAr
stringundefinedColumn header text (Arabic)
accessorKey
Required
keyof T-Key in data object to access for this column
cell
(row: T) => React.ReactNodeundefinedCustom cell renderer function
sortable
booleanfalseEnable sorting for this column
align
'start' | 'center' | 'end''start'Text alignment in cells
width
stringundefinedColumn width (CSS value)

Accessibility

Semantic HTML

Built on top of the semantic Table component with proper thead, tbody, th, and td elements.

Keyboard Navigation

Sortable column headers are buttons that can be activated with Enter or Space keys. Search input is fully keyboard accessible.

Screen Readers

Sort indicators provide visual feedback, and the table structure is properly announced to screen readers with column headers associated to their cells.

Loading States

Skeleton loading states provide visual feedback while maintaining layout stability. Interactive elements are disabled during loading.

RTL Considerations

Automatic RTL Support

DataTable inherits RTL support from the base Table component. Sort indicators, search input, and all spacing use logical properties for proper RTL layout.

Sort Indicators

Chevron icons automatically position correctly in both LTR and RTL contexts. The sorting button layout adapts to text direction.

Search Input

Search icon and clear button position correctly using margin-inline-start (ms-) and margin-inline-end (me-) utilities, ensuring proper placement in both directions.

Mobile Cards

On mobile, the cards view uses a grid layout that automatically adapts to RTL, with labels on the start side and values on the end side.

Related Components