watheqalshowaiter/filament-sticky-table-header
Installation Add the package via Composer:
composer require watheqalshowaiter/filament-sticky-table-header
Publish the config (if needed):
php artisan vendor:publish --provider="FilamentStickyTableHeader\FilamentStickyTableHeaderServiceProvider"
Register the Plugin
Add to app/Providers/Filament/AppServiceProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\FilamentStickyTableHeader\FilamentStickyTableHeaderPlugin::make(),
]);
}
First Use Case Apply sticky headers to a table in a Filament resource/page:
use FilamentStickyTableHeader\Concerns\HasStickyTableHeaders;
public static function table(Table $table): Table
{
return $table
->columns([
// columns...
])
->plugins([
HasStickyTableHeaders::make(),
]);
}
Global vs. Per-Table Activation
config/filament-sticky-table-header.php):
'default' => true,
->plugins([HasStickyTableHeaders::make()])
Conditional Sticky Headers Use middleware or logic to toggle sticky headers dynamically:
->plugins([
HasStickyTableHeaders::make()->when(fn (User $user) => $user->prefers_sticky_headers()),
])
Custom Styling
Override default styles via CSS (target .filament-sticky-table-header):
.filament-sticky-table-header {
background: #f8f9fa;
z-index: 10;
}
Integration with Filament Actions Ensure sticky headers work seamlessly with bulk actions or filters:
->actions([
Tables\Actions\DeleteBulkAction::make(),
])
->plugins([HasStickyTableHeaders::make()])
'min_rows_for_sticky' => 10,
responsive modifier for mobile:
HasStickyTableHeaders::make()->responsive()
->columns([
Tables\Columns\TextColumn::make('nested_data')
->table(fn (Model $record) => $record->relatedModels)
->plugins([HasStickyTableHeaders::make()]),
])
Z-Index Conflicts
z-index in custom CSS or adjust Filament’s modal z-index (e.g., !important in resources/css/filament.css).Scrollbar Jumps
overflow-y: auto is set on the table container:
.filament-table-container {
overflow-y: auto;
height: calc(100vh - 120px); /* Adjust as needed */
}
Filament 3 vs. 4
filament/sticky-table-header namespace.FilamentStickyTableHeader namespace (check composer.json for version compatibility).Dynamic Column Changes
useStickyTableHeaders() hook:
->plugins([
HasStickyTableHeaders::make()->hook('useStickyTableHeaders', fn () => {
// Re-render logic if needed
}),
])
Uncaught TypeError if the plugin fails to load. Ensure:
.filament-sticky-table-header to verify styles are applied.Custom Header Content Override the header template via Blade:
HasStickyTableHeaders::make()->view('filament-sticky-table-header::custom-header');
Create resources/views/filament-sticky-table-header/custom-header.blade.php:
<div class="sticky-header">
@include('filament::table.header')
<!-- Add custom elements here -->
</div>
Server-Side Processing
For large datasets, ensure the plugin works with livewire:ignore:
->plugins([
HasStickyTableHeaders::make()->ignoreLivewire(),
])
Localization Translate labels (e.g., "Sticky Header") via Filament’s localization system:
HasStickyTableHeaders::make()->label(__('filament-sticky-table-header::labels.sticky'));
How can I help you explore Laravel packages today?