Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set color of windows titlebar - electron.js

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

like image 606
Daniel Avatar asked Sep 14 '17 14:09

Daniel


People also ask

How do I change the color of the title bar in Electron JS?

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). Then, you should create your custom titlebar (or import a third party library like 1 or 2) in HTML, CSS and JS.

What is Kiosk mode Electron?

Kiosk mode is a common way to lock down a Windows device when that device is used for a specific task or used in a public setting. So in electron kiosk mode, we'd have the ability to lock down our application to a point that users are restricted to the actions that we want them to perform.

How do you hide the title bar of an Electron?

When you set the titleBarStyle property to hidden , you instruct Electron to hide the title bar but leave the traffic light controls in the top-left corner. This allows us to continue controlling the look and feel of the application window but preserve the behavior behind the control buttons.


1 Answers

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

like image 57
lucgenti Avatar answered Oct 15 '22 06:10

lucgenti