From a73d90c0cb5a3092d12c223f02c00237acfabbe4 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 10 Feb 2026 12:15:33 +0100 Subject: [PATCH] Fix white flicker --- resources/views/layouts/admin.blade.php | 11 ++++--- resources/views/layouts/app.blade.php | 3 ++ resources/views/layouts/guest.blade.php | 3 ++ resources/views/layouts/main.blade.php | 33 ++----------------- resources/views/partials/theme-init.blade.php | 19 +++++++++++ 5 files changed, 35 insertions(+), 34 deletions(-) create mode 100644 resources/views/partials/theme-init.blade.php diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php index f8c9642a2..9f9f41f06 100644 --- a/resources/views/layouts/admin.blade.php +++ b/resources/views/layouts/admin.blade.php @@ -5,14 +5,13 @@ + {{-- Apply dark mode BEFORE any CSS loads to prevent white flash --}} + @include('partials.theme-init') + {{ $meta_title ?? 'Admin' }} - {{ config('app.name') }} - - @vite(['resources/css/app.css', 'resources/js/app.js']) - @stack('styles') - @@ -21,6 +20,10 @@ + + + @vite(['resources/css/app.css', 'resources/js/app.js']) + @stack('styles')
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 77d2c3bed..1a3058519 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -7,6 +7,9 @@ + {{-- Apply dark mode BEFORE any CSS loads to prevent white flash --}} + @include('partials.theme-init') + {{ config('app.name', 'Laravel') }} diff --git a/resources/views/layouts/guest.blade.php b/resources/views/layouts/guest.blade.php index 3685f1014..08d5cc2d2 100644 --- a/resources/views/layouts/guest.blade.php +++ b/resources/views/layouts/guest.blade.php @@ -6,6 +6,9 @@ + {{-- Apply dark mode BEFORE any CSS loads to prevent white flash --}} + @include('partials.theme-init') + {{ config('app.name') }} diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index f84b2e2a4..c95541c32 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -8,6 +8,9 @@ + {{-- Apply dark mode BEFORE any CSS loads to prevent white flash --}} + @include('partials.theme-init') + {{ $meta_title ?? config('app.name') }}@if(isset($meta_title) && $meta_title != '' && $site['metatitle'] != '') - @endif{{ $site['metatitle'] ?? '' }} @@ -25,36 +28,6 @@ @vite(['resources/css/app.css', 'resources/js/app.js']) @stack('styles') - - -
diff --git a/resources/views/partials/theme-init.blade.php b/resources/views/partials/theme-init.blade.php new file mode 100644 index 000000000..c0f01522b --- /dev/null +++ b/resources/views/partials/theme-init.blade.php @@ -0,0 +1,19 @@ +{{-- + Dark mode initialization - MUST be included at the very top of , + BEFORE any CSS/Vite tags, to prevent white flash on page load. + This tiny blocking script applies the 'dark' class to synchronously + before the browser paints any content. +--}} +