Skip to main content

Table

A responsive table component for displaying structured data with full RTL support. Uses semantic HTML with proper text alignment for bidirectional content.

Preview

A list of recent users
NameEmailStatusRole
Ahmed Aliahmed@example.com
Active
Admin
Fatima Hassanfatima@example.com
Active
User
Mohammed Youssefmohammed@example.com
Inactive
User
Sarah Abdullahsarah@example.com
Active
Editor

Installation

Terminalbash

Usage

Reacttsx

Composition Pattern

The Table component follows a composition pattern with seven sub-components:

  • Table - Main wrapper with overflow handling
  • TableHeader - thead element for column headers
  • TableBody - tbody element for data rows
  • TableFooter - tfoot element for summary rows
  • TableRow - tr element with hover effects
  • TableHead - th element with text-start for RTL
  • TableCell - td element for data cells
  • TableCaption - caption element for table description

Examples

Table with Caption

A list of your recent transactions
InvoiceStatusMethodAmount
INV-001
Paid
Credit Card$250.00
INV-002
Pending
PayPal$150.00
INV-003
Paid
Bank Transfer$350.00
tsx

Interactive Table with Checkboxes

NameEmailRole
Ahmed Aliahmed@example.com
Admin
Fatima Hassanfatima@example.com
User
Mohammed Youssefmohammed@example.com
User
Sarah Abdullahsarah@example.com
Editor
tsx

Mobile Responsive Table

This table adapts to mobile screens by showing a 2-column layout (label + value) instead of horizontal scrolling. Resize your browser to see it in action.

Name
Ahmed Ali
Email
ahmed@example.com
Status
Active
Role
Admin
Name
Fatima Hassan
Email
fatima@example.com
Status
Active
Role
User
Name
Mohammed Youssef
Email
mohammed@example.com
Status
Inactive
Role
User
Name
Sarah Abdullah
Email
sarah@example.com
Status
Active
Role
Editor
tsx

Props

Table

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply

TableHeader

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to thead

TableBody

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to tbody

TableRow

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to tr

TableHead

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to th (uses text-start for RTL support)

TableCell

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to td

TableCaption

NameTypeDefaultDescription
className
stringundefinedAdditional CSS classes to apply to caption

Accessibility

Semantic HTML

Uses proper semantic table elements (table, thead, tbody, tfoot, th, td) for screen reader compatibility and accessibility.

Table Caption

Always include a TableCaption to describe the table's purpose for screen reader users. The caption can be visually hidden if needed while remaining accessible.

Column Headers

TableHead components render as th elements, which are automatically associated with their column's cells by assistive technologies.

Keyboard Navigation

For interactive tables, ensure all interactive elements (buttons, checkboxes) are keyboard accessible with proper tab order and focus indicators.

RTL Considerations

Tables automatically support RTL layout with proper text alignment. The TableHead component uses text-start to ensure headers align correctly in both LTR and RTL contexts.

LTR (English)

NameStatusEmail
Ahmed Ali
Active
ahmed@example.com

RTL (العربية)

الاسمالحالةالبريد
أحمد علي
نشط
ahmed@example.com

Related Components