Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

classicalguss's avatar

Laravel nova 4.0 topbar customize

Is there an easy and official way to customize the topbar section? It seems for the documentation I can only hide the theme icon and notifications icon.

What I need is to add another icon in order to change the country. I'm struggling to find something I can use.

0 likes
3 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Yes, you can customize the topbar section in Laravel Nova 4.0. You can do this by creating a custom Nova Tool. To do this, you will need to create a new Nova Tool class and register it in your NovaServiceProvider.php file.

In your Nova Tool class, you can add a custom icon to the topbar section by using the withToolbar method. This method takes a closure as an argument, which you can use to add your custom icon.

For example:

public function withToolbar()
{
    return function (NovaTool $tool) {
        $tool->addButton('Change Country', 'change-country', function () {
            // Your code here
        });
    };
}

You can then use the addButton method to add your custom icon. The first argument is the label for the button, the second argument is the name of the icon, and the third argument is a closure that will be called when the button is clicked.

In the closure, you can add the code to change the country.

Once you have added your custom Nova Tool, you can register it in your NovaServiceProvider.php file.

public function tools()
{
    return [
        // Other tools...
        new ChangeCountryTool(),
    ];
}

That's it! You should now have a custom icon in the topbar section that you can use to change the country.

1 like
axxel's avatar

Hi @classicalguss, did you manage to customize the top bar as per @laryai 's suggestion? I'm not sure about the NovaTool class and the addButton() method: I'm not able to find neither the class (could it be Laravel\Nova\Tool?) nor the method in Nova's source code.

1 like

Please or to participate in this conversation.