How to Configure BrowserWindow Options for Frameless Windows in Electron

To configure BrowserWindow options for frameless windows in Electron, set frame: false in the constructor options object and use CSS properties like -webkit-app-region: drag to create draggable regions.

When building desktop applications with the electron/electron repository, removing the native operating system chrome allows for fully custom user interfaces. Configuring BrowserWindow options for frameless windows requires passing specific properties to the constructor, which inherits from BaseWindow and forwards parameters to the native electron_browser_window binding. This configuration transforms the window into a plain drawing surface where the web page controls all visual elements.

Essential Frameless Window Configuration Options

The BrowserWindow class defined in lib/browser/api/browser-window.ts accepts an options object that controls native window creation. To remove system chrome, you must set specific boolean and object properties that the native C++ implementation reads during instantiation.

Disabling the Native Frame

Set the frame property to false to eliminate the title bar, borders, and standard window controls. This creates a borderless window that serves as a blank canvas for your application interface.

const { BrowserWindow } = require('electron');

const win = new BrowserWindow({
  width: 800,
  height: 600,
  frame: false  // Removes OS chrome completely
});

Window Controls Overlay and Positioning

Even with frame: false, you can retain or customize system window controls using additional options documented in docs/api/structures/base-window-options.md:

  • titleBarOverlay: Enables the Window Controls Overlay API on macOS and Windows, displaying native minimize, maximize, and close buttons over your content
  • trafficLightPosition: Accepts an object { x: number, y: number } to reposition macOS traffic-light buttons
  • roundedCorners: Boolean controlling whether window edges appear rounded on supported platforms
  • thickFrame: Boolean adjusting the resize border thickness on Windows
const win = new BrowserWindow({
  width: 800,
  height: 600,
  frame: false,
  titleBarOverlay: true,           // Keep native controls as overlay
  trafficLightPosition: { x: 12, y: 12 },
  roundedCorners: true
});

Implementing Draggable Regions and Custom Controls

With the native frame disabled, you must implement custom title bars and window management controls using web technologies and inter-process communication.

CSS Drag Regions

Use the -webkit-app-region CSS property to define draggable areas. Apply drag to regions that should move the window when clicked, and no-drag to interactive elements that require separate click handling.

.titlebar {
  height: 32px;
  background: #2f3241;
  display: flex;
  align-items: center;
  -webkit-app-region: drag;  // Enables window dragging
}

.titlebar button {
  -webkit-app-region: no-drag;  // Disables dragging on buttons
  cursor: pointer;
}

Window Control Implementation

Implement minimize, maximize, and close functionality by exposing safe IPC methods via a preload script. The renderer process sends messages to the main process, which calls methods on the BrowserWindow instance.

Preload script (preload.js):

const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
  minimize: () => ipcRenderer.send('minimize-window'),
  maximize: () => ipcRenderer.send('maximize-window'),
  close: () => ipcRenderer.send('close-window')
});

Main process handlers (main.js):

const { ipcMain, BrowserWindow } = require('electron');

ipcMain.on('minimize-window', (event) => {
  const win = BrowserWindow.fromWebContents(event.sender);
  win.minimize();
});

ipcMain.on('maximize-window', (event) => {
  const win = BrowserWindow.fromWebContents(event.sender);
  if (win.isMaximized()) {
    win.unmaximize();
  } else {
    win.maximize();
  }
});

ipcMain.on('close-window', (event) => {
  const win = BrowserWindow.fromWebContents(event.sender);
  win.close();
});

Complete Frameless Window Implementation

The following example demonstrates a complete setup across all process types, creating a frameless window with a draggable custom title bar and functional controls.

Main process (main.js):

const { app, BrowserWindow, ipcMain } = require('electron');

function createWindow() {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    frame: false,
    titleBarOverlay: true,
    trafficLightPosition: { x: 12, y: 12 },
    webPreferences: {
      contextIsolation: true,
      preload: __dirname + '/preload.js'
    }
  });

  win.loadFile('index.html');
}

app.whenReady().then(createWindow);

// IPC handlers for window controls
ipcMain.on('minimize-window', (event) => {
  BrowserWindow.fromWebContents(event.sender).minimize();
});

ipcMain.on('close-window', (event) => {
  BrowserWindow.fromWebContents(event.sender).close();
});

Renderer interface (index.html):

<!DOCTYPE html>
<html>
<head>
  <style>
    body { margin: 0; font-family: sans-serif; }
    .titlebar {
      height: 32px;
      background: #2f3241;
      color: white;
      display: flex;
      align-items: center;
      padding: 0 12px;
      -webkit-app-region: drag;
    }
    .controls {
      margin-left: auto;
      display: flex;
      gap: 8px;
    }
    .controls button {
      -webkit-app-region: no-drag;
      background: transparent;
      border: none;
      color: white;
      cursor: pointer;
      padding: 4px 8px;
    }
  </style>
</head>
<body>
  <div class="titlebar">
    <span>My Frameless App</span>
    <div class="controls">
      <button onclick="window.electronAPI.minimize()">—</button>
      <button onclick="window.electronAPI.close()">✕</button>
    </div>
  </div>
  <!-- Your application content -->
</body>
</html>

Summary

  • Set frame: false in the BrowserWindow constructor to remove native OS chrome, as implemented in lib/browser/api/browser-window.ts.
  • Use -webkit-app-region: drag in CSS to create draggable title bar regions, and no-drag to exclude interactive controls from drag behavior.
  • Enable titleBarOverlay for platform-native window controls on macOS and Windows without sacrificing the frameless aesthetic.
  • Implement custom window controls using ipcMain and ipcRenderer to call methods like win.minimize() and win.close().
  • Reference docs/api/structures/base-window-options.md for complete frameless-specific properties including trafficLightPosition and roundedCorners.

Frequently Asked Questions

How do I make a frameless window draggable in Electron?

Apply the CSS property -webkit-app-region: drag to any HTML element that should function as a title bar. To prevent specific child elements like buttons from triggering window movement, apply -webkit-app-region: no-drag to those elements. This approach is documented in docs/tutorial/custom-window-styles.md.

Can I use the system menu bar with a frameless window?

No, when you set frame: false, Electron disables automatic menu handling. According to the source code behavior in the electron_browser_window binding, you must manually create menus using the Menu module and attach them using win.setMenu() or Menu.setApplicationMenu() if you need menu functionality in a frameless window.

What is the difference between frame: false and titleBarOverlay?

Setting frame: false completely removes the native title bar and window controls, requiring you to build custom controls. Setting titleBarOverlay: true (available on macOS and Windows) keeps the native traffic lights or minimize/maximize/close buttons visible as an overlay on top of your content, allowing you to customize the title bar appearance while retaining system controls.

Where are BrowserWindow options processed in the Electron source code?

The BrowserWindow class is defined in lib/browser/api/browser-window.ts, where the constructor forwards the options object to the native electron_browser_window binding. The native C++ implementation reads flags like frame, titleBarOverlay, and trafficLightPosition when creating the underlying window object, as detailed in the BaseWindow options structure.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →