0.1.4 โ€ข Published 6 months ago

react-context-themify v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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:

0.1.4

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago