pub struct ModalProps {
pub show: Signal<bool>,
pub title: String,
pub body: Option<Element>,
pub footer: Option<Element>,
pub size: ModalSize,
pub backdrop_close: bool,
pub show_close: bool,
pub centered: bool,
pub scrollable: bool,
pub fullscreen: ModalFullscreen,
pub class: String,
pub children: Element,
/* private fields */
}Expand description
Bootstrap Modal component — signal-driven, no JavaScript.
Replaces Bootstrap’s <div class="modal"> + JavaScript with a signal-controlled component.
§Bootstrap HTML → Dioxus
<!-- Bootstrap HTML (requires JavaScript) -->
<div class="modal fade" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header"><h5 class="modal-title">Title</h5></div>
<div class="modal-body"><p>Body</p></div>
<div class="modal-footer"><button class="btn btn-primary">OK</button></div>
</div>
</div>
</div>// Dioxus equivalent — no JavaScript needed
let show = use_signal(|| false);
rsx! {
Button { onclick: move |_| show.set(true), "Open Modal" }
Modal {
show: show,
title: "Confirm Action",
size: ModalSize::Lg,
centered: true,
body: rsx! { p { "Are you sure?" } },
footer: rsx! {
Button { color: Color::Secondary, onclick: move |_| show.set(false), "Cancel" }
Button { color: Color::Primary, "Confirm" }
},
}
}§Props
show—Signal<bool>controlling visibilitytitle— modal title textbody— modal body content (Element)footer— modal footer content (Element)size—ModalSize::Sm,Default,Lg,Xlfullscreen—ModalFullscreen::Off,Always,SmDown..XxlDowncentered— vertically center the modalscrollable— scrollable modal bodybackdrop_close— close when clicking backdrop (default: true)
Fields§
§show: Signal<bool>Signal controlling modal visibility.
title: StringModal title.
body: Option<Element>Modal body content.
Modal footer content.
size: ModalSizeModal size.
backdrop_close: boolClose when clicking the backdrop.
show_close: boolShow the close button in the header.
centered: boolCenter the modal vertically.
scrollable: boolAllow the modal body to scroll.
fullscreen: ModalFullscreenFullscreen mode.
class: StringAdditional CSS classes for the modal-dialog.
children: ElementChild elements (alternative to body prop for custom layout).
Implementations§
Source§impl ModalProps
impl ModalProps
Sourcepub fn builder() -> ModalPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> ModalPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building ModalProps.
On the builder, call .show(...), .title(...)(optional), .body(...)(optional), .footer(...)(optional), .size(...)(optional), .backdrop_close(...)(optional), .show_close(...)(optional), .centered(...)(optional), .scrollable(...)(optional), .fullscreen(...)(optional), .class(...)(optional), .attributes(...)(optional), .children(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of ModalProps.
Trait Implementations§
Source§impl Clone for ModalProps
impl Clone for ModalProps
Source§fn clone(&self) -> ModalProps
fn clone(&self) -> ModalProps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more