Overview
TheBladeColumn allows you to render completely custom content in table cells using Blade views or raw HTML. It’s perfect for complex cell layouts, custom components, or any content that doesn’t fit the standard column types.
Creating a Blade Column
Basic Usage
Factory Method
You can also create blade columns using the baseColumn class:
With Custom Field Name
_blade_0, _blade_1).
Blade-Specific Methods
Define the content rendering logic. The closure receives the row model and optionally the table component. You can return a Blade view instance or raw HTML string.
Enable searching on blade columns by providing a custom search callback. Unlike other columns, blade columns require a closure to enable searching.
Common Methods
Set a custom label for the column header.
Set the column width.
Apply CSS classes to both header and cells.
Apply CSS classes only to the column header.
Apply CSS classes only to the column cells.
Hide the column from display.
Conditionally hide the column.
Specify a Blade view to render. This is a shortcut for using
render() with a view.Important Notes
- Sorting: Blade columns cannot be made sortable (the
sortable()method is ignored) - Searching: Basic
searchable()without a closure does nothing. You must provide a closure for search functionality - Empty Render: If no
render()callback is set, the column displays an empty string - resolveValue: Always returns
nullfor blade columns
Examples
Basic HTML Rendering
Render Blade View
Complex Status Badge
Multi-Line Cell Content
Progress Bar Column
Interactive Components
Tags Display
Conditional Formatting with Icons
With Livewire Component
Custom Link with Badge Count
Rendering Logic
TheBladeColumn uses a custom renderCell() method:
- Returns empty string if no render callback is set
- Automatically renders
Illuminate\Contracts\View\Viewinstances - Casts other return values to string
Type
The column type identifier forBladeColumn is 'blade'.
Best Practices
- Keep it Simple: Blade columns are powerful, but complex logic can slow down table rendering
- Escape User Input: Always use
e()or{{ }}in Blade to prevent XSS attacks - Use View Components: For complex layouts, create reusable Blade components
- Avoid Heavy Queries: Don’t load relationships or make database queries inside render callbacks
- Consider Caching: If rendering is expensive, consider caching the output
- Accessibility: Include proper ARIA labels and semantic HTML