# NavigationRail

> NavigationRail from Material Compose (`androidx.compose.material:material`) for Jetpack Compose, with a code sample.

- Library: [Material Compose](https://composables.com/material-components/material-compose.md)
- Category: [Navigation](https://composables.com/material-components/navigation.md)
- Category: [Rails](https://composables.com/material-components/rails.md)
- API reference and more examples: [NavigationRail](https://composables.com/jetpack-compose/androidx.compose.material/material/components/NavigationRail/api.md)

## Code

```kotlin
@Composable
fun NavigationRailSample() {
    var selectedItem by remember { mutableStateOf(0) }
    val items = listOf("Home", "Search", "Settings")
    val icons = listOf(Icons.Filled.Home, Icons.Filled.Search, Icons.Filled.Settings)
    NavigationRail(windowInsets = NavigationRailDefaults.windowInsets) {
        items.forEachIndexed { index, item ->
            NavigationRailItem(
                icon = { Icon(icons[index], contentDescription = item) },
                label = { Text(item) },
                selected = selectedItem == index,
                onClick = { selectedItem = index },
            )
        }
    }
}
```
