Skip to content

meshal10613/theme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 theme

A lightweight and versatile theme manager that allows you to set, get, and control themes across JavaScript, TypeScript, React, Next.js, and Node.js, including support for system default theme detection.


🚀 Installation

Using npm:

npm i @meshal10613/theme

Or using yarn:

yarn add @meshal10613/theme

🧠 Usage

CommonJS (Node.js)

const { setTheme, getTheme } = require('@meshal10613/theme');

setTheme("dark");
console.log(getTheme()); // "dark"

ES Module (if your project uses "type": "module")

import { setTheme, getTheme } from '@meshal10613/theme';

setTheme("light");
console.log(getTheme()); // "light"

🧩 API

square(number)

Function Parameter Type Description
setTheme(theme) "light" "dark" "system"
getTheme() - "light" "dark"
Supported Themes

"light" — Light mode

"dark" — Dark mode

"system" — Follows system preference

🧪 Examples

setTheme("dark");
console.log(getTheme()); // "dark"

setTheme("system");
console.log(getTheme()); // "light" or "dark" depending on system settings

⚙️ Validation Details

  • ✅ Works in frontend (React, Next.js) and backend (Node.js)
  • ✅ Supports CommonJS and ES Modules
  • ✅ Automatically respects system dark/light mode
  • ✅ Minimal and dependency-free
  • ✅ Simple API for quick theme control

📦 Why Use This?

✅ Minimal and dependency-free ✅ Type-safe input validation ✅ Works in both CommonJS and ESM environments ✅ Great for small math utilities or teaching purposes

🧰 Project Structure

theme/
├── src/
│   ├── index.ts        # main entry
│   └── themeManager.ts # theme logic
├── dist/               # compiled files (CJS + ESM)
├── tests/
│   └── theme.test.ts   # tests
├── package.json
├── tsconfig.json
└── README.md

📝 License

MIT License © 2025 Syed Mohiuddin Meshal

🌐 Links

NPM: https://www.npmjs.com/package/@meshal10613/theme

GitHub Repository: https://github.com/meshal10613/theme

About

A lightweight theme manager for JavaScript, TypeScript, React, Next.js, and Node.js. Easily set, get, and control themes including system default.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors