💡 Custom Regulatory Compliance Dashboard See Demo

How to Implement Conditional Sub-Navigation in Filament v4 Resources

| 5 min read
James Manager

James Manager

How to Implement Conditional Sub-Navigation in Filament v4 Resources

When building complex admin panels with Filament v4, navigation plays a huge role in user experience. You might want quick-access tabs between related pages — for example, when editing or processing a record — but showing those tabs everywhere can make your interface cluttered and confusing.

You can easily add a method to your Filament resources so that tabs only appear on specific pages. 

The Problem

Let’s imagine you have a Lead resource with multiple pages:

  • List Leads (index)
  • View Lead (view)
  • Edit Lead (edit)
  • Pre-Qualify Lead (pre-qualify)
  • Move to Compliance (move-to-compliance)

You would like sub-navigation tabs for easy switching between Edit, Pre-Qualify, and Move to Compliance pages. But you don’t want these tabs cluttering up your View pages.

By default, Filament shows sub-navigation on all record pages once getRecordSubNavigation() is defined in your resource — which can quickly lead to a messy UI.

The Solution

To fix this, you can call the `getSubNavigation()` method in the page you don't want the sub-navigation to appear and return an empty array.

class ViewLead extends ViewRecord
{
    protected static string $resource = LeadResource::class;

    public function getSubNavigation(): array
    {
        return [];
    }
}

This gives you precise control, clear intent in your code, and flexibility to add or remove navigation per page.