Skip to content

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

StandardAction

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.

messagerequiredTypeStringDefaultrequiredDescriptionthe text to display.
modifierTypeModifierDefaultModifierDescriptionthe Modifier applied to the snackbar.
actionLabelTypeString?DefaultnullDescriptionoptional action button label; the action is shown only when both this and onAction are provided.
onActionType(() -> Unit)?DefaultnullDescriptionoptional action callback.
shapeTypeShapeDefaultFormaSnackbarDefaults.shapeDescriptionthe snackbar container shape (defaults to FormaSnackbarDefaults.shape).
containerColorTypeColorDefaultSnackbarDefaults.colorDescriptionthe snackbar's background color (defaults to the M3 default).
contentColorTypeColorDefaultSnackbarDefaults.contentColorDescriptionthe color of the message text (defaults to the M3 default).
actionContentColorTypeColorDefaultSnackbarDefaults.actionColorDescriptionthe color of the action button's label (defaults to SnackbarDefaults.actionColor — the same value FormaUI used before this was configurable, so the action keeps its look unless overridden).
messageTextStyleTypeTextStyle?DefaultnullDescriptionoptional TextStyle override for message, merged on top of the M3 snackbar body style.
actionLabelTextStyleTypeTextStyle?DefaultnullDescriptionoptional TextStyle override for actionLabel, merged on top of the M3 action-button label style.

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.

hostStaterequiredTypeSnackbarHostStateDefaultrequiredDescriptionthe SnackbarHostState whose current message is displayed.
modifierTypeModifierDefaultModifierDescriptionthe Modifier applied to the host.

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.