© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Amiejah

Logout action in a livewire component

I'm using the actions as a Livewire component to display a Sidepanel. However trying to figure out on how to create a "logout" action. I'm thinking of setting an extraAttribute (onClick) which will trigger a JS function to submit a form (logout form).

Something like this:
public function displayMenu(): Action
    {
        return Action::make('submit')
            ->icon('heroicon-o-bars-3')
            ->iconButton()
            ->size(ActionSize::ExtraLarge)
            ->modalSubmitAction(false)
            ->modalCancelAction(false)
            ->registerModalActions([
                Action::make('logout')
                    ->icon('far-arrow-right-from-bracket')
                    ->label(__('Sign out'))
                    ->link()
                    ->extraAttributes(['onclick' => 'logout()']),
            ])
            ->modalHeading(fn () => new HtmlString(
                view('steponthebox.layouts::modal-heading',
                    [
                        'logo' => filament()->getBrandLogo(),
                    ]))
            )
            ->modalContent(fn (Action $action) => view(
                'layouts::menu-items',
                [
                    'menuItems' => new HtmlString($this->items),
                    'action' => $action
                ]
            ))
            ->modalWidth(MaxWidth::Small)
            ->slideOver();
    }
public function displayMenu(): Action
    {
        return Action::make('submit')
            ->icon('heroicon-o-bars-3')
            ->iconButton()
            ->size(ActionSize::ExtraLarge)
            ->modalSubmitAction(false)
            ->modalCancelAction(false)
            ->registerModalActions([
                Action::make('logout')
                    ->icon('far-arrow-right-from-bracket')
                    ->label(__('Sign out'))
                    ->link()
                    ->extraAttributes(['onclick' => 'logout()']),
            ])
            ->modalHeading(fn () => new HtmlString(
                view('steponthebox.layouts::modal-heading',
                    [
                        'logo' => filament()->getBrandLogo(),
                    ]))
            )
            ->modalContent(fn (Action $action) => view(
                'layouts::menu-items',
                [
                    'menuItems' => new HtmlString($this->items),
                    'action' => $action
                ]
            ))
            ->modalWidth(MaxWidth::Small)
            ->slideOver();
    }

Is there no better option than this?

Thank you
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Livewire Table component in a action modal
FilamentFFilament / ❓┊help
10mo ago
Delete Action in a custom livewire component
FilamentFFilament / ❓┊help
2y ago
Action not trigging in a livewire component?
FilamentFFilament / ❓┊help
3y ago
Livewire component in Action modalContent? Help
FilamentFFilament / ❓┊help
5mo ago