androidx.navigation.compose

Classes

ComposeNavigator

Navigator that navigates through Composables.

Cmn
ComposeNavigator.Destination

NavDestination specific to ComposeNavigator

Cmn
ComposeNavigatorDestinationBuilder

DSL for constructing a new ComposeNavigator.Destination

Cmn
DialogNavigator

Navigator that navigates through Composables that will be hosted within a Dialog.

Cmn
DialogNavigator.Destination

NavDestination specific to DialogNavigator

Cmn
DialogNavigatorDestinationBuilder

DSL for constructing a new DialogNavigator.Destination

Cmn

Composables

DialogHost

Show each Destination on the DialogNavigator's back stack as a Dialog.

Cmn
LocalOwnersProvider

Provides this as LocalViewModelStoreOwner, LocalLifecycleOwner and LocalSavedStateRegistryOwner to the content and saves the content's saveable states with the given saveableStateHolder.

Cmn
NavHost

Provides a place in the Compose hierarchy for self contained navigation to occur.

Cmn
currentBackStackEntryAsState

Gets the current navigation back stack entry as a MutableState.

Cmn
rememberNavController

Creates a NavHostController that handles the adding of the ComposeNavigator and DialogNavigator.

Cmn
android

Extension functions summary

inline Unit
<T : Any> NavGraphBuilder.composable(
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
Unit
<T : Any> NavGraphBuilder.composable(
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
Unit
NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
inline Unit
<T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    noinline content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
Unit
<T : Any> NavGraphBuilder.dialog(
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
Unit
NavGraphBuilder.dialog(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
inline Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
inline Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn

Extension functions

NavGraphBuilder.composable

inline fun <T : Any> NavGraphBuilder.composable(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

Parameters
<T : Any>

route from a KClass for the destination

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

NavGraphBuilder.composable

fun <T : Any> NavGraphBuilder.composable(
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

Parameters
route: KClass<T>

route from a KClass for the destination

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

NavGraphBuilder.composable

fun NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable<Collapsed>(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2,
                        ) at 150
                    }
                }
            },
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable<Expanded>(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            },
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

NavGraphBuilder.dialog

inline fun <T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    noinline content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
<T : Any>

route from a KClass for the destination

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

noinline content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

NavGraphBuilder.dialog

fun <T : Any> NavGraphBuilder.dialog(
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
route: KClass<T>

route from KClass of T for the destination

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

NavGraphBuilder.dialog

fun NavGraphBuilder.dialog(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

NavGraphBuilder.navigation

inline fun <T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
<T : Any>

the destination's unique route from a KClass

startDestination: Any

the starting destination's route from an Object for this NavGraph

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

NavGraphBuilder.navigation

inline fun <T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        navigation<NestedGraph>(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            startDestination = InnerCollapsed::class,
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2,
                        ) at 150
                    }
                }
            },
        ) {
            composable<InnerCollapsed>(
                enterTransition = { EnterTransition.None },
                exitTransition = { ExitTransition.None },
            ) {
                ExpandedScreen {}
            }
        }
    }
}
Parameters
<T : Any>

the destination's unique route from a KClass

startDestination: KClass<*>

the starting destination's route from KClass for this NavGraph

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

NavGraphBuilder.navigation

fun <T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
startDestination: Any

the starting destination's route from an Object for this NavGraph

route: KClass<T>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

NavGraphBuilder.navigation

fun <T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    route: KClass<T>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
startDestination: KClass<*>

the starting destination's route from KClass for this NavGraph

route: KClass<T>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

NavGraphBuilder.navigation

fun NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
startDestination: String

the starting destination's route for this NavGraph

route: String

the destination's unique route

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph