Skip to content

Jetpack Navigation Compose Material

Maven Central

A library which provides Compose Material support for Jetpack Navigation Compose. This features composable bottom sheet destinations.

Warning

The navigation APIs are currently experimental and they could change at any time. All of the APIs are marked with the @ExperimentalMaterialNavigationApi annotation.

Usage

Bottom Sheet Destinations

  1. Create a BottomSheetNavigator and add it to the NavController:

    @Composable
    fun MyApp() {
        val navController = rememberNavController()
        val bottomSheetNavigator = rememberBottomSheetNavigator()
        navController.navigatorProvider += bottomSheetNavigator
    }
    
  2. Wrap your NavHost in the ModalBottomSheetLayout composable that accepts a BottomSheetNavigator.

    @Composable
    fun MyApp() {
        val navController = rememberNavController()
        val bottomSheetNavigator = rememberBottomSheetNavigator()
        navController.navigatorProvider += bottomSheetNavigator
        ModalBottomSheetLayout(bottomSheetNavigator) {
            NavHost(navController, Destinations.Home) {
               // We'll define our graph here in a bit!
            }
        }
    }
    
  3. Register a bottom sheet destination

    @Composable
    fun MyApp() {
        val navController = rememberNavController()
        val bottomSheetNavigator = rememberBottomSheetNavigator()
        navController.navigatorProvider += bottomSheetNavigator
        ModalBottomSheetLayout(bottomSheetNavigator) {
            NavHost(navController, Destinations.Home) {
               composable(route = "home") {
                   ...
               }
               bottomSheet(route = "sheet") {
                   Text("This is a cool bottom sheet!")
               }
            }
        }
    }
    

For more examples, refer to the samples.

Download

Maven Central

repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-navigation-material:<version>"
}

Snapshots of the development version are available in Sonatype's snapshots repository. These are updated on every commit.