BrowserWindow class extends Electron’s BrowserWindow and manages the browser UI, view hierarchy, page layout, and window-level features like the omnibox and sidebar.
Overview
BrowserWindow provides:- Window creation with custom chrome (hidden titlebar, traffic lights)
- View management for tabs, omnibox, and UI components
- Declarative page bounds system for tab layout
- Sidebar animation with synchronized interpolation
- Space management for organizing tabs
- Fullscreen handling with proper layout updates
Window Types
Standard browser window with full UI (800x400 minimum)
Popup window with minimal chrome (300x200 minimum)
Creating a Window
BrowserWindowCreationOptions
Window width in pixels (default: 1280)
Window height in pixels (default: 720)
Window x position (centers if x and y not provided)
Window y position (centers if x and y not provided)
Properties
Window Identification
Unique window ID (from Electron BrowserWindow)
Window type: ‘normal’ or ‘popup’
Underlying Electron BrowserWindow instance
View Management
Manages the view hierarchy (tabs, omnibox, UI overlays)
Array of core WebContents (window + omnibox)
The omnibox/address bar view
Layout & Bounds
Current page bounds for tab views
Space Management
ID of the currently active space in this window
Methods
Layout Management
Updates layout parameters and recomputes page bounds. Handles sidebar animations.Parameters:
params: Declarative layout parameters from renderersentAt: Timestamp for IPC delay compensation
Legacy method: sets pre-computed bounds from renderer. Triggers page-bounds-changed event.
Space Management
Sets the active space for this window. Emits ‘current-space-changed’ event.
macOS Traffic Lights
Shows or hides the macOS window control buttons
Messaging
Sends IPC message to all core WebContents (window + omnibox)
Lifecycle
Destroys the window and cleans up resources. All tabs in the window are destroyed after a 500ms delay.
Events
BrowserWindow extendsBaseWindow and emits:
Emitted when page bounds change (resize, sidebar toggle, etc.)
Emitted when the active space changes
Emitted when window enters fullscreen mode
Emitted when window exits fullscreen mode
Declarative Page Bounds
Flow Browser uses a declarative layout system where the renderer sends layout parameters and the main process computes page bounds:Sidebar Animation
WhensidebarAnimating is true, the window automatically interpolates sidebar width with an ease-in-out curve matching the CSS transition:
- Uses 200ms duration (SIDEBAR_ANIMATE_DURATION)
- Applies ease-in-out timing function
- Backs off the timestamp to compensate for IPC delay
- Adds a small buffer during animation to prevent visual artifacts
View Layers
Views are organized in layers (z-index):Window Persistence
Window bounds are automatically persisted:- On resize (debounced 500ms)
- On move (debounced 500ms)
- On initial creation
Example: Creating a Custom Window
Platform Differences
macOS
- Uses vibrancy effect (“popover”)
- Hidden titlebar with traffic lights
- Traffic lights visibility can be toggled
- Transparent background (#00000000)
Windows
- Hidden titlebar with overlay controls
- Title bar overlay height: 30px
- Symbol color adapts to space theme
- Opaque background (#000000)
Linux
- Default frame (titleBarStyle not set)
- Title bar overlay with custom controls
- Opaque background
Related
Browser
Learn about browser controllers
Tab
Learn about the Tab class