1.4.1 • Published 1 year ago
@paalan/react-providers v1.4.1
Paalan React UI Providers
This package contains the providers for the Paalan React UI.
Installation
npm install @paalan/react-providersUsage
ThemeProvider - For React Framework
- Import the
ThemeProvidercomponent from@paalan/react-providers/ThemeProviderand use them in your project.
import React from 'react';
import ReactDOM from 'react-dom/client';
import { ThemeProvider } from '@paalan/react-providers/ThemeProvider';
import { App } from './App';
const root = ReactDOM.createRoot(document.getElementById('root')!);
const Root = () => {
return (
<React.StrictMode>
<ThemeProvider>
<App />
</ThemeProvider>
</React.StrictMode>
);
};
root.render(<Root />);- Import the
useThemehook from the@paalan/react-providers/ThemeProviderand use them in your project.
import { useTheme } from '@paalan/react-providers/ThemeProvider';
export const App = () => {
const theme = useTheme();
return (
<div style={{ backgroundColor: theme.isDark ? 'black' : 'white' }}>
<h1 style={{ color: theme.isDark ? 'white' : 'black' }}>Hello, World!</h1>
</div>
);
};NextThemeProvider - For Next.js Framework
- Import the
NextThemeProvidercomponent from@paalan/react-providers/NextThemeProviderand use them in your project.
import { NextThemeProvider } from '@paalan/react-providers/NextThemeProvider';
import { App } from './App';
const Root = () => {
return (
<NextThemeProvider>
<App />
</NextThemeProvider>
);
};
export default Root;- Import the
useNextThemehook from@paalan/react-providers/NextThemeProviderand use them in your project.
import { useNextTheme } from '@paalan/react-providers/NextThemeProvider';
export const App = () => {
const theme = useNextTheme();
return (
<div style={{ backgroundColor: theme.isDark ? 'black' : 'white' }}>
<h1 style={{ color: theme.isDark ? 'white' : 'black' }}>Hello, World!</h1>
</div>
);
};