23

I would like to change the color of the titlebar for the windows version of my electron app. currently it is white, how do I change it to, for example, blue? enter image description here

Daniel
  • 667
  • 2
  • 11
  • 25

6 Answers6

29

There's no way at the moment to customize the native titlebar. So, first step is to hide the native titlebar by telling your BrowserWindow to hide the frame (that would also hide the menubar).

mainWindow = new BrowserWindow({
    frame: false
})

see: https://electronjs.org/docs/api/browser-window

Then, you should create your custom titlebar (or import a third party library like 1 or 2) in HTML, CSS and JS. That way, the titlebar lives under the renderer process in Electron. So, to actually for example quit your application when clicking the X button, you should take advantage of the IPC to send an event to the main process and quit the application.

Example:

# renderer
ipcRenderer.send('app:quit')

# main
ipcMain.on('app:quit', () => { app.quit() })

Or as an alternative: look this answer here on StackOverflow

lucgenti
  • 368
  • 5
  • 14
8

actually now there is a way
take a look here, a lot of electron apps use it so I think is a win win...
just make sure to install this first

npm i custom-electron-titlebar
Egon Stetmann.
  • 461
  • 6
  • 14
  • It is not outdated. You linked a package. It does not make it an official way of customizing the titlebar and does not integrate natively with the OS: https://github.com/AlexTorresSk/custom-electron-titlebar/blob/fafae41008d8af406ba1285dffb5818a23bd5113/src/themebar.ts#L547 – Romeo Mihalcea Nov 11 '20 at 21:24
5

Now can hide the title bar and set the color of buttons in Windows with:

//main.js
const { BrowserWindow } = require('electron')
const win = new BrowserWindow({
  titleBarStyle: 'hidden',
  titleBarOverlay: {
    color: '#2f3241',
    symbolColor: '#74b1be'
  }
})

see Docs for more informations.

Yu ZHANG
  • 51
  • 1
  • 1
4

You must hide the window-title bar and build a new window title bar in html,css,js..

Robin Lindner
  • 515
  • 6
  • 13
1

Here is the Answer:-

// Create the browser window.
const mainWindow = new BrowserWindow({
    titleBarStyle: 'hidden',
    titleBarOverlay: {
        // color of titile bar
        color: '#3b3b3b',
        // color of titile bar control
        symbolColor: '#74b1be',
        // height of titile bar
        height: 32
    },
});

Refence: Electron Docs

-2
mainWindow = new BrowserWindow({
    width: 1000,
    height: 800,
    titleBarStyle: "hiddenInset"
})

https://electronjs.org/docs/api/frameless-window

Lucas Lima
  • 11
  • 3