Table Cell
Documentation for the TableCell component in React Table Grid
Table Cell 📱
The TableCell
component renders individual cells in your table. It's highly flexible, supporting custom rendering, editing, and styling options to display your data exactly how you want it.
Features 🎯
- 🎨 Multiple rendering options
- ✏️ Editable cell support
- 📐 Flexible width control
- 🎯 Custom component overrides
- ♿ Full accessibility support
- 🎭 With/without Tailwind styling
Basic Usage
Here's a simple example of how to use TableCell:
Props
Required Props
column
Column configuration object.
row
The data object for the current row.
rowIndex
The index of the current row.
value
The value to display in the cell.
Optional Props
className
Add custom CSS classes to the cell.
width
Set the cell width in pixels.
style
Add custom inline styles.
components
Override the default cell rendering.
withoutTailwind
Use without Tailwind CSS.
- Type:
boolean
- Default:
false
isEditing
Whether the cell is in edit mode.
- Type:
boolean
- Default:
false
Rendering Priority
The TableCell component follows this rendering priority:
customRender
prop (if provided)components.Cell
(if provided)column.cell
(if defined)- Default rendering (converts value to string)
Advanced Features
1. Custom Cell Rendering
You can customize cell rendering in multiple ways:
2. Editable Cells
Handle cell editing with onChange callbacks:
3. Cell Width Control
Control cell width and sizing:
Styling Guide
With Tailwind (Default)
Without Tailwind
Examples
Basic Text Cell
Formatted Number Cell
Interactive Cell
Accessibility ♿
The TableCell component includes these accessibility features:
role="cell"
: Identifies the element as a table cellaria-colindex
: Provides the cell's column position- Proper data attributes for cell identification
- Support for keyboard interaction in editable cells
Best Practices 💡
- Choose Right Renderer: Use the appropriate rendering method for your needs
- Handle Edits Safely: Validate changes in editable cells
- Consistent Styling: Keep cell styles consistent across the table
- Performance: Keep cell renderers simple and memoized
- Mobile Support: Ensure cells work well on small screens
- Error Handling: Handle null or undefined values gracefully
- Accessibility: Maintain proper ARIA attributes
Related Components
Last updated on