Components / Anchor

Anchor

A place a #name link scrolls to, gliding there.

Example

The component itself, running in WebAssembly, beside its code in a playground. Try it.

Code

use ravenrs::prelude::*;

fn anchor() -> impl View {
    let rows: Vec<AnyView> = (1..=12).map(|n| Box::new(Text::new(format!("Row {n}"))) as AnyView).collect();
    ScrollView::new((
        Link::new("Jump to the summary", "#summary"),
        VStack::new(rows).spacing(8.0),
        Anchor::new("summary", Text::new("Summary").style(TextStyle::Title)),
        Canvas::new(|_, _| {}).size(10.0, 160.0),
    ))
    .spacing(12.0)
    .height(200.0)
}

Open in the playground, with every example →

Full API of Anchor →