Table Column
Documentation for the table column component in React Table Grid
Table Column 📊
The TableColumn
component renders individual column headers in your table. It handles sorting, resizing, and other column-specific features to make your table more interactive and user-friendly.
Features 🎯
- 🔄 Sorting with visual indicators
- ↔️ Column resizing
- 📌 Column pinning support
- 🎨 Custom styling options
- ♿ Full accessibility support
- 🎯 Custom header content
Basic Usage
Here's a simple example of how to use TableColumn:
Props
Required Props
tableInstance
The table instance from useTableGrid hook.
column
Column configuration object.
Optional Props
className
Add custom CSS classes to the column.
width
Set the column width in pixels.
style
Add custom inline styles.
enableColumnResize
Enable column resizing.
- Type:
boolean
- Default:
false
withoutTailwind
Use without Tailwind CSS.
- Type:
boolean
- Default:
false
Advanced Features
1. Sortable Columns
Make columns sortable with built-in sort indicators:
2. Custom Header Content
Use a function to render custom header content:
3. Resizable Columns
Enable column resizing with drag handles:
4. Column Styling
Style your columns with or without Tailwind:
Examples
Basic Sortable Column
Resizable Column with Custom Header
Pinned Column
Accessibility ♿
The TableColumn component includes these accessibility features:
role="columnheader"
: Identifies the element as a column headeraria-sort
: Indicates current sort state (ascending/descending/none)aria-colindex
: Provides the column's position in the table- Sort buttons with descriptive
aria-label
Best Practices 💡
- Clear Headers: Use clear, concise header text
- Appropriate Sorting: Only enable sorting for sortable data types
- Reasonable Widths: Set appropriate min/max widths for resizable columns
- Consistent Styling: Maintain consistent styling across columns
- Mobile-Friendly: Ensure headers work well on smaller screens
- Performance: Use memo for custom header content
- Accessibility: Keep ARIA labels descriptive and meaningful
Related Components
Last updated on