Skip to content

Stack

Stack measures and overlays children in declaration order. Later children paint above earlier children.

Stack {
Image(app::images::cover)
.Fit(ImageFit::Cover)
.With(Frame{.height = 220.0F}),
Text("Featured", TextRole::Title)
.With(
Align(HorizontalAlignment::Start, VerticalAlignment::End),
Padding(16.0F),
Foreground(Color::White())
),
}

Use child Align modifiers to position content within the stack’s available size. Apply ClipChildren with CornerRadius when overlays must remain inside a shaped surface.

Stack controls painting order but does not create a window-level overlay. Use presentation services and layers for dialogs, menus, popups, tooltips, and other content that must escape the application subtree.

  • Construction: Stack { children... } or an explicit child vector.
  • Common modifiers: Frame, Padding, ClipChildren, CornerRadius.
  • Child modifier: Align.

Read Presentation when content must live in a window layer instead of the local layout subtree.

Stack is in huxerui, <huxerui/view.h>, with the inherited child-vector and braced-content constructors. There is no Stack Style or change event. Alignment belongs on the direct overlaid child: Align(HorizontalAlignment, VerticalAlignment) chooses Start, Center, or End within the stack’s resolved bounds.

Later children paint above earlier children, but a decorative overlay should not be given an activation handler merely to position it. An interactive overlay participates in hit testing and can obscure an underlying action. ClipChildren clips descendants to the surface shape; CornerRadius alone does not turn every descendant into a rounded image.

A Stack’s overlay remains part of its ancestor’s layout, clipping, and lifetime. Use a layer presentation when an overlay must escape a scroll viewport, trap modal focus, or remain anchored to a target that moves.