Custom Electron Titlebar when not using index.html

Viewed 1029

When using the following code:

mainWindow.loadURL(`http://www.google.com/`);

I am not able to make a custom titlebar with css/html as i am not using an index.html as i would be able to if i was using this code:

loaderWindow.loadURL(`file:///${__dirname}/loader.html`);

Ive tried custom npm packages like electron-titlebar-windows & custom-electron-titlebar. Nothing seems to work when im displaying an external page from loadURL.

Here is my current implementation of custom-electron-titlebar, in the renderer process:

let MyTitleBar = new customTitlebar.Titlebar({
  backgroundColor: customTitlebar.Color.fromHex('#03a9f4')
});

MyTitleBar.updateTitle('Test Title');
1 Answers

You should be able to use setTitle Documentation

mainWindow.webContents.on('did-finish-load', () => {
  mainWindow.setTitle('Test Title');
});
Related