e30e75b5d4
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Changesets / Create Version PR (push) Has been cancelled
36 lines
873 B
TypeScript
36 lines
873 B
TypeScript
"use client";
|
|
|
|
import { useTheme } from "next-themes";
|
|
import { useEffect, useState } from "react";
|
|
import { Moon, Sun } from "lucide-react";
|
|
|
|
export function ThemeToggle() {
|
|
const { resolvedTheme, setTheme } = useTheme();
|
|
const [mounted, setMounted] = useState(false);
|
|
|
|
useEffect(() => setMounted(true), []);
|
|
|
|
const toggleTheme = () => {
|
|
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
};
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={toggleTheme}
|
|
className="text-muted-foreground hover:text-foreground flex size-8 items-center justify-center transition-colors"
|
|
aria-label="Toggle theme"
|
|
>
|
|
{mounted ? (
|
|
resolvedTheme === "dark" ? (
|
|
<Moon className="size-4" />
|
|
) : (
|
|
<Sun className="size-4" />
|
|
)
|
|
) : (
|
|
<div className="size-4" />
|
|
)}
|
|
</button>
|
|
);
|
|
}
|