fix: pre-hydration navbar color to prevent flash, fix hydration mismatch in color picker
This commit is contained in:
1 parent
d6ccc250f6
commit
5b7bd1ebb0
2 files changed
+10
-11
No files matched your search
+1
-1
@@ -42,7 +42,7 @@ export default async function RootLayout({ children }: { children: ReactNode })
|
||||
{/* Apply the saved/default theme before first paint to avoid a flash. */}
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `try{var s=localStorage.getItem('theme');if(s==='dark'||(!s&&${defaultDark}))document.documentElement.classList.add('dark');}catch(e){}`,
|
||||
__html: `try{var s=localStorage.getItem('theme');if(s==='dark'||(!s&&${defaultDark}))document.documentElement.classList.add('dark');var nc=localStorage.getItem('navbarColor'),nt=localStorage.getItem('navbarTextColor');if(nc)document.documentElement.style.setProperty('--color-navbar',nc);if(nt)document.documentElement.style.setProperty('--color-navbar-text',nt);}catch(e){}`,
|
||||
}}
|
||||
/>
|
||||
</head>
|
||||
|
||||
Reference in new issue
Block a user