Skip to content

Commit

Permalink
Dynamically adjust theme color based on dark or light mode
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed Apr 25, 2024
1 parent 302d173 commit 8017582
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,17 @@ export default function Home() {
console.log("Service Worker not supported");
}
}, []);
useEffect(() => {
if (theme === "dark") {
document
.querySelector('meta[name="theme-color"]')
?.setAttribute("content", "#0f172a");
} else {
document
.querySelector('meta[name="theme-color"]')
?.setAttribute("content", "#fafaf9");
}
}, [theme]);
return (
<div
className="flex h-dvh flex-col items-center justify-between p-0 sm:p-2 lg:p-4 bg-stone-200 dark:bg-slate-800 relative overflow-hidden text-slate-800 dark:text-slate-200"
Expand Down

0 comments on commit 8017582

Please sign in to comment.