Cristian006/frameless-titlebar

Apr 21, 2020 All of this can be achieved with Electron, which can simply wrap your web application inside a native container that can be used as a real native desktop application on Windows and Mac OS! We will build a simple Ionic app with Capacitor and add Electron to finally build a native desktop out of our basic application. This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including electron-titlebar with all npm packages installed. On Windows however, Electron applications are often left untouched when it comes to the title bar. In my opinion, the default menu and title bar don't exaclty work well with some stylized applications such as Atom, VS Code or Signal. Apps would look a little more unified if they used a custom stylized menu. Enables or disables the option of the close window by clicking on the corresponding button in the title bar. True: order: string: Set the order of the elements on the title bar. (inverted, first-buttons) null: titleHorizontalAlignment: string: Set horizontal alignment of the window title. (left, center, right) center: menu: Electron.Menu.


Customizable Electron Titlebar for frameless windows

  • Users starred: 115
  • Users forked: 15
  • Users watching: 115
  • Updated at: 2020-06-12 14:32:47

Customizable titlebar for frameless electron windows built with React

The demo application can be found in the example folder along with more images of the different titlebar styles:

  • Overflow Menu: When menu buttons don't fit in the given titlebar space items are moved into an overflowed submenu.
  • Stacked Menu: Titlebar stacked above menu bar.
  • Vertical Menu: All menu items moved into a vertical submenu.

Install

Usage

Electron Browser SetUp

React App SetUp

Example of all of the overridable theme properties can be found in the example folder here

Use titlebar theme in children

Example of a custom TitleBarButton can be seen here

Electron Mac Title Bar On Electron For Windows

Supported Menu Item Properties

Supported menu item properties from:Electron Menu Object/Template Documentation

NameTypeDescription
id (optional)stringMust be unique. If defined then it can be used as a reference to this item by the position attribute
type (optional)oneOf([normal, separator, submenu, checkbox, radio])Type of supported menu items
label (optional)stringMenu item label
click (optional)function(menuItem, browserWindow, event)if currentWindow is not passed in to the titlebar then, browserWindow will be null
disabled (optional)boolEnables/disables menu item from being clicked on
accelerator (optional)stringAccelerator string eg CmdOrCtrl+Z
icon (optional)imgThe image shown to the left of the menu label
checked (optional)boolShould only be specified for checkbox or radio type menu items
submenu (optional)array : [MenuItems]Array of menu items. If submenu is specified, the type: 'submenu' can be omitted.
before (optional)stringInserts this item before the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu
after (optional)stringInserts this item after the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu

Keyboard accessibility

Opening Menu: Pressing Alt Key + First letter of any of the visible menu items. eg: Alt+F would open the first menu item with an F if any, such as File.

Closing Menu: Pressing Esc.

Navigating Submenus: Use arrow keys (up, down, left, right) to navigate menus once they're open.

Disclaimers

NOTE: ^v2.0.0 has a lot of breaking changes from the previous ^1.x.x releases since this was a complete re-write of frameless-titlebar

Contributing

Feel free to fork and create pull requests! I'll try my best to review any code changes for the next release.

Links

License

Electron Mac Title Bar On Electron For Windows 8.1

MIT © Cristian006

Electron remove title bar

Frameless Window, Instead of setting frame to false which disables both the titlebar and window On Linux, users have to put --enable-transparent-visuals --disable-gpu in the Alternatives on macOS. There's an alternative way to specify a chromeless window. Instead of setting frame to false which disables both the titlebar and window controls, you may want to have the title bar hidden and your content extend to the full window size, yet still preserve the window controls ('traffic lights') for standard window actions.

Electron mac title bar on electron for windows 8.1

Frameless window with controls in electron (Windows), you can accomplish this by removing the frame around Electron and filling the rest in Then create and add control buttons for your title bar: Check out the Electron Docs with crossplatform hints about transperent windows. The you can then add or remove a class on the title bar to make it appear/disappear. The titlebar element should have the css property -webkit-app-region: drag

How to hide the titleBar of Windows · Issue #7136 · electron/electron , Dismiss. Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and We were wondering if electron would allow us to do something like this. erusev changed the title Is it possible to hide the title bar Hiding the title bar Jun 5, 2015 This comment has been minimized.

Electron remove menu not working

Electron now has win.removeMenu () ( added in v5.0.0 ), to remove application menus instead of using win.setMenu (null). Electron 7.1.x seems to have a bug where win.removeMenu () doesn't work. The only workaround is to use Menu.setApplicationMenu (null) share. Share a link to this answer.

I have also found that neither win.removeMenu () nor win.setMenu (null) work in electron 7.1.3. Whilst setting Menu.setApplicationMenu (false) does remove the menu bar, this isn't a good solution since it also disables the ability to bring up the debugging console when developing the application. igortupini commented on Dec 6, 2019

setMenu(null) will remove the menu, but the not frame, whereas frame: false will remove the entire interface. dasarindam March 2, 2017, 11:45am #11

Electron browserwindow

BrowserWindow, const { BrowserWindow } = require('electron').remote const win = new BrowserWindow({ width: 800, height: 600 }) // Load a remote URL win. const { BrowserWindow } = require ('electron') let win = new BrowserWindow ({ show: false }) win.once ('ready-to-show', () => { win.show () }) This event is usually emitted after the did-finish-load event, but for pages with many remote resources, it may be emitted before the did-finish-load event.

