Package-level declarations

Snackbars inform users of a process that an app has performed or will perform They appear temporarily, towards the bottom of the screen. They should not interrupt the user experience, and they don’t require user input to disappear. Only one snackbar may be displayed at a time.

@Composable
public fun Snackbar(
data: SnackbarData,
modifier: Modifier = Modifier,
actionOnNewLine: Boolean = false,
withDismissAction: Boolean = false,
){}
private val snackbarHostState = remember { SnackbarHostState() }

LaunchedEffect(conversationsState) {
if (shouldShowSnackbar) {
snackbarHostState.showSnackbar(
message = "Message",
duration = SnackbarDuration.Short)
}
}
Scaffold(
snackbarHost = {
SnackbarHost(hostState = snackbarHostState)
},
) { innerPadding ->
// Content
}

Types

Link copied to clipboard

State of the SnackbarHost, which controls the queue and the current Snackbar being shown inside the SnackbarHost.

Link copied to clipboard
Link copied to clipboard
class SnackbarSparkVisuals(val message: String, val icon: SparkIcon? = null, val intent: SnackbarIntent = SnackbarDefaults.intent, val style: SnackbarStyle = SnackbarDefaults.style, val actionLabel: String? = null, val withDismissAction: Boolean = false, val actionOnNewLine: Boolean = false, val duration: SnackbarDuration = SnackbarDuration.Short) : SnackbarVisuals

SnackbarVisuals interface that defines the visuals for a Snackbar.

Link copied to clipboard

SnackbarStyle is used to define the style of the Snackbar, which can be Filled or Tinted.

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun Snackbar(data: SnackbarData, modifier: Modifier = Modifier)

Snackbars provide brief messages about app processes at the bottom of the screen.

fun Snackbar(modifier: Modifier = Modifier, intent: SnackbarIntent = SnackbarDefaults.intent, style: SnackbarStyle = SnackbarDefaults.style, actionOnNewLine: Boolean = false, withDismissAction: Boolean = false, icon: SparkIcon? = null, actionLabel: String? = null, onActionClick: () -> Unit? = null, onDismissClick: () -> Unit? = null, content: @Composable () -> Unit)

Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn’t interrupt the user experience, and they don’t require user input to disappear.

Link copied to clipboard
fun SnackbarHost(hostState: SnackbarHostState, modifier: Modifier = Modifier, snackbar: @Composable (SnackbarData) -> Unit = { Snackbar(it) })

Host for Snackbars to be used in Scaffold to properly show, hide and dismiss items based on Material specification and the hostState.