Snackbar
fun UiTreeBuilder.Snackbar(visible: Boolean, message: String, actionLabel: String? = null, duration: SnackbarDuration = SnackbarDuration.Short, queuePolicy: TransientFeedbackQueuePolicy = TransientFeedbackQueuePolicy.Enqueue, requestKey: String = "snackbar", onAction: () -> Unit? = null, onDismiss: (TransientFeedbackDismissReason) -> Unit? = null)(source)
Submits a keyed snackbar request to the active overlay presenter.
No request is submitted when visible is false. Duration and queueing are presenter-owned; callbacks run on the presenter thread and do not mutate visible automatically.
Receiver
active tree builder submitting the transient request
Parameters
visible
whether this render includes the snackbar request
message
message displayed by the presenter
action Label
optional label for the snackbar action
duration
presenter duration category
queue Policy
behavior when another transient item is active
request Key
stable identity used for deduplication and replacement
on Action
optional callback invoked when the action is accepted
on Dismiss
optional callback receiving the terminal dismissal reason
Samples
Snackbar(visible = true, message = "Saved", requestKey = "save")
Toast(visible = true, message = "Connected", requestKey = "connection")
Dialog(visible = true, requestKey = "confirm", onDismissRequest = {}) {
Text("Confirm")
}
Popup(visible = true, anchorId = "account-anchor", onDismissRequest = {}) {
Text("Account")
}
PlainTooltip(text = "Open account", visible = true, anchorId = "account-anchor")
DropdownMenu(expanded = true, anchorId = "account-anchor", onDismissRequest = {}) {
DropdownMenuItem(text = "Settings", onClick = {})
}Content copied to clipboard