I'm very new to Electron and Node.js so forgive any misuse of the terminology.
I'm working on a Windows 10 application. I'm trying to gain the ability to customize the title bar area of my app (along the lines of other Electron apps like Github Desktop or Discord).
From what I found by searching and reading, there are two ways to do this: Do a frameless window and create all the elements yourself including the window control buttons OR do a frameless window and use the Window Controls Overlay (titleBarOverlay
). I would prefer to do the latter just because it's less code and the few parameters titleBarOverlay
has is enough to get the buttons to look the way I want.
The problem is that the overlay leaves a 1px gap around the buttons and I can't find a way to adjust the position of the overlay. This is what the window buttons look like (red title bar for contrast:
This is the window creation code in main.js
:
const createWindow = () => {
const win = new BrowserWindow({
width: 1100,
height: 900,
webPreferences: {
preload: path.join(__dirname, "preload.js")
},
backgroundColor: "#0a0a0a",
frame: false,
titleBarStyle: 'hidden',
titleBarOverlay: {
color: '#323232',
symbolColor: '#ffffff',
height: 30
}
})
win.loadFile("index.html");
}
The style in index.html
includes this (title_bar
is just a div directly under the body
element):
body {
border: none;
margin: 0px;
padding: 0px;
}
#title_bar {
-webkit-app-region: drag;
height: 30px;
background-color: red;
}
Is there a way to get rid of this gap? If not, is the preferred method of accomplishing the look I want to add in the window buttons manually as mentioned above?
I have not been able to find much documentation on titleBarOverlay
. Is this a very new feature? Or a feature that is being phased out?