npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

electron-theme-mode

v1.0.1-beta.3

Published

开箱即用的 Electron 暗黑模式支持,整合 DarkReader 与 Electron 生态,提供亮色/暗色/跟随系统三模切换。

Readme

electron-theme-mode

简体中文 | English

electron-theme-mode is a professional theme management solution for Electron applications. Powered by DarkReader, it provides industrial-grade dark mode conversion and ensures a coherent, consistent visual experience throughout your application's lifecycle.

🌟 Key Features

  • 🚀 Instant Visual Synchronization: Applies theme configurations at the earliest stage of page load, ensuring consistent visual style from the very first frame.
  • 🎨 Complete DarkReader Interface: Supports all native parameters including brightness, contrast, grayscale, sepia, text stroke, and custom fonts.
  • 🔄 Global Broadcast: Automatically synchronizes theme changes in real-time across all windows (BrowserWindow) and nested frames (iframes).
  • 🖥️ Dual-Process API: Provides programming interfaces for both Main and Renderer processes, offering flexible theme control from anywhere in your app.
  • 📦 Automatic Persistence: Built-in mechanism to save and restore theme settings, with support for custom adapters to integrate with your existing configuration system.
  • 🛠️ Advanced Fixes: 精细化精细化页面修复功能 including custom CSS injection, ignoring specific stylesheet URLs, and inverting specific selectors.

📦 Installation

npm install electron-theme-mode
# or
yarn add electron-theme-mode

🚀 Quick Start

1. Initialize in Main Process

Enable theme management in your main process entry file.

const { initTheme } = require('electron-theme-mode/main');

initTheme();

2. Expose API in Preload Script

Expose the API using contextBridge in your preload.js.

const { contextBridge } = require('electron');
const { themeMode } = require('electron-theme-mode/preload');

contextBridge.exposeInMainWorld('themeMode', themeMode);

3. Use in Renderer Process

// Set theme configuration
window.themeMode.setTheme({
  mode: 'dark',
  darkReader: {
    brightness: 90,
    contrast: 100
  }
});

// Listen for theme state changes
window.themeMode.onThemeChanged((state) => {
  console.log('Current mode:', state.mode);
  console.log('Is dark:', state.isDark);
});

🛠️ Advanced Usage

iframe Support

To keep iframes synchronized with the theme, enable this option when creating windows:

new BrowserWindow({
  webPreferences: {
    nodeIntegrationInSubFrames: true,
    preload: path.join(__dirname, 'preload.js')
  }
});

Main Process API

const { setTheme, getTheme, resetTheme } = require('electron-theme-mode/main');

// Set theme mode
setTheme({ mode: 'system' });

// Reset to default
resetTheme();

Advanced Page Fixes

Use the fixes configuration to solve display issues for specific elements:

Force Invert

Useful for dark icons or elements that are hard to see on dark backgrounds.

window.themeMode.setTheme({
  mode: 'dark',
  fixes: {
    invert: ['.sidebar-icon', '.logo-dark'] // These selectors will be forced to invert
  }
});

Ignore Conversion

Keep a specific area in its original light appearance (e.g., color pickers or preview zones):

window.themeMode.setTheme({
  mode: 'dark',
  fixes: {
    // Option A: Override colors by injecting CSS (Recommended)
    css: `
      .keep-light-zone { 
        background-color: #ffffff !important; 
        color: #333333 !important; 
      }
    `,
    // Option B: Ignore inline style processing for the area
    ignoreInlineStyle: ['.keep-light-zone']
  }
});

📖 API Reference

ThemeConfig

| Property | Type | Description | | :--- | :--- | :--- | | mode | 'light' \| 'dark' \| 'system' | Theme mode: light, dark, or follow system | | darkReader | DarkReaderTheme | [Optional] DarkReader display parameters | | fixes | DarkReaderFixes | [Optional] Page fix settings |

DarkReaderTheme (Common)

| Property | Description | Default | | :--- | :--- | :--- | | brightness | Brightness (0-200) | 100 | | contrast | Contrast (0-200) | 100 | | grayscale | Grayscale (0-100) | 0 | | sepia | Sepia (0-100) | 0 | | fontFamily | Custom font family | '' | | textStroke | Text stroke (0-1px) | 0 | | scrollbarColor | Custom scrollbar color | auto | | selectionColor | Selection highlight color | auto |


📄 License

MIT License.