mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 07:38:29 -04:00
30 lines
775 B
TypeScript
30 lines
775 B
TypeScript
import { memo } from "react";
|
|
import { useTheme } from "next-themes";
|
|
import { BulbOffIcon, BulbOnIcon } from "../icons";
|
|
|
|
const ThemeToggle = ({ className = "" }) => {
|
|
const { resolvedTheme, setTheme } = useTheme();
|
|
|
|
return (
|
|
<button
|
|
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
|
|
title={resolvedTheme === "dark" ? "Toggle Light Mode" : "Toggle Dark Mode"}
|
|
aria-hidden={true}
|
|
style={{
|
|
border: 0,
|
|
padding: 0,
|
|
background: "none",
|
|
cursor: "pointer",
|
|
}}
|
|
>
|
|
{resolvedTheme === "dark" ? (
|
|
<BulbOffIcon className={`icon ${className}`} />
|
|
) : (
|
|
<BulbOnIcon className={`icon ${className}`} />
|
|
)}
|
|
</button>
|
|
);
|
|
};
|
|
|
|
export default memo(ThemeToggle);
|