Skip to content

Instantly share code, notes, and snippets.

@kotsutsumi
Last active October 26, 2024 17:33
Show Gist options
  • Save kotsutsumi/5cd0648280992a088f5124439682959e to your computer and use it in GitHub Desktop.
Save kotsutsumi/5cd0648280992a088f5124439682959e to your computer and use it in GitHub Desktop.
ThemeToggleButton Component with ParkUI
'use client'
/**
* ThemeToggleButton Component
*
* npm install next-themes react-icons --force
*/
import { useTheme } from 'next-themes'
import { MdOutlineDarkMode, MdOutlineLightMode } from 'react-icons/md'
import { Button } from '../button'
export default function ThemeToggleButton() {
const { theme, setTheme } = useTheme()
return (
<div>
<Button
variant="ghost"
onClick={() => {
if (theme === 'light') {
setTheme('dark')
} else {
setTheme('light')
}
}}
>
{theme !== 'light' ? <MdOutlineLightMode /> : <MdOutlineDarkMode />}
</Button>
</div>
)
}
// EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment