Customise navigationGroup->icon from Plugin?

Hello, first time poster. New to Laravel and Filament but not a complete newbie to programming/php. What I'm trying to do: I am creating a plugin, and it will come with Resources. I can obviously set ?string $navigationGroup on the Resource, but per https://filamentphp.com/docs/3.x/panels/navigation#customizing-navigation-groups you have to set the icon in the panel settings. What I would like to do: Set the navigation group icon within the Plugin package, so that it doesn't need to be manually added (or added by an installcommand). What I have tried: I've tried searching the web, this discord, the documentation, I even chanced asking AI (so we know I was clutching at straws) and the only reference I can see is that it has to be set on the panel instantiation in the PanelProvider. I'm hoping I am just too new to the ecosystem to know of the obvious way to do this and that's why it's not stated anywhere, but if it's not possible that's fine too.
Solution:
Solution: ```php use Filament\Navigation\NavigationGroup; ...
Jump to solution
8 Replies
awcodes
awcodesβ€’3mo ago
Since you have resources you should just be able to set them there.
πŸ…Έ πŸ…°πŸ…Ό πŸ…³πŸ…°πŸ…³πŸ…ΌπŸ…ΈπŸ…½
Thanks for replying! Within the Resource I can set $navigationIcon and $navigationGroup ... but there doesn't seem to be any string defined for the group icon?
awcodes
awcodesβ€’3mo ago
ahh. you'll need to use the plugin object then to do the custom navigation setup then.
πŸ…Έ πŸ…°πŸ…Ό πŸ…³πŸ…°πŸ…³πŸ…ΌπŸ…ΈπŸ…½
Great, I figured that's where I would need to be, however this is where my relative inexperience is showing and I'm not sure how, and my searching attempts have been unsuccessful in finding any examples. If you (or anyone else) can give any pointers I'd really appreciate it And my apologies if this is something I should just know by now, I am self-taught and doing my best πŸ™‚
awcodes
awcodesβ€’3mo ago
for example, in the plugin object you can do this:
public function register(Panel $panel): void
{
$panel
->resources([
$this->getResource(),
])
->navigation(...);
}
public function register(Panel $panel): void
{
$panel
->resources([
$this->getResource(),
])
->navigation(...);
}
i'm self taught too, no worries.
πŸ…Έ πŸ…°πŸ…Ό πŸ…³πŸ…°πŸ…³πŸ…ΌπŸ…ΈπŸ…½
Oh it's that simple? Awesome I will go have a fiddle
Solution
πŸ…Έ πŸ…°πŸ…Ό πŸ…³πŸ…°πŸ…³πŸ…ΌπŸ…ΈπŸ…½
Solution:
use Filament\Navigation\NavigationGroup;

class YourPlugin implements Plugin
{
(...)

public function register(Panel $panel): void
{
$panel
->navigationGroups([
NavigationGroup::make()
->label('Example')
->icon('heroicon-o-key'),
]);
}
}
use Filament\Navigation\NavigationGroup;

class YourPlugin implements Plugin
{
(...)

public function register(Panel $panel): void
{
$panel
->navigationGroups([
NavigationGroup::make()
->label('Example')
->icon('heroicon-o-key'),
]);
}
}

Did you find this page helpful?