Struct patternfly_yew::components::toast::Toast
source · pub struct Toast {
pub title: String,
pub type: AlertType,
pub timeout: Option<Duration>,
pub body: Html,
pub actions: Vec<Action>,
}
Expand description
Toasts are small alerts that get shown on the top right corner of the page.
A toast can be triggered by every component. The toast fill get sent to an agent, the Toaster. The toaster will delegate displaying the toast to an instance of a ToastViewer component.
In order for Toasts to be displayed your application must have exactly one ToastViewer before creating the first Toast.
For example:
#[function_component(App)]
fn app() -> Html {
html! {
<>
<ToastViewer>
<View/>
</ToastViewer>
</>
}
}
#[function_component(View)]
fn view() -> Html {
let toaster = use_toaster().expect("Must be nested under a ToastViewer component");
html!{
<div>
<button onclick={move |_| toaster.toast("Toast Title")}>
{ "Click me" }
</button>
</div>
}
}
Fields§
§title: String
§type: AlertType
§timeout: Option<Duration>
The timeout when the toast will be removed automatically.
If no timeout is set, the toast will get a close button.
body: Html
§actions: Vec<Action>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Toast
impl !RefUnwindSafe for Toast
impl !Send for Toast
impl !Sync for Toast
impl Unpin for Toast
impl !UnwindSafe for Toast
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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.