Installation

npm install nayan yarn add nayan bun install nayan
Include module in `tailwind.config.js` to read tailwind classes, this will help in reusing same tailwind classes.
module.exports = { darkMode: ['class'], content: ['./src/**/*.{ts,tsx}', './index.html', './node_modules/nayan/dist/index.es.js'], // Check node_modules path properly theme: { extend: { colors: { primary: 'var(--COLOR_PRIMARY)', 'primary-light': 'var(--COLOR_PRIMARY_LIGHT)', 'primary-dark': 'var(--COLOR_PRIMARY_DARK)', background: 'var(--COLOR_BACKGROUND)', text: 'var(--COLOR_TEXT)', muted: 'var(--COLOR_MUTED)', border: 'var(--COLOR_BORDER)', card: 'var(--COLOR_CARD)', shadow: 'var(--COLOR_SHADOW)', overlay: 'var(--COLOR_OVERLAY)' } } }, plugins: [require('tailwindcss-animate')] };
Add library styles to `index.css`, and update theme color variables accordingly for both light and dark modes.
@import 'nayan/dist/style.css'; @tailwind base; @tailwind components; @tailwind utilities; @layer base { :root { --COLOR_PRIMARY: #005ee6; --COLOR_PRIMARY_DARK: #0043a3; --COLOR_PRIMARY_LIGHT: #0069ff; --COLOR_BACKGROUND: #f0f2f5; --COLOR_CARD: #ffffff; --COLOR_TEXT: #050505; --COLOR_MUTED: 'gray'; --COLOR_BORDER: #e0e0e0; --COLOR_SHADOW: #d3d3d3; --COLOR_OVERLAY: rgba(255, 255, 255, .7); } [data-theme='dark'] { --COLOR_PRIMARY: #2997ff; --COLOR_PRIMARY_DARK: #0a84ff; --COLOR_PRIMARY_LIGHT: #7dc1ff; --COLOR_BACKGROUND: #1f1f1f; --COLOR_CARD: #353535; --COLOR_TEXT: #f5f5f5; --COLOR_MUTED: #afafaf; --COLOR_BORDER: #4f4f4f; --COLOR_SHADOW: #cbcbcb; --COLOR_OVERLAY: rgba(0, 0, 0, .7); } body { color: var(--COLOR_TEXT) !important; background-color: var(--COLOR_BACKGROUND) !important; } }

Usage

import { useState } from 'react'; import { NTheme, THEMES, useLocalStorage } from 'nayan'; const App = () => { const [theme, setTheme] = useLocalStorage('THEME', THEMES.LIGHT); const toggleTheme = () => { setTheme(theme === THEMES.LIGHT ? THEMES.DARK : THEMES.LIGHT); }; return ( <NTheme theme={theme}> <div className="p-3" onClick={toggleTheme}>TOGGLE THEME</div> </NTheme> ); }; export default App;