Component
Snackbar
A FormaUI snackbar — a brief, transient message at the bottom of the screen, delegating to Material 3's Snackbar, with a standard (message-only) and an action variant.
dev.formaui.components.snackbar
Preview
This toggle is site chrome only — the preview has its own light/dark switch inside.
Live preview
Live preview — ~37 MB development build
Usage
FormaSnackbar(
message = "Message deleted.",
actionLabel = "Undo",
onAction = { /* undo */ },
)
// To surface transient messages, host queued snackbars:
val hostState = remember { SnackbarHostState() }
Scaffold(snackbarHost = { FormaSnackbarHost(hostState) }) { /* ... */ }
// elsewhere: scope.launch { hostState.showSnackbar("Saved.", actionLabel = "Undo") }FormaSnackbar
Renders the snackbar visual directly; the action button is shown only when both actionLabel and onAction are provided.
FormaSnackbarHost
Hosts snackbars queued through a SnackbarHostState, rendering each as a FormaUI-styled FormaSnackbar (including its action button); place it in a Scaffold's snackbarHost slot.
Supporting API
- FormaSnackbarDefaultsobject
- Default values used by FormaSnackbar; exposes shape (FormaUI's md corner tier).
Accessibility
message and actionLabel render as real Text, so both are announced, and the action becomes a focusable button only when actionLabel and onAction are both supplied. Prefer queueing through SnackbarHostState + FormaSnackbarHost so Material 3 owns the show/dismiss timing, rather than composing FormaSnackbar directly.