alp-develop/laravel-livewire-tables
Reactive Livewire data tables for Laravel—search, sort, filter, paginate, export, and bulk actions with zero JavaScript. Supports Laravel 10–13, Livewire 3–4, PHP 8.1+, Tailwind or Bootstrap 4/5, plus dark mode and configurable themes.
Toolbar slots allow you to inject custom content into the table's toolbar area and around the table itself.
| Method | Position |
|---|---|
toolbarLeftPrepend() |
Before search input (left side) |
toolbarLeftAppend() |
After search & filter buttons (left side) |
toolbarRightPrepend() |
Before bulk/columns/per-page (right side) |
toolbarRightAppend() |
After per-page selector (right side) |
beforeTable() |
After toolbar, before data rows |
afterTable() |
After data rows, before pagination |
Each method returns View|string|null. Return null (default) to render nothing.
Override the slot methods in your table component:
use Illuminate\Contracts\View\View;
class UsersTable extends DataTableComponent
{
public function toolbarLeftPrepend(): View|string|null
{
return '<button wire:click="createUser" class="lt-btn-primary">+ New User</button>';
}
public function toolbarRightAppend(): View|string|null
{
return view('tables.partials.toolbar-actions');
}
public function beforeTable(): View|string|null
{
return '<div class="p-3 bg-yellow-50 text-yellow-800 rounded">⚠ 5 users pending approval</div>';
}
public function afterTable(): View|string|null
{
return view('tables.partials.summary', [
'total' => $this->getSelectedCount($this->totalRows ?? 0),
]);
}
}
public function toolbarLeftPrepend(): View|string|null
{
return view('tables.partials.create-button', [
'label' => 'New User',
'action' => 'createUser',
]);
}
{{-- resources/views/tables/partials/create-button.blade.php --}}
<button wire:click="{{ $action }}" class="lt-btn-primary">
{{ $label }}
</button>
public function toolbarRightPrepend(): View|string|null
{
$count = User::where('active', false)->count();
return "<span class='text-red-600 text-sm font-medium'>{$count} inactive</span>";
}
public function beforeTable(): View|string|null
{
if (! $this->hasActiveFilters()) {
return null;
}
return '<div class="p-2 text-sm text-gray-500">Filters are active. Showing filtered results.</div>';
}
How can I help you explore Laravel packages today?