Skip to content

Navigation API

Declared by <huxerui/navigation.h>.

  • TopAppBar, TopAppBarTitleAlignment, TopAppBarStyle.
  • NavigationItem: label/icon constructors, SelectedIcon, and Enabled.
  • NavigationBar and NavigationPane: controlled selected index and OnChanged.
  • NavigationBarStyle and NavigationPaneStyle configure colors, icon/label geometry, selection indicator, indication, and animation.
  • StartDrawer and EndDrawer: content, controlled Open, and OnOpenChanged.
  • DrawerLayout: content-only, either-side, and both-side constructors.
  • DrawerStyle: surface/scrim/shadow, preferred/minimum widths, minimum content width, modal reveal, edge drag width, corner radius, and optional motion.
  • DrawerMotion: open and close animation specs.

NavigationStack(factory, args...) creates a retained stack. NavigationController exposes Push, Pop, Replace, CanPop, and Depth; factory/argument overloads avoid forwarding lambdas. UseNavigation() resolves the nearest stack and UseRootNavigation() the outermost.

NavigationPath<Route> stores route values and exposes Empty, Size, Routes, and equality. NavigationStack(root, State<NavigationPath<Route>>, resolver) builds destinations. RouteNavigationController<Route> exposes Push, Pop, Replace, SetPath, CanPop, and Depth. Typed UseNavigation<Route>() and UseRootNavigation<Route>() require a compatible routed stack.

NavigationMotion controls entering/covered offsets, scale, opacity, and push/pop specs. NavigationStyle contains optional motion and Default().

See the dedicated navigation component pages and routing guide.

#include <huxerui/huxerui.h>
using namespace huxerui;
struct ArticleRoute {
int id = 0;
bool operator==(const ArticleRoute&) const = default;
};
View Article(const ArticleRoute& route) {
return Text::Format("Article {}", route.id);
}
View Home() {
auto navigation = UseNavigation<ArticleRoute>();
return Button("Open article").OnClick([navigation] {
navigation.Push(ArticleRoute {.id = 42});
});
}
[[huxerui::scope]]
View RoutedApplication() {
auto path = UseState(NavigationPath<ArticleRoute>{});
return NavigationStack(Home, path, Article);
}

The path is application-owned state; the controller performs typed mutations and the resolver maps each route value to a destination View.