Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Android docs
FeedbackAndroid

Toast viewport

Stack timed notifications above the app inside the safe area.

Public APILumenToastViewportAndroid / Compose

Native example

Use Toast viewport

Render one viewport at the app root and show toasts through its queue. Keep messages short and actions optional.

Toast viewport rendered in the Android phone emulator Lumen playground
Captured exampleAndroid phone emulatorView dark appearance
kotlin
@Composable
fun UploadScreen(upload: suspend () -> Unit) {
    val toasts = rememberLumenToastViewportState()
    val scope = rememberCoroutineScope()

    fun startUpload() {
        scope.launch {
            try {
                upload()
                toasts.show("Upload complete", "Your files are ready to share.", LumenBannerVariant.Success)
            } catch (failure: IOException) {
                toasts.show(
                    title = "Upload failed",
                    description = "Check your connection and try again.",
                    variant = LumenBannerVariant.Destructive,
                    action = LumenToastAction("Retry") { startUpload() }
                )
            }
        }
    }

    Box(Modifier.fillMaxSize()) {
        LumenButton(onClick = { startUpload() }, modifier = Modifier.padding(LumenSpacing.Lg)) {
            LumenText("Upload files")
        }
        LumenToastViewport(toasts)
    }
}
Android
A screen-level toast stack that shows a success toast after saving and a destructive toast with a Retry action when an upload fails.

Reference

Public API

The primary shared and platform-specific options exposed by LumenToastViewport.

APIValues or typeDefaultDescription
placement / maxCount / durationscreen edge / visible toasts / auto-dismissbottom-center / 3 / 5000 msRender one viewport at the app root and show toasts through its queue.

Native behavior

Design and accessibility

When to use it

Render one viewport at the app root and show toasts through its queue. Keep messages short and actions optional.

Accessibility

Toasts announce by tone, pause while touched, and keep a named dismiss button.

Shared component

Available on other platforms

React NativeApple / SwiftUI Web
Android docsCompose module