pub struct Snackbar { /* private fields */ }Expand description
A message for a window’s snackbar queue. The default timeout is four seconds.
Implementations§
Source§impl Snackbar
impl Snackbar
Sourcepub fn new(message: impl Into<SharedString>) -> Self
pub fn new(message: impl Into<SharedString>) -> Self
Creates a snackbar with the given message text and a default four-second timeout.
Sourcepub fn timeout(self, timeout: Option<Duration>) -> Self
pub fn timeout(self, timeout: Option<Duration>) -> Self
Sets how long the message is visible. None waits for explicit dismissal.
Sourcepub fn action(
self,
label: impl Into<SharedString>,
action: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn action( self, label: impl Into<SharedString>, action: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Adds a keyboard-accessible action. By default, messages with an action
persist. Call timeout after this method to set a duration explicitly.
Sourcepub fn message(&self) -> &SharedString
pub fn message(&self) -> &SharedString
Returns the plain message used as the status announcement.
Sourcepub fn action_label(&self) -> Option<&SharedString>
pub fn action_label(&self) -> Option<&SharedString>
Returns the accessible name of the optional action.
Sourcepub fn message_content<E: IntoElement>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Self
pub fn message_content<E: IntoElement>( self, content: impl Fn(&mut Window, &mut App) -> E + 'static, ) -> Self
Replaces the visible message with repeatable decorative content.
Sourcepub fn action_content<E: IntoElement>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Self
pub fn action_content<E: IntoElement>( self, content: impl Fn(&mut Window, &mut App) -> E + 'static, ) -> Self
Replaces the visible content of the named action supplied by Self::action.
Sourcepub fn dismiss_label(self, label: impl Into<SharedString>) -> Self
pub fn dismiss_label(self, label: impl Into<SharedString>) -> Self
Overrides the accessible name of the default dismiss button (default "Dismiss message").
Sourcepub fn dismiss_content<E: IntoElement>(
self,
label: impl Into<SharedString>,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Self
pub fn dismiss_content<E: IntoElement>( self, label: impl Into<SharedString>, content: impl Fn(&mut Window, &mut App) -> E + 'static, ) -> Self
Supplies the accessible name and decorative content of the close affordance.
Sourcepub fn show_dismiss(self, show: bool) -> Self
pub fn show_dismiss(self, show: bool) -> Self
Shows or hides the explicit dismiss button. It is shown by default.
Sourcepub fn action_on_new_line(self, enabled: bool) -> Self
pub fn action_on_new_line(self, enabled: bool) -> Self
Places the action below the message for a long action label.
Sourcepub fn shape(self, shape: CornerShape) -> Self
pub fn shape(self, shape: CornerShape) -> Self
Overrides the corner shape of the snackbar container.
Sourcepub fn tone(self, tone: SemanticTone) -> Self
pub fn tone(self, tone: SemanticTone) -> Self
Applies a Material 3 semantic tone shortcut.
SemanticTone::Default keeps the M3 inverse palette; semantic tones
use (Container, OnContainer, Role) while explicit Self::colors
overrides still take precedence.
Sourcepub fn colors(self, colors: SnackbarColors) -> Self
pub fn colors(self, colors: SnackbarColors) -> Self
Overrides the snackbar’s container, content, action, and dismiss colors.
Sourcepub fn on_dismiss(
self,
dismissed: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn on_dismiss( self, dismissed: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Runs on timeout, user dismissal, or explicit dismissal by the caller.
Auto Trait Implementations§
impl !RefUnwindSafe for Snackbar
impl !Send for Snackbar
impl !Sync for Snackbar
impl !UnwindSafe for Snackbar
impl Forget for Snackbar
impl Freeze for Snackbar
impl Move for Snackbar
impl Unpin for Snackbar
impl UnsafeUnpin for Snackbar
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more