A github desktop style title bar component for electron.
npm i --save @meetfranz/electron-react-titlebar
npm run build
npm run demo
app.on("ready", () => {
require("electron-react-titlebar/main").initialize();
});
import { TitleBar } from "electron-react-titlebar/renderer";
import "electron-react-titlebar/assets/style.css";
ReactDOM.render(
<TitleBar menu={menuTemplate} icon={iconPath} />,
document.querySelector("title-bar")
);
ReactDOM.render(
<TitleBar menu={menuTemplate} icon={iconPath}>
<link
rel="stylesheet"
type="text/css"
href={require.resolve("electron-react-titlebar/assets/style.css")}
/>
</TitleBar>,
document.body
);
Elements to be rendered in between the menu and the window controls (optional).
Disable minimize button (optional).
Disable maximize button (optional).
Path to icon file (optional).
The browserWindow's id that window controls affect to. Default value is the browserWindow that renders the component (optional).
Callback function when menu item is clicked (optional)
Show window controls (minimize, maximize, close) (optional)
Menu template of Electron's Menu (optional).
Note: electron-react-titlebar is supporting a subset of Electron's MenuItem.
Supported options:
click
- supported, but the callback only haveitem
andevent
parameter, and thebrowserWindow
parameter is removed due to restriction since Electron@14type
-submenu
is not supported.label
- supportedenabled
- supportedvisible
- supportedchecked
- supported
The v1.0.0 version contains following breaking changes:
- Requires
[email protected]
or newer version - Due to the Electron's removal of remote module since version 14, electron-react-titlebar now:
- Needs to initialize in main process (See example above)
- The require path of component has changed to
electron-react-titlebar/renderer
- The
currentWindow
prop has been removed, instead you can control your browserWindow bybrowserWindowId
prop - The second parameter of callback of menuItem's click handler (the browserWindow) has been removed
If you're still using Electron below 14 and don't want to take breaking changes, you can still use 0.x version of electron-react-titlebar.