FilamentF
Filament3y ago
John

Admin panel styling depending on authenticated user

I tried this:

namespace App\Providers;

use Auth;
use Filament\Facades\Filament;
use Illuminate\Support\ServiceProvider;

class FilamentServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Register css
        Filament::serving(function () {
            Filament::registerViteTheme('resources/css/filament.css');
        });

        // Register custom css
        if (Auth::user()->someVariable) {
            Filament::registerStyles([
                asset('css/some-styles.css'),
            ]);
        }
    }
}

  1. It doesn't work because Auth::user() isn't loaded at this point in time.
  2. It loads from /public. I'd prefer it if it would be included in the npm built styles.
  3. The custom styles all need to be !important to overrule Filament styling.
Any advise is appreciated!
Was this page helpful?