Overview
TheBrowserUI component is the top-level React component that renders the complete Flow Browser interface. It orchestrates all major UI systems including the sidebar, topbar, tab content area, and popup windows.
Architecture
BrowserUI follows a provider-based architecture with multiple context providers wrapping the main UI layout:Component Types
Flow Browser supports two types of browser UI:main: Full browser window with sidebar navigationpopup: Compact window with inline toolbar (no sidebar)
Main Components
BrowserContent
TheBrowserContent component represents the web page viewing area. Instead of directly measuring bounds, it sends declarative layout parameters to the main Electron process.
Location: src/renderer/src/components/browser-ui/browser-content.tsx
- Uses
useLayoutEffectfor synchronous IPC communication before paint - Sends layout params to main process via
flow.page.setLayoutParams() - Coordinates with sidebar animations and topbar visibility
- Handles resize events during sidebar drag operations
AdaptiveTopbar
TheAdaptiveTopbar dynamically adjusts window controls based on platform and sidebar position.
Location: src/renderer/src/components/browser-ui/adaptive-topbar.tsx
- macOS
- Windows/Linux
- Shows window controls on the left side of the sidebar
- Height: 34px when sidebar is on the right, 0px when on the left
- Uses
SidebarWindowControlsMacOScomponent
PresenceSidebar
A wrapper component that managesAnimatePresence for sidebar transitions between attached and floating modes.
Location: src/renderer/src/components/browser-ui/main.tsx:62
Current sidebar mode:
attached-left, attached-right, floating-left, floating-right, or hiddenArray of modes this instance should render for
Which side of the window the sidebar appears on
ResizablePanel order (1 for left, 3 for right, 2 for center content)
PopupToolbar
A compact navigation toolbar for popup windows that replaces the full sidebar. Location:src/renderer/src/components/browser-ui/main.tsx:169
NavigationControls(back, forward, reload)AddressBarfor URL display and search- Reports height via
contentTopOffsetto position tab content below it
Layout System
BrowserUI uses a ResizablePanel system for flexible layouts:Performance Optimizations
Isolated Tab-Dependent Components
To prevent layout re-renders on every tab update, tab-dependent logic is isolated: WindowTitle (main.tsx:104)
main.tsx:124)
Special Features
FullscreenGuard
Manages UI visibility when a tab enters fullscreen mode:AutoNewTab
Automatically opens a new tab when the browser starts with no tabs:Usage Example
CSS Classes
The main container uses these classes:app-drag: Enables window dragging (from titlebar area)remove-app-drag: Disables dragging for specific areas (buttons, content)
Related Documentation
- Sidebar Component - Vertical navigation panel
- Tabs Management - Tab system and grouping
- Portal Component - Floating window system
Design Documents
For implementation details, see:design/DECLARATIVE_PAGE_BOUNDS.md- Layout parameter system- Source:
src/renderer/src/components/browser-ui/main.tsx