Skip to main content

Docking and Viewports

Docking and multi-viewport features are available in the docking branch of Dear ImGui. These features allow windows to be docked together and moved outside the main application window.
Docking and viewports are currently available in the docking branch, not in the master branch. You need to use the docking branch to access these features.

Docking Overview

Docking allows users to:
  • Drag windows to dock them together
  • Create custom layouts by splitting docked spaces
  • Save and restore docking layouts
  • Create tab bars from docked windows

Enabling Docking

Enable docking in your application:

Creating a Dockspace

A dockspace is a region where windows can be docked:

Simple Dockspace

For a simpler approach:

Docking Flags

Window Flags

Control docking behavior per-window:
Docking-related window flags:
  • ImGuiWindowFlags_NoDocking - Cannot be docked

DockNode Flags

Customize dockspace behavior:
Example usage:

Programmatic Docking

Set up initial docking layout programmatically:

Multi-Viewport Support

Multi-viewport allows Dear ImGui windows to be moved outside the main application window into their own OS windows.

Enabling Viewports

Backend Requirements

Multi-viewport requires:
  1. Platform backend support (e.g., imgui_impl_glfw.cpp, imgui_impl_win32.cpp)
  2. Renderer backend support (e.g., imgui_impl_opengl3.cpp, imgui_impl_dx11.cpp)
  3. Backend must create and manage additional OS windows

Rendering Viewports

Viewport Flags

ImGuiViewport Structure

Getting Viewport Information

Complete Docking Example

Saving and Loading Layouts

Dear ImGui automatically saves docking layouts to .ini files:
Important notes:
  • Docking and viewports are in the docking branch, not master
  • Multi-viewport requires backend support for creating OS windows
  • Some backends may not fully support all viewport features
  • Test thoroughly on all target platforms

Platform-Specific Considerations

Windows

Full support in GLFW, Win32, SDL2 backends.

macOS

Full support with some quirks around focus and decorations.

Linux

Full support with X11 and Wayland backends.

Web (Emscripten)

Multi-viewport not supported (browser limitation).

Reference