Popovers
A popover is the small surface that appears next to something rather than over the whole window: a tooltip you can interact with, a menu, a context menu on a row. GTK has four widgets for it, and they stack — the popover is the surface, the popover menu is that surface filled from a menu model, the popover menu bar is a row of menus, and the popover bin wraps any widget so that a right click on it opens one.
Libadwaita styles the surface (popover > contents: an 8 px inset, a 15 px
radius and a three-layer shadow) and the menu inside it (popover.menu swaps the
8 px inset for a 6 px one and draws 32 px rows with 9 px corners), and adds
neither of the other two to its stylesheet. Both are on this page, because a
menu bar is not a look and a bin is not a widget: they are behaviour.
Popover
Section titled “Popover”The surface itself. It holds whatever widget you put in it and shows it beside
its parent. position picks the side (bottom, top, start, end) and
align picks the edge on the vertical axis — GTK spells that as the parent
widget’s own halign, which is why the browser element carries an align
attribute of its own.
The one worth trying is autohide. It defaults to on, and it is GTK’s grab: with it on, an outside click or an Esc dismisses the popover. Turn it off and the popover no longer takes the focus, which is what an entry’s completion list needs — the caret stays in the entry and the list follows the typing.
Popover Menu
Section titled “Popover Menu”The same surface filled from a menu model rather than from a child widget —
which is what makes it more than a surface, because a submenu becomes a named
page of the one popup rather than a second window beside it.
visible-submenu is that name: 'main' is the root, and a submenu’s label is
its own. Reading it tells you where the reader is; writing it opens that page.
menu-model is the JSON the two other menu widgets take too: items, section
groups and submenu nests, with the attribute names GTK reads. A section
carries the heading, and an item may carry an accel, an icon or an action.
Popover Menu Bar
Section titled “Popover Menu Bar”A horizontal bar whose items pop up a menu. There is exactly one way to make one — from a model — and the model must hold submenus at the top level, one per item; anything else is refused with GTK’s own “Don’t know how to handle this item”.
What makes it a menu bar and not a row of menu buttons is one rule:
clicking an item opens its menu, hovering only selects it. And a second
follows from it — the item whose menu is actually up is the one that gets
.active, so walking the bar with the pointer shows selection without lighting
anything. ← and → move between items and wrap; with a menu
open they belong to the menu instead, which is where ↑ and
↓ already live.
Popover Bin
Section titled “Popover Bin”GTK 4.22’s answer to “any part of this window can offer a menu”. Wrap a widget
in it and the container owns the popover, the gestures and a menu.popup
action. menu-model builds the popover for you and pins it below the child;
handle-input is what makes a right click — or a long press on a touchscreen —
open it, and it defaults to off, so a plain click still reaches the child.
While the popup is up the child wears libadwaita’s has-open-popup class,
which is how a list row or a sidebar row stays highlighted while its own menu
covers the list.
Related
Section titled “Related”- Buttons: the menu button, whose popup is the popover menu with a button attached.
- Navigation: the split view, the sidebar and the bottom sheet, the other surfaces that own their own popup.
- Adwaita Presentation: the popovers libadwaita draws on top of these.
- Adwaita Storybook: the same widgets in a live component browser you can poke at.