webContents, const { BrowserWindow } = require('electron') let win = new BrowserWindow({ width: 800, height: 1500 }) win.loadURL('http://github.com') let contents = win. BrowserWindow. Create and control browser windows. Process: Main // In the main process. const {BrowserWindow} = require('electron') // Or use `remote` from the renderer process.

All the Electron Docs!, window BrowserWindow. Emitted when a browserWindow gets blurred. Event: '​browser-window-focus'. Returns:. Process: Main A BrowserView can be used to embed additional web content into a BrowserWindow. It is like a child window, except that it is positioned relative to its owning window. It is meant to be an alternative to the webview tag.

Electron | custom title bar

Try more powerful experiments with Electron Fiddle. Electron Fiddle lets you create and play with small Electron experiments. It greets you with a quick-start template after opening – change a few things, choose the version of Electron you want to run it with, and play around. Then, save your Fiddle either as a GitHub Gist or to a local folder.

Electron definition, an elementary particle that is a fundamental constituent of matter, having a negative charge of 1.602 × 10−19 coulombs, a mass of 9.108 × 10−31 kilograms, and spin of ½, and existing independently or as the component outside the nucleus of an atom.

The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS. It is based on Node.js and Chromium and is used by the Atom editor and many other apps . Follow @ElectronJS on Twitter for important announcements.

Electron dynamic menu

All this is not working in Electron, as the menu is created at application start and it can't be modified at all. I believe this is a serious lack, as dynamic menu items are very common (i.e.: menu checkboxes, enabled/disabled, etc).

On Windows and Linux, the menu will be set as each window's top menu. Also on Windows and Linux, you can use a & in the top-level item name to indicate which letter should get a generated accelerator. For example, using &File for the file menu would result in a generated Alt-F accelerator that opens the associated menu. The indicated character in the button label gets an underline.

Run npm start and doublecheck that everything works – you should see a blank window open and the Mac OS X menu is the default Electron menu. If you need help with that part, check out my tutorial on getting started with Electron. Set a custom menu Override the Default Electron Development Menu. First pull the Menu class from electron: src/index.js

Electron hide application menu

Remove menubar from Electron app, removeMenu() (added in v5.0.0), to remove application menus instead of const {app, BrowserWindow, Menu} = require('electron') Menu. The menu can be hidden or auto-hidden (like in Slack or VS Code - you can press Alt to show/hide the menu). Relevant methods:---- win.setMenu(menu) - Sets the menu as the window’s menu bar, setting it to null will remove the menu bar. (This will remove the menu completly) mainWindow.setMenu(null)

did not hide the window menu bar · Issue #16521 · electron , The Electron v5 application menu is also broken on Linux. When you need to remove the (application) menu at runtime you can build a dummy opens the associated menu. The indicated character in the button label gets an The &character is not displayed on the button label. Passing nullwill suppress the default menu. this has the additional effect of removing the menu bar from the window.

How to disable the default menubar - electron, This will remove the menu bar completely - browserWindow. electron.app.on('​browser-window-created',function(e,window) { window. I think this should be configurable without hacking electron’s startup script. The default menu can be an eyesore under Linux (wherever there isn’t a unified menu), and unnecessary if the developer wants to implement an html menu for their application.

Electron preload js

How to use preload.js properly in Electron, Edit. As another user asked, let me explain my answer below. The proper way to use the preload.js in Electron is to expose whitelisted The proper way to use the preload.js in Electron is to expose whitelisted wrappers around any module your app may need to require. Security-wise, it's dangerous to expose require, or anything you retrieve through the require call in your preload.js (see my comment here for more explanation why). This is especially true if your app loads remote content, which many do.

How to use preload script in electron, You can use preload.js which will be loaded before other scripts run in the page. This script will always have access to both electron… The Electron API will only be available in the preload script and not the loaded page. This option should be used when loading potentially untrusted remote content to ensure the loaded content cannot tamper with the preload script and any Electron APIs being used.

BrowserWindow, sandbox and disabling the Node.js engine. This is not the same as the nodeIntegration option and the APIs available to the preload script are more limited. Electron uses Chromium and Node.js so you can build your app with HTML, CSS, and JavaScript. Open Source Electron is an open source project maintained by GitHub and an active community of contributors.

Electron app icon

Electron app icons 1. Creating our icns and ico-files First we need an icon that is 1024x1024 pixels large and saved in PNG. I’ve got one 2. Folder structure Now create a folder structure that looks like this: electron icon folder structure Create a folder 3. Updating main.js with path to icon

Electron Mac Title Bar On Electron For Windows Operating System

Optional icon.ico (Windows app icon) or icon.png. Icon size should be at least 256x256. needs to be placed in the buildResources directory (defaults to build). It is important to provide icon.ico (or icon.png), as otherwise the default Electron icon will be used.

Ok, not through code, but with some simple steps: Find the .icns file you want to use, open it and copy it via Edit menu Find the electron.app, usually in node_modules/electron/dist Open the information window Select the icon on the top left corner (gray border around it) Paste the icon via cmd+v

Electron Mac Title Bar On Electron For Windows Key

More Articles