pub struct ScrollspyProps {
pub target: String,
pub root: String,
pub active: Signal<String>,
pub offset: i32,
pub root_margin: String,
pub threshold: Vec<f64>,
pub refresh_key: u64,
pub smooth_scroll: bool,
}Expand description
Bootstrap Scrollspy tracks scroll position and updates active section state.
The target prop follows Bootstrap semantics: it points to the nav, list
group, or simple links container whose links reference section ids. Use
root for the body or custom scroll container being observed.
§Bootstrap HTML -> Dioxus
| HTML | Dioxus |
|---|---|
<body data-bs-spy="scroll" data-bs-target="#nav"> | Scrollspy { target: "#nav", active: signal } |
<div data-bs-spy="scroll" data-bs-target="#nav" tabindex="0"> | Scrollspy { target: "#nav", root: "#scroll-area", active: signal } |
let active_section = use_signal(|| String::new());
rsx! {
Scrollspy {
target: "#docs-nav",
root: "#docs-scroll",
active: active_section,
offset: 80,
}
nav { id: "docs-nav",
a { class: if *active_section.read() == "intro" { "nav-link active" } else { "nav-link" },
href: "#intro", "Intro" }
a { class: if *active_section.read() == "features" { "nav-link active" } else { "nav-link" },
href: "#features", "Features" }
}
}Fields§
§target: StringCSS selector for nav/list/simple links container.
root: StringCSS selector for scroll container. Use "body" for viewport scroll.
active: Signal<String>Signal receives id currently active section.
offset: i32Compatibility offset in pixels for fixed or sticky headers.
root_margin: StringIntersectionObserver root margin.
threshold: Vec<f64>IntersectionObserver thresholds.
refresh_key: u64Change this value to force section/link discovery refresh.
smooth_scroll: boolSmooth-scroll target links owned by target.
Implementations§
Source§impl ScrollspyProps
impl ScrollspyProps
Sourcepub fn builder() -> ScrollspyPropsBuilder<((), (), (), (), (), (), (), ())>
pub fn builder() -> ScrollspyPropsBuilder<((), (), (), (), (), (), (), ())>
Create a builder for building ScrollspyProps.
On the builder, call .target(...)(optional), .root(...)(optional), .active(...), .offset(...)(optional), .root_margin(...)(optional), .threshold(...)(optional), .refresh_key(...)(optional), .smooth_scroll(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ScrollspyProps.
Trait Implementations§
Source§impl Clone for ScrollspyProps
impl Clone for ScrollspyProps
Source§fn clone(&self) -> ScrollspyProps
fn clone(&self) -> ScrollspyProps
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more