Table Search 🔍
A flexible search component for filtering table data with support for custom rendering and styling
Table Search 🔍
The TableSearch
component provides a powerful and flexible way to filter your table data. It integrates seamlessly with the TableGrid system and supports both default and custom search implementations.
Features ✨
- 🔄 Integrated with TableGrid instance
- 🎨 Customizable styling (Tailwind/Custom CSS)
- 🎯 Custom search input components
- ⌛ Loading state support
- ❌ Error state handling
- ♿ Full accessibility support
Basic Usage
Props
Required Props
tableInstance
The table instance from useTableGrid hook that manages the table state.
Optional Props
className
Add custom CSS classes to the search container.
searchInputClassName
Add custom CSS classes specifically to the search input.
style
Add custom inline styles to the search container.
placeholder
Customize the input placeholder text.
- Type:
string
- Default:
"Search..."
isLoading
Show loading state in the search input.
- Type:
boolean
- Default:
false
error
Display error message below the search input.
- Type:
string
withoutTailwind
Use without Tailwind CSS styling.
- Type:
boolean
- Default:
false
Customization
Custom Search Input
You can provide a custom search input component through the components
prop:
Custom Render Function
For complete control over the search UI, use the customRender
prop:
Styling
With Tailwind (Default)
Without Tailwind
Examples
Basic Search with Loading State
Search with Error Handling
Custom Search with Icons
Accessibility ♿
The TableSearch component implements these accessibility features:
- Proper
role="search"
attribute - Descriptive ARIA labels
- Screen reader support via
aria-label
andaria-describedby
- Clear error announcements with
role="alert"
- Keyboard navigation support
- Loading state indication
Best Practices 💡
- Always provide a descriptive placeholder text
- Handle loading and error states appropriately
- Consider adding a clear button for non-empty searches
- Use appropriate icons to indicate search functionality
- Implement proper error handling
- Keep accessibility in mind when customizing
Related Components
Last updated on