Table Body
Documentation for the table body component in React Table Grid
Table Body 📋
The TableBody
component is responsible for rendering the main content area of your table. It handles displaying your data rows, loading states, and empty states in a clean and efficient way.
Features 🎯
- 📊 Efficient row rendering
- ⌛ Built-in loading states
- 🗑️ Empty state handling
- 🎨 Custom row rendering
- 🎭 With/without Tailwind styling
- ♿ Full accessibility support
Basic Usage
Here's a simple example of how to use TableBody:
Props
Required Props
tableInstance
The table instance from useTableGrid hook that manages the table state.
Optional Props
className
Add custom CSS classes to the body container.
style
Add custom inline styles.
bodyRowClassName
Add custom CSS classes to all rows.
bodyCellClassName
Add custom CSS classes to all cells.
components
Override default components for loading and empty states.
customRender
Custom render functions for different states and rows.
withoutTailwind
Use without Tailwind CSS.
- Type:
boolean
- Default:
false
States and Rendering
1. Loading State
The loading state is shown when data is being fetched:
2. Empty State
Shown when there's no data to display:
3. Custom Row Rendering
Customize how each row is rendered:
Styling Guide
With Tailwind (Default)
Without Tailwind
Examples
Basic Table Body
Custom Loading and Empty States
Custom Row Rendering
Accessibility ♿
The TableBody component includes these accessibility features:
role="rowgroup"
: Identifies the element as a table bodyaria-label
: Provides context for screen readersaria-busy
: Indicates loading statearia-live
: Announces dynamic content changes- Proper row and cell roles
Best Practices 💡
- Handle States: Always provide appropriate loading and empty states
- Custom Rendering: Keep custom row renders simple and performant
- Consistent Styling: Maintain consistent styling across rows
- Error States: Handle error states gracefully
- Mobile Support: Ensure content works well on small screens
- Accessibility: Keep ARIA labels descriptive
- Performance: Avoid unnecessary re-renders in custom components
Related Components
Last updated on