Aller au contenu principal

Custom Window Styles

Frameless windows

Frameless Window

A frameless window removes all chrome applied by the OS, including window controls.

To create a frameless window, set the BaseWindowContructorOptions frame param in the BrowserWindow constructor to false.

const { app, BrowserWindow } = require('electron')

function createWindow () {
const win = new BrowserWindow({
width: 300,
height: 200,
frame: false
})
win.loadURL('https://example.com')
}

app.whenReady().then(() => {
createWindow()
})

Transparent windows

Transparent Window Transparent Window in macOS Mission Control

To create a fully transparent window, set the BaseWindowContructorOptions transparent param in the BrowserWindow constructor to true.

The following fiddle takes advantage of a tranparent window and CSS styling to create the illusion of a circular window.

const { app, BrowserWindow } = require('electron')

function createWindow () {
const win = new BrowserWindow({
width: 100,
height: 100,
resizable: false,
frame: false,
transparent: true
})
win.loadFile('index.html')
}

app.whenReady().then(() => {
createWindow()
})

Limitations

  • Vous ne pouvez pas cliquer dans la zone transparente. See #1335 for details.
  • Les fenêtres transparentes ne sont pas redimensionnables. Setting resizable to true may make a transparent window stop working on some platforms.
  • The CSS blur() filter only applies to the window's web contents, so there is no way to apply blur effect to the content below the window (i.e. other applications open on the user's system).
  • La fenêtre ne sera pas transparente lorsque les DevTools sont ouverts.
  • On Windows:
    • Les fenêtres transparentes ne fonctionneront pas lorsque DWM est désactivé.
    • Transparent windows can not be maximized using the Windows system menu or by double clicking the title bar. The reasoning behind this can be seen on PR #28207.
  • On macOS:
    • L'ombre native de la fenêtre ne sera pas affichée sur une fenêtre transparente.