Dialogs, Bottom Sheets and Snackbars

Android Development 9 min min read Updated: Nov 16, 2026 Beginner
Dialogs, Bottom Sheets and Snackbars
Beginner Topic 8 of 9

AlertDialog

kotlin @Composable fun DeleteDemo() { var showDialog by remember { mutableStateOf(false) } Button(onClick = { showDialog = true }) { Text("Delete account") } if (showDialog) { AlertDialog( onDismissRequest = { showDialog = false }, title = { Text("Delete account?") }, text = { Text("This cannot be undone.") }, confirmButton = { TextButton(onClick = { showDialog = false; /* delete */ }) { Text("Delete") } }, dismissButton = { TextButton(onClick = { showDialog = false }) { Text("Cancel") } } ) } }
Compose pattern: There is no dialog.show(). A dialog is simply a composable that appears when showDialog is true. Change the state and the dialog shows or hides.

Bottom Sheet

kotlin @OptIn(ExperimentalMaterial3Api::class) @Composable fun SheetDemo() { var show by remember { mutableStateOf(false) } val sheetState = rememberModalBottomSheetState() val scope = rememberCoroutineScope() Button(onClick = { show = true }) { Text("Options") } if (show) { ModalBottomSheet(onDismissRequest = { show = false }, sheetState = sheetState) { Column(Modifier.padding(16.dp).navigationBarsPadding()) { ListItem(headlineContent = { Text("Share") }, leadingContent = { Icon(Icons.Default.Share, null) }, modifier = Modifier.clickable { scope.launch { sheetState.hide() }.invokeOnCompletion { show = false } }) ListItem(headlineContent = { Text("Delete") }, leadingContent = { Icon(Icons.Default.Delete, null) }) } } } }

Snackbar with Action

kotlin val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() Scaffold(snackbarHost = { SnackbarHost(snackbarHostState) }) { padding -> Button(Modifier.padding(padding), onClick = { scope.launch { val result = snackbarHostState.showSnackbar( message = "Item deleted", actionLabel = "Undo", duration = SnackbarDuration.Short ) if (result == SnackbarResult.ActionPerformed) { /* restore the item */ } } }) { Text("Delete") } }

Toast: The Old Quick Message

kotlin val context = LocalContext.current Toast.makeText(context, "Saved", Toast.LENGTH_SHORT).show()

Prefer Snackbar because it follows Material design and can have an Undo action.

Progress Indicators

kotlin CircularProgressIndicator() LinearProgressIndicator(progress = { 0.6f }, modifier = Modifier.fillMaxWidth())
ComponentUse for
AlertDialogImportant yes or no questions
SnackbarShort messages and Undo
Bottom sheetExtra options or a small task
ToastVery simple system messages

Conclusion

Dialogs and sheets are composables controlled by state. Use Snackbar for feedback, AlertDialog for important confirmations.

Quick Summary: Show AlertDialog, ModalBottomSheet and Snackbar by changing state, and handle results with callbacks.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators