pub struct Backdrop {
pub content: Html,
}Expand description
Backdrop overlay the main content and show some new content, until it gets closed.
New content can be sent to the backdrop viewer using the Backdropper::open call. It can be
closed using the Backdropper::close call.
§Contexts
The BackdropViewer must be wrapped by all contexts which the backdrop content might use,
as the content is injected as a child into the backdrop element. So if you can to send toasts
from a modal dialog, the ToastViewer must be wrapping the
BackdropViewer.
§Example
#[function_component(App)]
fn app() -> Html {
html! {
<>
<BackdropViewer>
<View/>
</BackdropViewer>
</>
}
}
#[function_component(View)]
fn view() -> Html {
let backdropper = use_backdrop().expect("Must be nested under a BackdropViewer component");
html!{
<div>
<button onclick={move |_| backdropper.open(Backdrop::new(
html! {
<Bullseye>
<Modal
title={"Example modal"}
variant={ ModalVariant::Medium }
description={"A description is used when you want to provide more info about the modal than the title is able to describe."}
>
<p>{"The modal body can contain text, a form, any nested html will work."}</p>
</Modal>
</Bullseye>
}))
}>
{ "Click me" }
</button>
</div>
}
}Fields§
§content: HtmlImplementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Backdrop
impl !RefUnwindSafe for Backdrop
impl !Send for Backdrop
impl !Sync for Backdrop
impl Unpin for Backdrop
impl !UnwindSafe for Backdrop
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.