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
The package auto-registers to all Filament panels with zero configuration.
First Use Case:
Navigate to any resource page (e.g., /admin/posts) with sub-navigation (e.g., ->subNavigationPosition(SubNavigationPosition::Start)). A collapsible toggle button will appear in the sub-navigation sidebar, allowing users to expand/collapse sections.
Where to Look First:
subNavigationPosition() defined (e.g., PostResource, PageResource).->spa() or ->navigationPosition() settings don’t interfere (though the plugin handles both seamlessly).Auto-Registration:
PostResource with sub-navigation will automatically gain collapsible functionality.Manual Registration (Optional): For granular control, register the plugin explicitly in a panel:
use Emuniq\FilamentCollapsibleSubnav\CollapsibleSubnavPlugin;
public function panel(Panel $panel): Panel {
return $panel
->plugin(CollapsibleSubnavPlugin::make());
}
Integration with Existing Workflows:
livewire:navigated to re-sync collapsed state after Livewire SPA navigation.Customization:
.collapsible-subnav-toggle).subnav_collapsed cookie. Override via:
CollapsibleSubnavPlugin::make()->cookieName('custom_subnav_state');
Theme Integration (Optional): For performance, bundle CSS with your theme:
php artisan collapsible-subnav:install
npm run build
Admin Panel Upgrade:
^3.0|^4.0|^5.0 with no breaking changes.composer require filament/filament:"^5.0"
composer require emuniq/filament-collapsible-subnav
A/B Testing:
Accessibility Audits:
aria-label and dark-mode tooltips pass WCAG checks. The plugin handles this automatically, but test with screen readers.livewire:navigated events are not blocked by your SPA setup (e.g., Alpine.js or custom event listeners).document.querySelector('.collapsible-subnav-toggle').addEventListener('click', () => {
// Custom logic
});
.fi-sidebar-item-btn) internally. Test on a staging panel post-upgrade.Cloudflare Rocket Loader:
data-cfasync="false". If issues persist, whitelist the script in Cloudflare or disable Rocket Loader for Filament pages.SPA Mode Desync (Pre-v1.6.0):
livewire:navigated listener. Ensure your Filament version is ≥1.6.0.Tooltips in Filament v4:
::after tooltips, ensuring compatibility across v3/v4/v5.Mobile Responsiveness:
.collapsible-subnav with display: block !important on small screens.Cookie Conflicts:
subnav_collapsed cookie names might conflict with other plugins.filament_subnav_collapsed).Toggle Not Appearing:
->subNavigationPosition())..collapsible-subnav-toggle. If missing, the plugin failed to auto-register. Manually register it in the panel.State Not Persisting:
subnav_collapsed in browser dev tools.CSS Overrides Broken:
!important sparingly; target specific classes like .collapsible-subnav-toggle.SPA Mode Issues:
livewire:navigated events in browser console. If missing, your SPA setup may suppress them.document.addEventListener('livewire:navigated', () => {
console.log('Livewire navigated - plugin should re-sync');
});
Performance Optimization:
collapsible-subnav:install Artisan command to bundle CSS with your theme, reducing HTTP requests.Dark Mode Styling:
.dark .collapsible-subnav-tooltip {
background: #333;
color: #fff;
}
Accessibility:
aria-label to collapsed items. Test with NVDA/VoiceOver to confirm.Filament v5 Migration:
Extending Functionality:
document.querySelector('.collapsible-subnav-toggle').addEventListener('click', (e) => {
// Example: Log analytics
console.log('Subnav toggled', e.target.dataset.state);
});
Localization:
aria-label. Localize by overriding the attribute:
// In your resource/page class
public static function getCollapsedTooltip(): string {
return __('filament-collapsible-subnav::toggle.collapse');
}
How can I help you explore Laravel packages today?