Files
stack/apps/web/src/components/layout/ThemeToggle.tsx
Jason Woltje a5ed260fbd
All checks were successful
ci/woodpecker/push/web Pipeline was successful
feat(web): MS15 Phase 1 — Design System & App Shell (#451)
Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
2026-02-22 20:57:06 +00:00

48 lines
1.4 KiB
TypeScript

"use client";
import { useTheme } from "@/providers/ThemeProvider";
interface ThemeToggleProps {
className?: string;
}
export function ThemeToggle({ className = "" }: ThemeToggleProps): React.JSX.Element {
const { resolvedTheme, toggleTheme } = useTheme();
return (
<button
onClick={toggleTheme}
className={`btn-ghost rounded-md p-2 ${className}`}
title={`Switch to ${resolvedTheme === "dark" ? "light" : "dark"} mode`}
aria-label={`Switch to ${resolvedTheme === "dark" ? "light" : "dark"} mode`}
>
{resolvedTheme === "dark" ? (
// Sun icon for dark mode (click to switch to light)
<svg
className="h-5 w-5"
style={{ color: "var(--warn)" }}
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={1.5}
>
<circle cx="12" cy="12" r="4" />
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" />
</svg>
) : (
// Moon icon for light mode (click to switch to dark)
<svg
className="h-5 w-5"
style={{ color: "var(--text-2)" }}
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={1.5}
>
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" />
</svg>
)}
</button>
);
}