Override the theme for a specific table component by passing the tableTheme parameter:
use Livewire\Livewire;use App\Livewire\Tables\UsersTable;// In your Blade view:Livewire::component('users-table', UsersTable::class, ['tableTheme' => 'bootstrap-5']);
The complete interface that all themes must implement:
namespace Livewire\Tables\Core\Contracts;interface ThemeContract{ public function name(): string; /** @return array<string, string> */ public function classes(): array; public function paginationView(): string; public function supportsImportantPrefix(): bool;}
You can create your own theme by implementing the ThemeContract interface:
1
Create the Theme Class
namespace App\Themes;use Livewire\Tables\Core\Contracts\ThemeContract;final class MaterialTheme implements ThemeContract{ public function name(): string { return 'material'; } public function classes(): array { return [ 'container' => 'mdc-data-table', 'table' => 'mdc-data-table__table', 'thead' => 'mdc-data-table__header-row', 'th' => 'mdc-data-table__header-cell', 'tbody' => 'mdc-data-table__content', 'tr' => 'mdc-data-table__row', 'td' => 'mdc-data-table__cell', // ... map all 90+ element keys ]; } public function paginationView(): string { return 'components.pagination.material'; } public function supportsImportantPrefix(): bool { return false; }}
2
Register in a Service Provider
namespace App\Providers;use Illuminate\Support\ServiceProvider;use Livewire\Tables\Themes\ThemeManager;use App\Themes\MaterialTheme;class AppServiceProvider extends ServiceProvider{ public function boot(): void { $manager = app(ThemeManager::class); // Register the theme $manager->register('material', MaterialTheme::class); // Optionally set it as active $manager->use('material'); }}
3
Use the Theme
// In config/livewire-tables.php'theme' => 'material',// Or per-table<livewire:users-table :tableTheme="'material'" />
Inside your table component, you can check which theme is active:
public function configure(): void{ if ($this->isTailwind()) { $this->setTableClass('rounded-lg shadow-xl'); } if ($this->isBootstrap()) { $this->setTableClass('table-hover table-striped'); } if ($this->isBootstrap5()) { // Bootstrap 5 specific } if ($this->isBootstrap4()) { // Bootstrap 4 specific }}
These helper methods are available:
$this->theme() — Returns the active theme name (string)
$this->isTailwind() — Returns true if theme is 'tailwind'
$this->isBootstrap() — Returns true if theme starts with 'bootstrap'
$this->isBootstrap5() — Returns true if theme is 'bootstrap5', 'bootstrap-5', or 'bootstrap'
$this->isBootstrap4() — Returns true if theme is 'bootstrap4' or 'bootstrap-4'