watheqalshowaiter/filament-sticky-table-header
composer require watheqalshowaiter/filament-sticky-table-header
PanelProvider (e.g., AdminPanelProvider):
use WatheqAlshowaiter\FilamentStickyTableHeader\StickyTableHeaderPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
StickyTableHeaderPlugin::make(),
]);
}
php artisan filament:assets
Apply the plugin to any Filament table resource/page. The headers will automatically stick when scrolling down, improving usability for large datasets.
Global Application:
Register the plugin in your PanelProvider to enable sticky headers across all tables in your Filament panel.
StickyTableHeaderPlugin::make()
->shouldScrollToTopOnPageChanged() // Optional: Enable scroll-to-top behavior
Conditional Activation: Use the plugin selectively by wrapping it in a conditional check (e.g., based on user roles or table type):
->plugins([
auth()->user()->isAdmin()
? StickyTableHeaderPlugin::make()
: null,
])
Customizing Scroll Behavior: Configure scroll-to-top behavior for pagination changes:
StickyTableHeaderPlugin::make()
->shouldScrollToTopOnPageChanged(enabled: true, behavior: "smooth")
behavior: "smooth" (default) or "instant".Integration with Table Actions: The plugin positions sticky headers between edit/delete actions and filter dropdowns, ensuring UI consistency.
Dynamic Plugin Loading:
Load the plugin dynamically in a resource’s getPages() or getWidgets() method:
public function getPages(): array
{
return [
Tables\UsersTable::class,
// ...
] + (auth()->user()->isAdmin()
? [StickyTableHeaderPlugin::make()]
: []);
}
Custom CSS Overrides: Extend the plugin’s default styles by publishing its assets and modifying the CSS:
php artisan vendor:publish --tag=filament-sticky-table-header-assets
Then override the styles in your app’s CSS file (e.g., resources/css/app.css).
Testing: Test sticky behavior in your feature tests by simulating scroll events:
$this->scrollPageToBottom();
$this->assertSeeInViewport('Table Header Text');
Asset Publishing:
Forgetting to run php artisan filament:assets may result in broken sticky behavior. Run this command after installation or updates.
Conflicts with Dropdowns: In Filament v3, the plugin may conflict with dropdown menus. Ensure you’re using version 1.2.1+ for fixes:
composer require watheqalshowaiter/filament-sticky-table-header:^1.2.1
Mobile Responsiveness: The plugin includes fixes for mobile screens (version 1.2.0+), but test on mobile devices to ensure headers remain usable.
Column Grouping Gaps: If using column grouping, gaps may appear. Update to 1.3.0+ for fixes:
composer require watheqalshowaiter/filament-sticky-table-header:^1.3.0
Inspect Elements:
Use browser dev tools to verify the sticky header’s CSS classes (e.g., filament-sticky-table-header). Override these classes if needed.
Check Plugin Registration: Ensure the plugin is registered after other plugins that might modify table behavior (e.g., sorting, filtering).
Clear Cached Views: If changes aren’t reflected, clear Filament’s view cache:
php artisan view:clear
Custom Styling: Override the plugin’s default styles by targeting its CSS classes:
.filament-sticky-table-header {
background: #f8f9fa;
z-index: 1000;
}
Conditional Activation:
Use Filament’s shouldRegisterNavigation or shouldRegisterSidebar patterns to conditionally enable the plugin:
StickyTableHeaderPlugin::make()
->shouldRegisterNavigation(fn () => auth()->check())
Event Listeners:
Extend the plugin’s behavior by listening to Filament’s events (e.g., TableRendered):
use Filament\Tables\Events\TableRendered;
TableRendered::listen(function (TableRendered $event) {
if ($event->table->getName() === 'large-dataset-table') {
// Custom logic for specific tables
}
});
Filament Version Compatibility: The plugin supports Filament 3.x, 4.x, and 5.x. Test thoroughly when upgrading Filament versions to avoid regressions.
How can I help you explore Laravel packages today?