MIT-licensed Electron toolkit for native macOS visual effects
Electrolyx brings native macOS window customization and visual effects to Electron applications, including rounded corners and glass/vibrancy effects.
- Custom Window Corners: Apply native-style rounded corners to Electron windows
- Vibrancy/Glass Effects: Create translucent UI elements with blur using native
NSVisualEffectView - Window Transparency: Full control over window background transparency
- TypeScript Support: Full type definitions included
- MIT Licensed: Completely free for any project
npm install electrolyx- macOS 10.13 (High Sierra) or later
- Electron 20.0.0 or later
- Node.js 16.0.0 or later
- Xcode Command Line Tools (for building native module)
import { app, BrowserWindow } from 'electron';
import { setWindowCornerRadius, addVibrancyView, setWindowTransparent } from 'electrolyx';
function createWindow() {
const window = new BrowserWindow({
width: 800,
height: 600,
transparent: true,
titleBarStyle: 'hiddenInset'
});
window.once('ready-to-show', () => {
// Set custom rounded corners
setWindowCornerRadius(window, 16);
// Make background transparent
setWindowTransparent(window);
// Add sidebar with vibrancy effect
addVibrancyView(window, {
x: 0,
y: 0,
width: 250,
material: 'sidebar',
cornerRadius: 16
});
window.show();
});
}
app.whenReady().then(createWindow);Set custom corner radius for a window.
Parameters:
window(BrowserWindow) - Electron BrowserWindow instanceradius(number) - Corner radius in points
Returns: boolean - true if successful
Note: This uses private macOS APIs and may break in future macOS versions.
setWindowCornerRadius(mainWindow, 16);Get the current corner radius of a window.
Parameters:
window(BrowserWindow) - Electron BrowserWindow instance
Returns: number - Current corner radius in points
const radius = getWindowCornerRadius(mainWindow);Add a native vibrancy (blur/glass) effect view to a window.
Parameters:
window(BrowserWindow) - Electron BrowserWindow instanceoptions(VibrancyViewOptions) - Configuration options
VibrancyViewOptions:
interface VibrancyViewOptions {
x?: number; // Default: 0
y?: number; // Default: 0
width?: number; // Default: 200
height?: number; // Default: window height
material?: VibrancyMaterial; // Default: 'sidebar'
blendingMode?: BlendingMode; // Default: 'behindWindow'
state?: VibrancyState; // Default: 'followsWindowActiveState'
cornerRadius?: number; // Default: 0
autoresizingMask?: {
width?: boolean;
height?: boolean;
minX?: boolean;
maxX?: boolean;
minY?: boolean;
maxY?: boolean;
};
}Material Types:
'titlebar'- Title bar appearance'sidebar'- Sidebar appearance (default)'menu'- Menu appearance'popover'- Popover appearance'hudWindow'- HUD window appearance'sheet'- Sheet appearance'tooltip'- Tooltip appearance'underWindowBackground'- Under window background
Example:
addVibrancyView(mainWindow, {
x: 0,
y: 0,
width: 250,
height: 700,
material: 'sidebar',
blendingMode: 'behindWindow',
cornerRadius: 16,
autoresizingMask: {
height: true // Resize with window height
}
});Set the background color of a window.
Parameters:
window(BrowserWindow) - Electron BrowserWindow instancecolor(RGBColor) - Color object with r, g, b values (0-1)
setWindowBackgroundColor(mainWindow, {
r: 1.0,
g: 1.0,
b: 1.0,
a: 0.95
});Make a window background completely transparent.
Parameters:
window(BrowserWindow) - Electron BrowserWindow instance
setWindowTransparent(mainWindow);const window = new BrowserWindow({
width: 800,
height: 600,
transparent: true,
frame: false
});
window.once('ready-to-show', () => {
setWindowCornerRadius(window, 20);
setWindowTransparent(window);
window.show();
});addVibrancyView(mainWindow, {
x: 0,
y: 0,
width: 250,
material: 'sidebar',
cornerRadius: 16,
autoresizingMask: {
height: true // Auto-resize with window
}
});See the example/ directory for a full working Electron app demonstrating all features.
To run the example:
npm run build
cd example
npm install
npm startThe setWindowCornerRadius() function uses private macOS APIs that are:
- Not documented by Apple
- Not guaranteed to work across macOS versions
- May change or be removed in future updates
- Could potentially be rejected in Mac App Store submissions
Use at your own risk and always test thoroughly on target macOS versions.
The vibrancy features use public NSVisualEffectView APIs that are:
- Officially documented by Apple
- Stable across macOS versions
- Safe for Mac App Store submissions
# Install dependencies
npm install
# Build native module and TypeScript
npm run build
# Or build separately
npm run build:native
npm run build:tsIf you encounter build errors like clang: error: no such file or directory during npm install, this is likely due to node-gyp not properly handling paths with spaces (e.g., "Personal Projects", "My Documents").
Workaround:
-
Copy the project to a temporary location without spaces:
cp -R /path/with spaces/electrolyx ~/electrolyx-temp cd ~/electrolyx-temp rm -rf build node_modules npm install
-
Copy the compiled module back to your original location:
cp ~/electrolyx-temp/build/Release/electrolyx.node /path/with spaces/electrolyx/build/Release/ cp -R ~/electrolyx-temp/node_modules /path/with spaces/electrolyx/
-
Install example dependencies without rebuilding:
cd /path/with spaces/electrolyx/example npm install --ignore-scripts
Alternative: Move your project to a path without spaces for easier development.
- macOS: Full support (10.13+)
- Windows: Not supported
- Linux: Not supported
The library will gracefully fail on non-macOS platforms.
Full TypeScript definitions are included. Import types as needed:
import { VibrancyViewOptions, VibrancyMaterial, BlendingMode } from 'electrolyx';Contributions are welcome! Please feel free to submit issues and pull requests.
MIT License - see LICENSE file for details
This library uses undocumented macOS APIs for certain features. While we strive for compatibility:
- Features may break with macOS updates
- No warranties or guarantees provided
- Use in production at your own risk
- Always test on target macOS versions
For mission-critical applications, consider commercial alternatives with professional support.
