SnackBar
UseSnackBar() returns a window-scoped SnackBarHandle and captures the current Environment. Use it for feedback with an optional recovery action; use Toast for lightweight messages and Dialog for a decision that must interrupt the workflow.
Offer an action
Section titled “Offer an action”#include <huxerui/huxerui.h>
using namespace huxerui;
[[huxerui::composable]]View ArchiveAction() { auto archived = UseState(false); auto snack_bar = UseSnackBar(); return Button("Archive").OnClick([archived, snack_bar] { archived = true; snack_bar.Show("Item archived", "Undo", [archived] { archived = false; }); });}The action dismisses its request before invoking the callback. Showing a newer message replaces the current one atomically; callbacks or timers belonging to an older request cannot dismiss the replacement.
API and timing
Section titled “API and timing”Declared by <huxerui/presentation.h>.
Show(message, options = {})returns aLayerId.Show(message, action_label, on_action, options = {})adds one action.Dismiss(id)dismisses only the matching current request and returns false for stale or disconnected IDs.SnackBarOptions::durationdefaults to four seconds;std::nulloptkeeps it visible indefinitely.- The timer pauses while the surface/action is hovered, while the action is focused or pressed, and while the application is inactive.
SnackBarStylebelongs to the current theme.
Labels accept StringVariant, including string resources. Keep essential application state outside the presentation; an action is not guaranteed to be invoked before dismissal.
SnackBarStyle fields
Section titled “SnackBarStyle fields”| Fields | Use |
|---|---|
background, message_style |
Message surface and typography. |
padding, content_spacing, minimum_height, maximum_width |
Content inset, message/action gap, and surface sizing. |
shadow, corner_radii, viewport_padding, motion |
Surface treatment, safe-edge spacing, and optional transitions. |
action_text_style, action_background, action_indication |
The action’s typography, fill, and interaction states. |
action_padding, action_minimum_height, action_corner_radii |
The action’s geometry. |
A specified duration must be finite and positive. For an indefinite request, use SnackBarOptions{.duration = std::nullopt} and keep a dismiss path. The action callback is a command, not a boolean permission to close; the service closes its request first. A newer request does not queue behind the old one, so do not use SnackBar as an audit log or transaction queue.

