Skip to content

NavigationBar

NavigationBar presents a controlled set of primary destinations. The owner supplies the selected index and handles requested changes.

NavigationBar(
{
NavigationItem(images::home, "Home"),
NavigationItem(images::library, "Library"),
NavigationItem(images::settings, "Settings"),
},
selected
).OnChanged([selected](std::size_t index) {
selected = index;
})

NavigationItem accepts a label alone or an ImageResource, ImageAsset, or VectorAsset plus label. .SelectedIcon(...) supplies an alternate selected icon and .Enabled(false) disables a destination.

The bar does not own selection. Pass std::size_t or State<std::size_t> and publish the new value after NavigationEvents::Changed. NavigationBarStyle controls height, icon and label treatment, selection indicator, indication, and animation.

The component exposes collection and selected-item semantics. Labels remain important even when a theme hides unselected labels.

  • NavigationBar(items, selected_index) with initializer-list/vector and value/state overloads.
  • OnChanged(handler) receives the requested index.
  • NavigationItem(label) and icon-plus-label constructors.
  • NavigationItem::SelectedIcon(...) and Enabled(bool).
  • NavigationBarStyle configures themed appearance.

See also NavigationPane and Tabs.

Declared in <huxerui/navigation.h>. NavigationBar does not create a NavigationStack or call its controller. For persistent top-level destinations, use one selected State with IndexedPages; each destination can contain its own NavigationStack. This keeps switching sections separate from pushing a detail page.

Items are owned declarations. NavigationItem(StringVariant) is label-only; NavigationItem(ImageVariant, StringVariant) adds an icon. SelectedIcon(ImageVariant) overrides only the selected icon, and Enabled(bool) defaults to true. Keep labels meaningful even when icons carry the visual identity. Selection remains index-based: after changing the destination list, supply an index appropriate to the new order.

Fields Use
background, label_style Bar surface and baseline label typography.
selected_content, disabled_content Icon/label state colors.
height, minimum_item_width, item_padding Bar and item geometry.
icon_size, icon_spacing Icon size and label gap.
indicator, indicator_size, indicator_corner_radius Selected destination’s background shape.
show_unselected_labels Whether inactive labels remain visible.
indication, selection_animation Interactive feedback and selection transition specification.

The style’s height is content geometry, not a mobile system-navigation-bar inset. Apply the application’s safe-area policy once at the appropriate boundary rather than adding a hard-coded bottom margin to every destination.