Table
A flexible data table component for displaying structured data with support for sorting, selection, responsive design, and interactive rows.
Import
Usage
Examples
Variant
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Size
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Radius
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
With row selection
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
| Bob Wilson | 42 | bob@example.com |
Selected: none
Row selection color
Primary Color
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Secondary Color
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Danger Color
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Success Color
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Warning Color
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
With interactive rows
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
With custom row key accessor
| Name | Age |
|---|---|
| John Doe | 30 |
| Jane Smith | 25 |
Empty state
| Name | Age | |
|---|---|---|
| No users found | ||
Custom empty message
| Name | Age | |
|---|---|---|
No data available | ||
With custom cell rendering
| Name | Status |
|---|---|
| John Doe | active |
| Jane Smith | inactive |
Custom styling
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
With grid classes
| Name | Age | |
|---|---|---|
| John Doe | 30 | john@example.com |
| Jane Smith | 25 | jane@example.com |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | TData[] | None | Array of row data objects (required) |
columns | ColumnDef<TData>[] | None | Column definitions (required) |
variant | "grid" | "striped" | "bordered" | "ghost" | "grid"* | Visual style |
size | "sm" | "md" | "lg" | "md"* | Density/size scale |
color | "none" | "default" | "primary" | "secondary" | "danger" | "warning" | "success" | "primary"* | Selection/hover color |
radius | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full" | "md"* | Corner rounding |
rowKeyAccessor | (row: TData) => string | number | None | Returns unique key per row |
selectedRowKey | string | number | None | Key of selected row |
isClickable | boolean | false | Enables interactive rows |
handleClick | (data: TData, rowId?: string | number) => void | None | Row click handler |
handleDoubleClick | (data: TData, rowId?: string | number) => void | None | Row double-click handler |
emptyMessage | ReactNode | "No items available" | Empty state content |
headerClassName | string | None | Extra classes for header |
rowClassName | string | None | Extra classes for each row |
cellClassName | string | None | Extra classes for each cell |
className | string | None | Extra classes, merged with internal styles |
* Falls back through Global Configuration if not set. See below.
ColumnDef
| Prop | Type | Description |
|---|---|---|
id | string | Optional explicit key for React rendering |
header | ReactNode | Header content (required) |
cell | (row: TData) => ReactNode | Cell renderer (required) |
Global Configuration
Table reads defaults from four places, in this order of precedence:
- Instance prop: set directly on
<Table /> - Component config:
components.tablein yourashee.config - Theme default:
defaultColor/defaultRadiusin yourashee.config - Built-in fallback: component's internal default values
Component config
Built-in fallbacks
Accessibility
- Uses semantic
<table>,<thead>, and<tbody>elements - Header cells use
scope="col" - Interactive rows are keyboard accessible with Enter and Space keys
- Uses
aria-selectedfor selected rows - Implements
focus-visiblerings for keyboard navigation - TabIndex management for interactive rows
- Empty state is conveyed properly to screen readers
Notes
- Variant:
gridadds borders between cells,stripedalternates row backgrounds,borderedadds borders around the table,ghostremoves all borders. - Interactive Rows: When
isClickableistrueor click handlers are provided, rows become interactive with hover effects and keyboard support. - Row Selection: Use
selectedRowKeyto highlight a specific row. The row's color is determined by thecolorprop. - Empty State: The
emptyMessageprop allows customization of the content displayed whendatais empty. - Row Key Accessor: For better performance with dynamic data, provide a
rowKeyAccessorfunction to generate unique row keys. - Sticky Header: The table header is sticky by default for better scrolling UX.