Skip to content

Instantly share code, notes, and snippets.

@kevinsawicki
Last active Jan 22, 2021
Embed
What would you like to do?
Electron Vibrancy Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vibrancy Example</title>
<style>
* {
color: rgba(100, 100, 100, 0.9);
}
h1 {
color: rgba(0, 0, 0, 0.9);
}
</style>
</head>
<body>
<h1>Vibrancy Example</h1>
<p>You can specify the vibrancy by either passing a <code>vibrancy</code> option to <code>new BrowserWindow(options)</code>
or by calling <code>BrowserWindow.setVibrancy(vibrancyType)</code>.
</p>
<form>
<p><b>Vibrancy Type</b></p>
<input type="radio" name="vibrancy" onclick="require('electron').remote.getCurrentWindow().setVibrancy()" checked>None<br>
<input type="radio" name="vibrancy" onclick="require('electron').remote.getCurrentWindow().setVibrancy('light')">Light<br>
<input type="radio" name="vibrancy" onclick="require('electron').remote.getCurrentWindow().setVibrancy('medium-light')">Medium Light<br>
<input type="radio" name="vibrancy" onclick="require('electron').remote.getCurrentWindow().setVibrancy('dark')">Dark<br>
<input type="radio" name="vibrancy" onclick="require('electron').remote.getCurrentWindow().setVibrancy('ultra-dark')">Ultra Dark<br>
</form>
</body>
</html>
const {app, BrowserWindow} = require('electron')
let window
app.on('ready', () => {
window = new BrowserWindow()
window.loadURL(`file://${__dirname}/index.html`)
})
@magicdawn

This comment has been minimized.

Copy link

@magicdawn magicdawn commented Jan 10, 2020

window = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
    },
  })

tip: nodeIntegration should be specified

@NetOperatorWibby

This comment has been minimized.

Copy link

@NetOperatorWibby NetOperatorWibby commented Feb 4, 2020

Note that appearance-based, light, dark, medium-light, and ultra-dark have been deprecated and will be removed in an upcoming version of macOS.

https://www.electronjs.org/docs/api/browser-window#winsetvibrancytype-macos

@dhamberlin

This comment has been minimized.

Copy link

@dhamberlin dhamberlin commented Jan 22, 2021

BrowserWindow needs these options for this example to work as of electron 11.2.0 and macos Catalina:

window = new BrowserWindow({
  transparent: true,
  webPreferences: {
    enableRemoteModule: true,
    nodeIntegration: true
  }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment