Filament: "Add New" Link to Create Page in Navigation Sidebar
2024-11-11 Filament v3To create a new record in Filament Resource, users typically go to the List page and click the "Add New" button. But what if you want to add that link to the sidebar navigation? Let me show you how.

Here's our initial navigation menu. Would you like to add an "Add New Product" link below the "Products" item?
To do that, you must register a custom navigation item in the Panel Provider.
app/Providers/Filament/AdminPanelProvider.php:
use App\Filament\Resources\ProductResource;use Filament\Navigation\NavigationItem; // ... return $panel ->default() // ... more functions here ->navigationItems([ NavigationItem::make('Add New Product') ->url(fn () => ProductResource::getUrl('create')) ->icon('heroicon-o-plus') ->sort(3), ]);
Here's the result after that code:

Important parts:
- You can add such links to any URL of any Filament Resource with
getUrl(), read more in the official docs - You can choose icons for the menu items from this Blade UI Kit list
- The
sort(3)in this case assumes that the following UserResource has a property$navigationSort = 4which positions it below the "Add New Product"
Official Filament docs: Registering custom navigation items
A few of our Premium Examples: