Skip to content

Commit c9c1ab4

Browse files
committed
Fix color flash on page load when setting dark/light mode
Previously, when loading the landing page, the page colors would flash briefly. For light mode the background flashes black before the white background loads. For dark mode, the header would flash white, and the text black, before the correct colors render. This was happening because the script was being executed after the page had finished loading, likely due to how the page is packaged into chunks. To fix this, the dark mode script is now set inline, so will be part of the generated HTML. This fixes tailwindlabs#2105
1 parent 256b4cc commit c9c1ab4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/app/layout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ export default async function RootLayout({
159159
<meta name="application-name" content="Tailwind CSS" />
160160
<meta name="msapplication-TileColor" content="#38bdf8" />
161161
<meta name="msapplication-config" content={v("/favicons/browserconfig.xml")} />
162-
163-
<Script src={`data:text/javascript;base64,${btoa(darkModeScript)}`} />
162+
<script type="text/javascript" dangerouslySetInnerHTML={{__html: darkModeScript}}></script>
164163
</head>
165164
<body>
166165
<Fathom />

0 commit comments

Comments
 (0)