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: Html

Implementations§

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert self to a value of a Properties struct.
Convert self to a value of a Properties struct.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more