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

myregistration's avatar

Can we display Filament's User Menu when a user is not logged in?

Can we display Filament's User Menu when user is not logged in? I've tried adding MenuItem to the userMenuItems array, but menu isn't showing up. I assume it's because user isn't logged in. Is there a way around this? I want to display Log In in the very least. Thanks

This didn't work

            ->userMenuItems([
                'login' => MenuItem::make()->label('Log in'),
            ])

This is the closest I could get. I would rather use the User Menu though.

        ->topNavigation()
        ->navigationItems([
            NavigationItem::make('Login')
                ->icon('heroicon-o-home')
                ->isActiveWhen(fn (): bool => request()->routeIs('filament.guest.pages.index'))
                ->url(fn (): string => route('filament.account.auth.login')),
        ])
0 likes
1 reply
LaryAI's avatar
Level 58

The Filament Admin panel is designed to show the User Menu only when a user is logged in. This is because the User Menu typically contains user-specific actions and information, such as profile settings or logout functionality. However, if you want to display a login option or similar actions when no user is logged in, you will need to customize the navigation bar instead of the User Menu.

Here's how you can add a "Log In" link to the top navigation bar that appears when no user is logged in. You can use the topNavigation() method in your Filament resource or through a service provider to modify the navigation items conditionally based on the user's authentication status.

use Filament\Facades\Filament;
use Filament\Navigation\UserMenuItem;
use Filament\Navigation\NavigationItem;

Filament::serving(function () {
    Filament::registerNavigationItems([
        NavigationItem::make('Login')
            ->icon('heroicon-o-login')
            ->url(route('filament.auth.login'))
            ->isVisible(!Filament::auth()->check()), // Only visible when no user is logged in
    ]);
});

In this example, the isVisible() method is used to conditionally display the "Login" navigation item only when no user is logged in (!Filament::auth()->check()). This approach ensures that the login link is only shown to guests, maintaining a clean and relevant user interface for authenticated users.

Remember to adjust the route (route('filament.auth.login')) and icon (icon('heroicon-o-login')) according to your application's configuration and your aesthetic preferences.

This solution modifies the top navigation bar and does not use the User Menu, as the User Menu is inherently designed to be user-specific and thus hidden when no user session exists.

Please or to participate in this conversation.