FilamentF
Filament12mo ago
Harvey

Different toast alignments for frontend

I have an admin panel, and I am using the Toast notifications in a regular livewire component (https://filamentphp.com/docs/3.x/notifications/installation).

The issue I am having is I cannot find a way of changing the position of the toast notifications only on the frontend.

The code I am using to change it.
Notifications::alignment(Alignment::Center);
Notifications::verticalAlignment(VerticalAlignment::End);


I have tried the following:

  1. Adding it inside
    View::composer('layouts.app', function() {})
  2. Creating a middleware and applying it to the frontend routes.
  3. Using
    request()->is('admin/*')
It only happens when trying to send a toast in livewire, does work if I send it then redirect (like a regular flash msg).

Notification::make('foo')
    ->title('bar')
    ->send();


It's like these attempts cannot tell if the livewire update request is frontend/admin panel so does not work, and Filament is generating the position during this request.
Solution
Ok have figured it out with:
.fi-no {
    @apply !items-center !flex-col-reverse !justify-end;
}

.fi-no .translate-x-12 {
    @apply -translate-y-12 translate-x-0;
}

which makes it slide in from the top (and is in the middle) like default
Was this page helpful?