Electron Applies a 1px Border Surrounding the titleBarOverlay

I am completely new to Electron and Node.js, so please forgive me if I misuse any terminology.

Currently, I am developing a Windows 10 application and I would like to customize the title bar area of my app similar to other Electron applications such as Github Desktop or Discord.

After doing some research, I have come across two methods to achieve this: one is to create a frameless window and manually design all the elements including the window control buttons, and the other is to use the Window Controls Overlay (titleBarOverlay). Personally, I prefer the latter option because it requires less code and provides enough parameters in titleBarOverlay to customize the buttons according to my preferences.

However, I encountered an issue with the overlay leaving a 1px gap around the buttons and I haven't found a way to adjust its position. Here is how the window buttons appear (I added a red title bar for better visibility):

https://i.sstatic.net/B4gvd.png

This is the code snippet for creating the window 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 CSS style in index.html includes the following code (where title_bar is 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 any way to eliminate this gap? If not, should I resort to manually adding window buttons as mentioned earlier to achieve the desired appearance?

I couldn't find much documentation on titleBarOverlay. Is this feature relatively new or possibly getting deprecated?

Answer №1

Unfortunately, it seems that the presence of a 1px border around windows is a common issue.

You can verify this by dragging any windowed application over a white background on your computer, resulting in the same thin border appearance.

To achieve a custom look, consider removing the titleBarStyle and titleBarOverlay options and creating your own title bar from scratch.

If you need guidance on building your own title bar, check out these two answers I provided previously:

In response to inquiries about the future of titleBarOverlay, as far as I am aware, it is not going to be phased out anytime soon.

For more information, refer to the following resources:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process by which Nginx manages outbound requests sent from Node.js as a client?

Introduction: I currently have an angular frontend and a node backend (Server A) that are functioning properly. Nginx is also being utilized for Server A. Now, I need to make an API call from my Node server (Server A) to an endpoint on another server (Serv ...

Tips for Formatting Mandatory Message Input Fields and Text Boxes

I am in the process of creating a contact page for my Reactjs website, but I am unsure how to style the required message that should appear below the input or textarea upon clicking Submit. Can anyone guide me on how to achieve this? Relevant Code <for ...

Utilizing spine.js in conjunction with haml

Recently, I've been experimenting with spine.js and delving into its view documentation. In particular, the example using eco as the templating engine left me feeling less than impressed. Personally, I much prefer working with haml for my templating n ...

Showing specific XML data from a node when a button is clicked in an HTML document

<script> $(document).ready(function(){ $.ajax({ type: "GET", url: "data.xml", dataType: "xml", success: function(xmlData) { $("POS", xmlData).each(function(){ var sr = $(this).find(&apos ...

Personalizing the structure of a joomla template

Having some trouble customizing my Helix Framework template. I'm trying to adjust the width of the page to be 1140 px. When I make changes in the framework menu, it only adjusts the text field width and not the graphics. How can I achieve the layout s ...

Switch up the URL and redirect by employing jQuery

Looking for a solution in jQuery to redirect based on user input? <form id="abc"> <input type="text" id="txt" /> </form> If you want to redirect to a URL constructed from the value of the text box, you can try this: var temp = $("#tx ...

A method for expanding the menu upwards to make room for newly added items

Looking at the images below, I have a menu that needs new items added to it while maintaining the position of the lower-left corner. Essentially, each time an entry is added, the menu should expand upwards from "the upper-left corner" while keepi ...

"Optimizing XSL stylesheets by implementing conditional row styles to prevent redundant

Is there a way to display rows that are older than 2 years from today in bold without repeating the code? I know the condition I need, but I'm struggling with avoiding duplicating all the code just for a different style. This is the code I have: & ...

Calling Node.js middleware externally results in bypassing its functionality

As a newcomer to Express and Node, I'm facing what seems like a very basic issue that is causing me quite a bit of confusion. Any assistance in resolving this problem or guiding me on how to troubleshoot it would be greatly appreciated. Issue var ...

React - Error occurred when parsing module: Unexpected Token. It is recommended to use a suitable loader to manage this file format

As a beginner in using React, I might be making obvious mistakes and I apologize for that. After researching similar bugs on various platforms like StackOverflow and GitHub, I couldn't find a solution that works for my specific issue. Here is the erro ...

When the columns start stacking in Bootstrap, the padding is disabled

As I work on revamping my website, I have decided to incorporate the Bootstrap framework. While I can navigate through HTML coding, I still consider myself a novice when it comes to coding. The current issue I am facing involves the alignment of two colum ...

Could we filter and retrieve only one unique notificationType/postId combination?

I have a notification model with the following Schema definition: const NotificationSchema = new Schema({ type: { type: String, required: true }, createdAt: { type: Number, required: true }, postId: { type: Schema.Types.Objec ...

How to position and center a div layer over another div

I have been struggling to place a div over another div that contains an image. The div needs to have a simple HTML link just like the example shown in this picture: However, when the page loads, the URL is not centered on the image as you can see on the l ...

express-validator, no validation errors have been found so far

How can I verify if a given string is in the format of an email address? Here's a snippet of code that attempts to do so: req.checkBody('email', 'Invalid email address').isEmail(); var validationErrors = req.validationErrors(); i ...

What is the best way to design a table to allow for changing the colors of specific boxes in the table when clicked?

I am looking to create a feature where the elements in this table change color from the background color to red and back to the default color when they are clicked. Can anyone help me achieve this? <table align="center" style="height: 355px;" width=" ...

Locate information about my friends and me in order to organize and categorize them using MongoDB

Currently, I am in need of finding information about my friends. My goal is to organize this information based on the Fame rating, with the highest fame ranking at the top. My query for this information has not been optimized and I'm struggling with ...

Is it possible to determine if a style property has been altered

I am looking to identify changes in CSS properties without needing the actual values. I only require the specific style property that has been altered. For example, I need the style property to be stored in a variable, as shown below: document.getElementB ...

Tips for loading a repeater on a div scroll instead of relying on the browser window scroll

Currently, I have a repeater that loads records as I scroll down the main browser window. However, I am looking to enhance this functionality by adding a scrollable div and loading the repeater data as I scroll down that specific div, instead of the entire ...

Reading JSON files in AngularJS is a common practice among developers

Creating a dynamic tree using JSON is a common task in AngularJS. To achieve this, you can store your JSON data in a separate file and then read it externally. Here's an example of how you can do this: Sample Controller Code: $scope.myjson = { ...

Guide on Generating SAS Token for Azure Table Storage in a jQuery Application

I am currently working on a jQuery web application that requires read-only access to an Azure Table Storage, fetching one record at a time by passing in the PartitionKey and RowKey. To simplify my code, I have integrated the Azure Storage JavaScript Client ...