Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/context/ThemeContext.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-refresh/only-export-components */
import React, { createContext, useState, useEffect } from "react";
import React, { createContext, useState, useLayoutEffect } from "react";

export const ThemeContext = createContext();

Expand All @@ -13,7 +13,8 @@ export const ThemeProvider = ({ children }) => {
return systemPrefersDark ? "dark" : "light";
});

useEffect(() => {
// Sync theme to DOM synchronously on mount (before paint)
useLayoutEffect(() => {
const root = window.document.documentElement;
if (theme === "dark") {
root.classList.add("dark");
Expand Down
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@layer base {
body {
font-family: 'Outfit', 'Inter', system-ui, sans-serif;
@apply bg-slate-50 text-slate-800 antialiased transition-colors duration-300;
@apply bg-slate-50 text-slate-800 antialiased;
}

body.dark {
Expand Down
Loading