You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
683 B
33 lines
683 B
"use client";
|
|
|
|
import { Switch } from "@nextui-org/react";
|
|
import { Component } from "@typings/component";
|
|
import { useTheme } from "next-themes";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { FiMoon, FiSun } from "react-icons/fi";
|
|
|
|
export const ThemeSwitcher: Component = () => {
|
|
const [mounted, setMounted] = useState(false);
|
|
const { theme, setTheme } = useTheme();
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) return null;
|
|
|
|
return (
|
|
<Switch
|
|
defaultSelected
|
|
size="lg"
|
|
color="primary"
|
|
onValueChange={(value) => {
|
|
value ? setTheme("dark") : setTheme("light");
|
|
}}
|
|
startContent={<FiSun />}
|
|
endContent={<FiMoon />}
|
|
/>
|
|
);
|
|
};
|