pub struct NavButtonProps {
pub active: bool,
pub disabled: bool,
pub onclick: Option<EventHandler<MouseEvent>>,
pub class: String,
pub children: Element,
/* private fields */
}Expand description
Bootstrap nav-link rendered as a <button> — the JS-toggled tab / SPA
navigation variant of NavLink.
Bootstrap supports button.nav-link for nav components driven by script
rather than by following an href (an in-page tab strip, a settings sidebar
that swaps sections). A button never navigates, so there is nothing to
prevent — use this instead of a NavLink with prevent_default when the
item is not a real link.
This renders a plain nav button (active → aria-current="page"). It does
not add role="tab"/aria-selected: those belong only inside a
role="tablist", which TabList already provides.
For a full ARIA tablist with managed panes, use TabList; use NavButton
for a plain button-driven nav.
§Bootstrap HTML → Dioxus
| HTML | Dioxus |
|---|---|
<button class="nav-link active">Home</button> | NavButton { active: true, "Home" } |
<button class="nav-link" disabled>Off</button> | NavButton { disabled: true, "Off" } |
let mut section = use_signal(|| 0);
rsx! {
Nav {
NavItem { NavButton { active: section() == 0, onclick: move |_| section.set(0), "General" } }
NavItem { NavButton { active: section() == 1, onclick: move |_| section.set(1), "Account" } }
}
}Fields§
§active: boolActive state.
disabled: boolDisabled state. Rendered as the <button> disabled attribute (Bootstrap
parity), not the .disabled class used for anchors.
onclick: Option<EventHandler<MouseEvent>>Click event handler.
class: StringAdditional CSS classes.
children: ElementChild elements.
Implementations§
Sourcepub fn builder() -> NavButtonPropsBuilder<((), (), (), (), (), ())>
pub fn builder() -> NavButtonPropsBuilder<((), (), (), (), (), ())>
Create a builder for building NavButtonProps.
On the builder, call .active(...)(optional), .disabled(...)(optional), .onclick(...)(optional), .class(...)(optional), .attributes(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of NavButtonProps.
Trait Implementations§
Source§fn clone(&self) -> NavButtonProps
fn clone(&self) -> NavButtonProps
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more