Components / navigation
AnchorList builder
A horizontal reading-order list of links to sections in the current page.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::navigation::AnchorList;
Reviewed in anchor-list.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
anchor(anchor: Anchor) -> Self
anchors(anchors: impl IntoIterator<Item = Anchor>) -> Self
active(id: impl Into<SharedString>) -> Self
on_navigate(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
overflow_after(count: usize) -> Self
overflow_menu(menu: Entity<Menu>) -> Self
Example · anchor-list
fn anchor_list(window: &mut Window, cx: &mut App) -> AnyElement {
if !cx.has_global::<SceneAnchorList>() {
let label = cx.strings().text(StringKey::AnchorMoreSections);
let overflow = cx.new(|cx| Menu::new("scene.anchor-list.menu", window, cx).trigger(label));
cx.set_global(SceneAnchorList { overflow });
}
let theme = cx.theme().clone();
let overflow = cx.global::<SceneAnchorList>().overflow.clone();
stack(&theme)
.w(px(700.0))
.child(caption(
&theme,
"section intents only; the declared overflow moves anchors into a menu",
))
.child(
AnchorList::new("scene.anchor-list")
.anchors([
Anchor::new("summary", "Summary"),
Anchor::new("inputs", "Inputs"),
Anchor::new("constraints", "Constraints"),
Anchor::new("verification", "Verification"),
Anchor::new("history", "History").disabled(true),
])
.active("inputs")
.overflow_after(3)
.overflow_menu(overflow)
.on_navigate(|_, _, _| {}),
)
.into_any_element()
}