TLDR;
Typically we build GUIs using event driven callbacks. This causes problems in managing life times, dynamic layouts, threading issues etc. The idea behind immediate mode GUI is that you get a frame and in each frame you create/update layout, check for user actions - just like you do in render frame in game loop. So there are no call backs and you don't have to worry about issues arising from event-driven code.
Does this pretty-much rule out (without a huge amount of effort) nonmodal GUIs? It seems without callbacks, you would need to roll your own window management, Z-ordering of overlapping UI elements, state transition validation (e.g. clicking on the parent dialogue’s Cancel button while a child window is still open), ...
https://pbrfrat.com/post/imgui_in_browser.html
For modal demo check "Popups & modal windows" -> "Modals" example.
This is how it looks in C++ code: https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp#...