"use client"; import { useEffect, useState, type ComponentProps, type SVGProps } from "react"; import { useTheme } from "fumadocs-ui/provider/base"; /** * Two-icon theme switcher (light / dark), each icon selecting its own theme — * unlike fumadocs' default "light-dark" switcher, which is a single blind * toggle that flips on any click. Dropped into the sidebar footer pill via * `slots.themeSwitch`, so fumadocs passes the container className (left * divider, `ms-auto`, rounded inner buttons); we merge it onto our own base. * * Icons are inlined (the project doesn't depend on `lucide-react` directly); * `useTheme` is re-exported by fumadocs so we avoid a bare `next-themes` import. */ function SunIcon(props: SVGProps) { return ( ); } function MoonIcon(props: SVGProps) { return ( ); } const OPTIONS = [ ["light", SunIcon], ["dark", MoonIcon], ] as const; function cx(...classes: (string | false | undefined)[]): string { return classes.filter(Boolean).join(" "); } export function ThemeToggle({ className, ...props }: ComponentProps<"div">) { const { setTheme, resolvedTheme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => setMounted(true), []); const active = mounted ? resolvedTheme : null; return (
{OPTIONS.map(([key, Icon]) => ( ))}
); }