Introduction
By default, Filament will register navigation items for each of your resources, custom pages, and clusters. These classes contain static properties and methods that you can override, to configure that navigation item. If you’re looking to add a second layer of navigation to your app, you can use clusters. These are useful for grouping resources and pages together.Customizing a navigation item’s label
By default, the navigation label is generated from the resource or page’s name. You may customize this using the$navigationLabel property:
getNavigationLabel() method:
Customizing a navigation item’s icon
To customize a navigation item’s icon, you may override the$navigationIcon property on the resource or page class:
$navigationIcon = null on all items within the same navigation group, those items will be joined with a vertical bar below the group label.
Switching navigation item icon when it is active
You may assign a navigation icon which will only be used for active items using the$activeNavigationIcon property:
Sorting navigation items
By default, navigation items are sorted alphabetically. You may customize this using the$navigationSort property:
Adding a badge to a navigation item
To add a badge next to the navigation item, you can use thegetNavigationBadge() method and return the content of the badge:
getNavigationBadge(), it will display using the primary color by default. To style the badge contextually, return either danger, gray, info, primary, success or warning from the getNavigationBadgeColor() method:
$navigationBadgeTooltip:
getNavigationBadgeTooltip():
Grouping navigation items
You may group navigation items by specifying a$navigationGroup property on a resource and custom page:
Grouping navigation items under other items
You may group navigation items as children of other items, by passing the label of the parent item as the$navigationParentItem:
getNavigationParentItem() method to set a dynamic parent item label:
Customizing navigation groups
You may customize navigation groups by callingnavigationGroups() in the configuration, and passing NavigationGroup objects in order:
icon() for the groups, and make one collapsed() by default.
Ordering navigation groups
By usingnavigationGroups(), you are defining a new order for the navigation groups. If you just want to reorder the groups and not define an entire NavigationGroup object, you may just pass the labels of the groups in the new order:
Making navigation groups not collapsible
By default, navigation groups are collapsible. You may disable this behavior by callingcollapsible(false) on the NavigationGroup object:
Adding extra HTML attributes to navigation groups
You can pass extra HTML attributes to the navigation group, which will be merged onto the outer DOM element. Pass an array of attributes to theextraSidebarAttributes() or extraTopbarAttributes() method, where the key is the attribute name and the value is the attribute value:
extraSidebarAttributes() will be applied to navigation group elements contained in the sidebar, and the extraTopbarAttributes() will only be applied to topbar navigation group dropdowns when using top navigation.
Registering navigation groups with an enum
You can use an enum class to register navigation groups, which allows you to control their labels, icons, and order in a single place, without needing to register them in the configuration. To do this, you can create an enum class with cases for each group:$navigationGroup property to the enum case:
HasLabel interface on the enum class, to define a custom label for each group:
HasIcon interface on the enum class, to define a custom icon for each group:
Collapsible sidebar on desktop
To make the sidebar collapsible on desktop as well as mobile, you can use the configuration:sidebarFullyCollapsibleOnDesktop() method:
Navigation groups in a collapsible sidebar on desktop
This section only applies to
sidebarCollapsibleOnDesktop(), not sidebarFullyCollapsibleOnDesktop(), since the fully collapsible UI just hides the entire sidebar instead of changing its design.icon() to the navigation group objects. When an icon is defined, the icon will be displayed in the collapsed sidebar instead of the items at all times. When the icon is clicked, a dropdown will open to the side of the icon, revealing the items in the group.
When passing an icon to a navigation group, even if the items also have icons, the expanded sidebar UI will not show the item icons. This is to keep the navigation hierarchy clear, and the design minimal. However, the icons for the items will be shown in the collapsed sidebar’s dropdowns though, since the hierarchy is already clear from the fact that the dropdown is open.
Registering custom navigation items
To register new navigation items, you can use the configuration:Conditionally hiding navigation items
You can also conditionally hide a navigation item by using thevisible() or hidden() methods, passing in a condition to check:
Disabling resource or page navigation items
To prevent resources or pages from showing up in navigation, you may use:shouldRegisterNavigation() method:
shouldRegisterNavigation() only hides the link from the sidebar — it does not prevent a user from typing the URL directly. To actually restrict access, use resource authorization or page authorization.Using top navigation
By default, Filament will use a sidebar navigation. You may use a top navigation instead by using the configuration:Customizing the width of the sidebar
You can customize the width of the sidebar by passing it to thesidebarWidth() method in the configuration:
sidebarCollapsibleOnDesktop() method, you can customize width of the collapsed icons by using the collapsedSidebarWidth() method in the configuration:
Advanced navigation customization
Thenavigation() method can be called from the configuration. It allows you to build a custom navigation that overrides Filament’s automatically generated items. This API is designed to give you complete control over the navigation.
Registering custom navigation items
To register navigation items, call theitems() method:
Registering custom navigation groups
If you want to register groups, you can call thegroups() method:
Disabling navigation
You may disable navigation entirely by passingfalse to the navigation() method:
false hides the navigation, while returning true renders the default auto-discovered navigation items. This is useful for flows such as onboarding or setup wizards where the navigation should only appear once the user has reached a particular state:
Disabling the topbar
You may disable topbar entirely by passingfalse to the topbar() method:
Replacing the sidebar and topbar Livewire components
You may completely replace the Livewire components that are used to render the sidebar and topbar, passing your own Livewire component class name into thesidebarLivewireComponent() or topbarLivewireComponent() method:
Disabling breadcrumbs
The default layout will show breadcrumbs to indicate the location of the current page within the hierarchy of the app. You may disable breadcrumbs in your configuration:Reloading the sidebar and topbar
Once a page in the panel is loaded, the sidebar and topbar are not reloaded until you navigate away from the page, or until a menu item is clicked to trigger an action. You can manually reload these components to update them by dispatching arefresh-sidebar or refresh-topbar browser event.
To dispatch an event from PHP, you can call the $this->dispatch() method from any Livewire component, such as a page class, relation manager class, or widget class:
$livewire argument into a closure function, and call dispatch() on that:
$dispatch() Alpine.js helper method, or the native browser window.dispatchEvent() method: