0.0.4 • Published 1 year ago
@themetransition/react v0.0.4
@themetransition/react

Check out the Live Example to try it for yourself.
Install
$ npm install @themetransition/react
# or
$ yarn add @themetransition/reactUsage
import { ThemeTransitionProvider } from "@themetransition/react"
function MyApp({ children }) {
return (
<html>
<head />
<body>
<ThemeTransitionProvider duration={0.9}>{children}</ThemeTransitionProvider>
</body>
</html>
)
}
export default MyAppuseTheme
Your UI will need to know the current theme and be able to change it. The useTheme hook provides theme information:
import { useTheme } from "next-themes"
import { useThemeTransition } from "@themetransition/react"
const ThemeChanger = () => {
const { theme, setTheme } = useTheme()
const { handleThemeChange } = useThemeTransition({
setTheme,
theme
})
return (
<div>
The current theme is: {theme}
<button onClick={handleThemeChange("light")}>Light Mode</button>
<button onClick={handleThemeChange("dark")}>Dark Mode</button>
</div>
)
}