Aller au contenu principal

Styles de fenêtre personnalisés

Fenêtre sans cadre

Frameless Window

Une fenêtre sans cadre supprime tous les chrome appliqués par l'OS, y compris les contrôles de fenêtres.

Pour créer une fenêtre sans cadre, définissez le paramètre BaseWindowContructorOptions frame dans le constructeur de BrowserWindow à 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()
})

Sur Wayland (Linux), les fenêtres sans cadre ont des ombres de drop GTK et des limites de redimension étendues par défaut. Pour créer une fenêtre sans cadre avec aucune décoration , définissez hasShadow: false dans les options du constructeur de fenêtre.

Fenêtres transparentes

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 transparent 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()
})