pub struct OffcanvasProps {
pub show: Signal<bool>,
pub title: String,
pub placement: OffcanvasPlacement,
pub backdrop_close: bool,
pub backdrop: bool,
pub show_close: bool,
pub responsive: String,
pub class: String,
pub children: Element,
}Expand description
Bootstrap Offcanvas (slide-in sidebar) — signal-driven, no JavaScript.
§Bootstrap HTML → Dioxus
<!-- Bootstrap HTML (requires JavaScript) -->
<button data-bs-toggle="offcanvas" data-bs-target="#sidebar">Open</button>
<div class="offcanvas offcanvas-start" id="sidebar">
<div class="offcanvas-header"><h5>Menu</h5><button class="btn-close" data-bs-dismiss="offcanvas"></button></div>
<div class="offcanvas-body">Content</div>
</div>// Dioxus equivalent
let show = use_signal(|| false);
rsx! {
Button { onclick: move |_| show.set(true), "Open Sidebar" }
Offcanvas { show: show, title: "Menu", placement: OffcanvasPlacement::Start,
Nav { vertical: true, pills: true,
NavItem { NavLink { active: true, "Home" } }
NavItem { NavLink { "Settings" } }
}
}
}§Props
show—Signal<bool>controlling visibilitytitle— header titleplacement—OffcanvasPlacement::Start,End,Top,Bottombackdrop— show backdrop overlay (default: true)backdrop_close— close on backdrop click (default: true)responsive— responsive variant breakpoint (e.g., “lg”)
Fields§
§show: Signal<bool>Signal controlling visibility.
title: StringTitle shown in the offcanvas header.
placement: OffcanvasPlacementPlacement (which side it slides in from).
backdrop_close: boolClose when clicking the backdrop.
backdrop: boolShow backdrop overlay.
show_close: boolShow close button.
responsive: StringResponsive variant — offcanvas only below this breakpoint. E.g., “lg” makes it offcanvas below lg, regular content above.
class: StringAdditional CSS classes.
children: ElementChild elements (offcanvas body content).
Implementations§
Source§impl OffcanvasProps
impl OffcanvasProps
Sourcepub fn builder() -> OffcanvasPropsBuilder<((), (), (), (), (), (), (), (), ())>
pub fn builder() -> OffcanvasPropsBuilder<((), (), (), (), (), (), (), (), ())>
Create a builder for building OffcanvasProps.
On the builder, call .show(...), .title(...)(optional), .placement(...)(optional), .backdrop_close(...)(optional), .backdrop(...)(optional), .show_close(...)(optional), .responsive(...)(optional), .class(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of OffcanvasProps.
Trait Implementations§
Source§impl Clone for OffcanvasProps
impl Clone for OffcanvasProps
Source§fn clone(&self) -> OffcanvasProps
fn clone(&self) -> OffcanvasProps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more