aymanalhattami/filament-slim-scrollbar
Installation
composer require aymanalhattami/filament-slim-scrollbar:^2.1.1
Publish the package assets (if needed):
php artisan vendor:publish --provider="AymanAlhattami\FilamentSlimScrollbar\FilamentSlimScrollbarServiceProvider" --tag="filament-slim-scrollbar-assets"
Enable the Package
Add the service provider to config/app.php (if not auto-discovered):
AymanAlhattami\FilamentSlimScrollbar\FilamentSlimScrollbarServiceProvider::class,
First Use Case The package now supports Filament v4 and v5 out-of-the-box. No additional configuration is required for default scrollbars (sidebar, tables, modals). Verify by refreshing a Filament page—scrollbars should appear slim in both versions.
resources/views/extensions/filament-slim-scrollbar.blade.php for customization hooks.config/filament-slim-scrollbar.php (if published) for global overrides, including version-specific configurations.Default Integration for Filament v4/v5
// FilamentPanel.php (if extending)
protected function getFilamentApp(): Filament\Filament {
return parent::getFilamentApp()
->withGlobalSearch()
->withSlimScrollbars(); // Package handles this via service provider
}
Targeting Specific Elements
Use the data-slim-scrollbar attribute on custom HTML elements:
<div data-slim-scrollbar class="h-64 overflow-y-auto">
<!-- Content -->
</div>
Laravel Blade Example:
<x-filament::section data-slim-scrollbar>
{{ $content }}
</x-filament::section>
Dark/Light Mode Support The package auto-detects Filament’s theme mode. Override via config:
// config/filament-slim-scrollbar.php
'force_light_mode' => env('FORCE_LIGHT_SCROLLBAR', false),
Customizing Scrollbar Styles Extend the base styles by publishing assets and overriding:
/* resources/css/filament-slim-scrollbar.css */
.slimScrollbar-track {
background: #333; /* Custom track color */
}
data-slim-scrollbar for consistency in both versions.overflow-auto alongside data-slim-scrollbar.Version-Specific Conflicts
data-slim-scrollbar is applied correctly..filament-v5 .slimScrollbar-* if needed.Nested Scrollables
<div data-slim-scrollbar class="overflow-hidden">
<table data-slim-scrollbar class="overflow-auto">
<!-- Rows -->
</table>
</div>
Third-Party Packages
filament-spatie-laravel-medialibrary) may override scrollbar styles in v4/v5. Inspect their CSS and add:
.filament-v4 .filament-spatie-medialibrary .slimScrollbar-track,
.filament-v5 .filament-spatie-medialibrary .slimScrollbar-track {
/* Override here */
}
Browser Quirks
.slimScrollbar-* classes in both versions.php artisan filament:cache-clear
data-slim-scrollbar is present on target elements in both Filament v4 and v5.php artisan vendor:publish --tag=filament-slim-scrollbar-assets --force
Custom Scrollbar Colors Override via config or published CSS for both Filament versions:
// config/filament-slim-scrollbar.php
'colors' => [
'track' => '#e2e8f0', // Light mode (v4/v5)
'thumb' => '#4a5568',
'dark_track' => '#4a5568', // Dark mode (v4/v5)
'dark_thumb' => '#e2e8f0',
],
Conditional Loading by Filament Version Disable or customize for specific Filament versions via middleware or a trait:
// app/Providers/FilamentServiceProvider.php
Filament::serving(function () {
if (app()->version() === '5.0.*' && request()->routeIs('filament.pages.no-scrollbar')) {
app()->singleton(FilamentSlimScrollbar::class, fn() => null);
}
});
JavaScript Hooks (Advanced) Though CSS-only, extend with JS if needed for version-specific tweaks:
document.addEventListener('DOMContentLoaded', () => {
const slimElements = document.querySelectorAll('[data-slim-scrollbar]');
slimElements.forEach(el => {
if (document.body.classList.contains('filament-v5')) {
el.style.setProperty('--slim-scrollbar-width', '8px');
}
});
});
How can I help you explore Laravel packages today?