State of Compose 2023 results are in! Click here to learn more

← Back to Material Compose

SnackbarHost

Component
in
Material
. Since 0.1.0-dev17

Overview

Code Examples

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

This component with default parameters comes build-in with Scaffold, if you need to show a default Snackbar, use use ScaffoldState.snackbarHostState and SnackbarHostState.showSnackbar.

Overloads

SnackbarHost

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

Parameters

NameDescription
hostStatestate of this component to read and show Snackbars accordingly
modifieroptional modifier for this component
snackbarthe instance of the Snackbar to be shown at the appropriate time with appearance based on the SnackbarData provided as a para