API Reference Item

DialogSceneStrategy.Companion.DialogKey

The key for NavEntry.metadata or Scene.metadata to indicate that an entry should be displayed within a Dialog.

DialogSample

@Serializable private object OverlaidNavKey : NavKey

@Serializable private object DialogNavKey : NavKey

@Composable
@Sampled
fun DialogSample() {
    val backStack = rememberNavBackStack(OverlaidNavKey)
    NavDisplay(
        backStack,
        onBack = { backStack.removeLastOrNull() },
        sceneStrategies = listOf(DialogSceneStrategy()),
        entryProvider =
            entryProvider {
                entry<OverlaidNavKey> {
                    Box(
                        Modifier.fillMaxSize()
                            .background(Color(0.2f, 0.2f, 1.0f, 1.0f))
                            .border(10.dp, Color.Blue),
                        contentAlignment = Alignment.Center,
                    ) {
                        Column(horizontalAlignment = Alignment.CenterHorizontally) {
                            BasicText(
                                "Overlaid Entry",
                                Modifier.size(50.dp),
                                style = TextStyle(textAlign = TextAlign.Center),
                            )
                            Button(onClick = { backStack.add(DialogNavKey) }) {
                                Text("Open Dialog")
                            }
                        }
                    }
                }
                entry<DialogNavKey>(metadata = metadata { put(DialogKey, DialogProperties()) }) {
                    RedBox("Dialog")
                }
            },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: