Skip to content

Instantly share code, notes, and snippets.

@kevinsawicki
Last active February 1, 2023 19:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinsawicki/9d05fabdee32105367969bbca259ab3e to your computer and use it in GitHub Desktop.
Save kevinsawicki/9d05fabdee32105367969bbca259ab3e to your computer and use it in GitHub Desktop.
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
Copy link

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

tip: nodeIntegration should be specified

@NetOpWibby
Copy link

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
Copy link

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