Something went wrong. Try again.
A plug-and-play dashboard for all your self-hosted services
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980"use client";
import { Monitor, Moon, Sun } from "lucide-react";import { AnimatePresence, motion } from "motion/react";import { useTranslations } from "next-intl";import { useTheme } from "next-themes";import { useEffect, useState } from "react";import { Button } from "@/src/components/ui/button";import { Tooltip, TooltipContent, TooltipTrigger,} from "@/src/components/ui/tooltip";
export function ThemeToggle() { const { theme, setTheme } = useTheme(); const t = useTranslations(); const [isClient, setIsClient] = useState(false);
useEffect(() => { setIsClient(true); }, []);
if (!isClient) return null;
return ( <Tooltip> <TooltipTrigger asChild> <Button variant="ghost" size="icon" onClick={() => { if (theme === "light") setTheme("dark"); else if (theme === "dark") setTheme("system"); else setTheme("light"); }} aria-label={t("theme.title")} > <AnimatePresence mode="wait"> {theme === "light" && ( <motion.div initial={{ scale: 0.75, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.75, opacity: 0 }} transition={{ duration: 0.15, ease: "easeInOut" }} key="light" > <Sun /> </motion.div> )} {theme === "dark" && ( <motion.div initial={{ scale: 0.75, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.75, opacity: 0 }} transition={{ duration: 0.15, ease: "easeInOut" }} key="dark" > <Moon /> </motion.div> )} {theme === "system" && ( <motion.div initial={{ scale: 0.75, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.75, opacity: 0 }} transition={{ duration: 0.15, ease: "easeInOut" }} key="system" > <Monitor /> </motion.div> )} </AnimatePresence> </Button> </TooltipTrigger> <TooltipContent>{t("tooltips.toggleTheme")}</TooltipContent> </Tooltip> );}