GtkStack
A container that shows one child at a time.
Preview
Content of first page
CSS Node Tree
stack
└── <page child> (one per page)
stackswitcher.linked[.horizontal|.vertical]
└── button.toggle[.text-button|.image-button][.needs-attention][:checked] (per page)
└── label | imageProps
Prop
Type
GtkStackPage
Prop
Type
GtkStackSwitcher
Prop
Type
Behavior
- Use
GtkStackPagechildren to declare each page with aname. Every page stays mounted, so the state inside a hidden page (an entry's text, a toggle) is kept. - A homogeneous stack (the default) is as large as its largest page. With
hhomogeneousorvhomogeneousoff, it follows the visible page along that axis. transitionTypeanimates page changes: crossfade, slides,over-*,under-*androtate-*, as in GTK. The*-left-rightand*-up-downtypes take their direction from the order of the pages. Nothing is animated when the user prefers reduced motion.- When the focus is inside the page being hidden, it moves to the new page: to the widget last focused there, or else its first focusable widget.
- Pair with
GtkStackSwitcherfor a tab bar: pass it the same pages, the visible page asactivePageName, and switch pages inonPageChanged. A page with aniconNamegets an icon tab with its title as the tooltip, and a page with neither a title nor an icon gets no tab. The tabs share the switcher's width and don't take the focus when clicked.