react-context-themify
v0.1.4
Published
The purpose of this package is to provide a simple way to change the theme of your application using React Context.
Downloads
5
Readme
React Context Themify
The purpose of this package is to provide a simple way to change the theme of your application using React Context.
🚀 Technologies
🖥️ How to use
ThemeProvider is a React Component to involve your application and provide the theme context
import { ThemeProvider } from 'react-context-themify';
const App = () => {
return (
<ThemeProvider>
<html lang="en">
<body>
<ThemeProvider>{children}</ThemeProvider>
</body>
</html>
</ThemeProvider>
);
};
UseThemeContext is a React Hook to get the current theme and change it
import { useThemeContext } from 'react-context-themify';
const Component = () => {
const { themeName, toggleTheme } = useThemeContext();
return (
<div>
<p>Current theme: {themeName}</p>
<button onClick={toggleTheme}>Toggle theme</button>
</div>
);
};
🗒️Note
This package is not working with Next.js yet.
Developed By: