t-convex-nextjs-saas/src/components/core/ThemeChanger.tsx

29 lines
626 B
TypeScript
Raw Normal View History

2026-03-27 23:15:07 +00:00
"use client";
import { useTheme } from "@wrksz/themes/client";
import { useEffect, useState } from "react";
2026-03-27 23:15:07 +00:00
export const ThemeChanger = () => {
const { theme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return <p>Loading theme...</p>;
}
2026-03-27 23:15:07 +00:00
return (
<div>
<p>The current theme is: {theme}</p>
<button type="button" onClick={() => setTheme("light")}>
Light Mode
</button>
<button type="button" onClick={() => setTheme("dark")}>
Dark Mode
</button>
2026-03-27 23:15:07 +00:00
</div>
);
};