Skip to content

Commit 904f6fc

Browse files
fix:fixed Flash of light screen issue (FOUC) (#184)
* fix:fixed Flash of light screen issue (FOUC) - Added ColorModeScript (kept in body) to apply color mode before first pain - Replace invalid CSS selectors Signed-off-by: Saurabhsing21 <[email protected]> * feat: add TypeScript declaration for CSS modules * fix: change initial color mode to dark in theme configuration * fix: remove suppressHydrationWarning from HTML and body tags in layout * style: kept :root in the globals --------- Signed-off-by: Saurabhsing21 <[email protected]> Co-authored-by: JeelRajodiya <[email protected]>
1 parent 599a845 commit 904f6fc

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

app/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.css';

app/layout.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Metadata } from "next";
22

33
import "./styles/globals.css";
44
import { GeistSans } from "geist/font/sans";
5+
import { ColorModeScript } from "@chakra-ui/react";
6+
import { theme } from "./styles/theme";
57
import { Providers } from "./providers";
68
import { GoogleAnalytics } from "@next/third-parties/google";
79
import IconLink from "./components/IconLink";
@@ -34,9 +36,10 @@ export default function RootLayout({
3436
<head>
3537
<IconLink />
3638
</head>
37-
<body className={GeistSans.className}>
39+
<body>
40+
<ColorModeScript initialColorMode={theme.config.initialColorMode} />
3841
<Providers>
39-
<main>{children}</main>
42+
<main className={GeistSans.className}>{children}</main>
4043
</Providers>
4144
</body>
4245
</html>

app/styles/globals.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ body {
22
/* padding: 16px; */
33
height: 100%;
44
margin: 0;
5+
background-color: hsl(var(--background));
6+
color: hsl(var(--text));
57
}
68
html {
79
height: 100%;

app/styles/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const Modal = {
150150

151151
export const theme = extendTheme({
152152
config: {
153-
initialColorMode: "light",
153+
initialColorMode: "dark",
154154
useSystemColorMode: true,
155155
},
156156
styles: {

0 commit comments

Comments
 (0)