React hook to switch between light and dark themes
npm install @heroui/use-themeReact hook to switch between light and dark themes
``sh`
yarn add @heroui/use-themeor
npm i @heroui/use-theme
Import useTheme
`tsx`
import {useTheme} from "@heroui/use-theme";
`tsxtheme
// is the active theme namelight
// by default, it will use the one in localStorage.
// if it is no such value in localStorage, theme will be used`
const {theme} = useTheme();
You can use any theme name you want, but make sure it exists in your
tailwind.config.js file. See Create Theme for more details.
`tsxtheme
// set by using setTheme``
const {setTheme} = useTheme();
// setting to light theme
setTheme('light')
// setting to dark theme
setTheme('dark')
// setting to purple-dark theme
setTheme('purple-dark')
Yes please! See the
contributing guidelines
for details.
This project is licensed under the terms of the
MIT license.