Electron frame false
This is the macOS only alternative. It removes the titlebar but leaves the stop light buttons.
mainWindow = new BrowserWindow({titleBarStyle: 'hidden', width: 1281, height: 800, minWidth: 1281, minHeight: 800})
Using this setting the app would look like this on macOS from Yosemite(10.10) and newer. On Windows and Linux there will be no change at all.
I like the option to remove the titlebar on macOS and leaving it as is on Linux and Windows. So i’m going for the titleBarStyle: ‘hidden’ setting.
There is also a titleBarStyle: ‘hidden-inset’. The docs explain it like this:
"results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge."
As said earlier, when using frameless window the user looses the ability to drag your application around the desktop. Let’s fix that. Electron handles this with css.
To make the whole window draggable you can set -webkit-app-region: drag on the body element. To do that in the electron tutorial app open up assets/sass/base/_page.scss and add this to the body.
body {
-ms-overflow-style: scrollbar;
-webkit-app-region:drag;
}
This makes our window draggable again. But it makes it a little to much draggable. For example the buttons will be draggable and the user won’t be able to click them. We’ll fix this with -webkit-app-region: no-drag; open up assets/sass/components/_button.scss and that property to button, textarea and input types submit, reset, button and text.
input[type="submit"],
input[type="reset"],
input[type="button"],
input[type="text"],
button,
textarea {
-webkit-app-region: no-drag;
}
If you implement your own titlebar and the user tries to move your app by dragging it the text in the titlebar may become selected. And we don’t want that. we can set this with -webkit-user-select: none; The electron tutorial app uses h1 as some kind of titlebar. Let’s remove the users ability to select headers.
Open up assets/sass/base/_typography.scss and go down to line 57 where you add this:
h1, h2, h3, h4, h5, h6 {
-webkit-user-select: none;
...
You can read more about Frameless window at the official docs or you can continue this tutorial with the Electron white screen app startup.
I hope you find this post valuable. If you click the ad below I get paid by someone else and can continue to publish posts for free. I would appreciate it very much.