emuniq/filament-collapsible-subnav
Filament v3–v5 plugin that adds a collapsible toggle to resource page sub-navigation sidebars (secondary nav), working with both top navigation and sidebar layouts. Auto-registers to all panels with zero configuration; optional theme CSS bundling.
Installation:
composer require emuniq/filament-collapsible-subnav
First Use Case:
resources/posts). Observe the new collapsible toggle button (⋯) in the sub-navigation sidebar.Optional Optimization: For reduced HTTP requests, integrate the CSS into your Filament theme:
php artisan collapsible-subnav:install
npm run build
Elements > head) for the injected critical CSS. Look for the data-cfasync="false" attribute if using Cloudflare Rocket Loader.subnav_collapsed) are set correctly for persistent state.Auto-Registration:
Panel classes unless overriding defaults.use Emuniq\FilamentCollapsibleSubnav\CollapsibleSubnavPlugin;
public function panel(Panel $panel): Panel {
return $panel->plugin(CollapsibleSubnavPlugin::make());
}
Sub-Navigation Targeting:
SPA Mode Integration:
livewire:navigated. No additional code required for SPA-compatible panels (->spa()).Responsive Design:
Adding to a New Panel:
Customizing Appearance:
.fi-sidebar-item-btn (toggle button).fi-sidebar-item-badge-ctn (badges in collapsed state).collapsible-subnav-tooltip (CSS-only tooltips)Disabling for Specific Panels:
->ignoreSubNavigation() method on the panel:
->plugin(CollapsibleSubnavPlugin::make()->ignoreSubNavigation())
Testing State Persistence:
subnav_collapsed) are set when toggling. Test across page reloads and Livewire SPA navigation.Filament v5 Migration:
composer.json to support v5:
"require": {
"emuniq/filament-collapsible-subnav": "^1.0"
}
Dark Mode Compatibility:
dark class for tooltips. Ensure your theme’s dark mode CSS targets .collapsible-subnav-tooltip::after.Performance Optimization:
collapsible-subnav:install Artisan command to bundle CSS with your theme, reducing HTTP requests.Accessibility:
aria-label to collapsed items. Extend with custom labels if needed:
CollapsibleSubnavPlugin::make()->ariaLabel('Collapse sub-navigation')
Cloudflare Rocket Loader:
data-cfasync="false". If still an issue, exclude the script from Rocket Loader or use the theme-integrated CSS.SPA Mode Desync (Pre-v1.6.0):
livewire:navigated for re-sync.Tooltips in Filament v4:
.fi-sidebar-item-btn instead of .fi-sidebar-item-button).::after pseudo-elements) that work across v3/v4/v5.Mobile Responsiveness:
.fi-sidebar or .collapsible-subnav-toggle.Cookie Conflicts:
subnav_collapsed cookie, causing conflicts.cookieName() method to customize:
CollapsibleSubnavPlugin::make()->cookieName('my_custom_subnav_state')
Toggle Not Appearing:
->subNavigationPosition(SubNavigationPosition::Start))..collapsible-subnav-toggle button. If missing, verify the plugin is registered.State Not Persisting:
Application > Cookies) and look for subnav_collapsed.->ignoreSubNavigation() to isolate the issue.CSS Overrides:
.fi-sidebar-item-btn or .collapsible-subnav-tooltip. Conflicting styles may hide the toggle or tooltips.!important sparingly.SPA Mode Issues:
livewire:navigated events in the browser console. Ensure the plugin’s script re-runs.console.log to the plugin’s JS to verify execution.Custom Toggle Icon:
.collapsible-subnav-toggle::after {
content: "▶";
font-size: 1.2rem;
}
Conditional Registration:
if ($this->isAdminPanel()) {
$panel->plugin(CollapsibleSubnavPlugin::make());
}
Theme Integration:
php artisan collapsible-subnav:install
Dark Mode Styling:
.dark .collapsible-subnav-tooltip::after {
background: #333;
color: white;
}
Testing:
--test flag to verify behavior in a clean environment:
php artisan filament:test --panel=admin
Extension Points:
CollapsibleSubnavPlugin::make()->cookieDomain('.yourdomain.com')
$panel->middleware([DisableSubnavMiddleware::class]);
How can I help you explore Laravel packages today?