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.

PageTransition has push, pop, and replace TransitionSpec values. Attach it to a page root with With; it overrides the entire inherited NavigationStyle::motion policy. Push/replace select the incoming page’s policy; pop selects the departing page’s. The selected policy is fixed for that operation.

A default NavigationStyle has no motion; Default() supplies generic slides. An absent motion disables inherited animation unless a page declares its own PageTransition. PageTransition explicitly makes all operations immediate. Page interaction is disabled during an operation, while container Back and predictive cancellation remain available. See Animation.

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::composable]]
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.