2024-05-17 09:16:20 +00:00
|
|
|
// app/components/ThemeSwitcher.tsx
|
|
|
|
"use client";
|
|
|
|
|
|
|
|
import { Button } from "@nextui-org/button";
|
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
export function ThemeSwitcher() {
|
|
|
|
const [mounted, setMounted] = useState(false);
|
|
|
|
const { theme, setTheme } = useTheme();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setMounted(true);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
if (!mounted) return null;
|
|
|
|
|
|
|
|
return (
|
2024-05-17 09:31:09 +00:00
|
|
|
<div className="flex gap-2 items-center my-2">
|
2024-05-17 09:16:20 +00:00
|
|
|
The current theme is: {theme}
|
|
|
|
<Button onClick={() => setTheme("light")}>Light Mode</Button>
|
|
|
|
<Button onClick={() => setTheme("dark")}>Dark Mode</Button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|