Navigation drawer

A side panel with many destinations. Modal, dismissible or permanent.

When to use

Use a modal drawer on compact windows, a dismissible drawer when the content should shift aside, and a permanent drawer on large windows where there is room. This documentation uses exactly that pattern.

For new designs on medium and expanded windows, the wide navigation rail is the recommended component. The drawers remain supported.

Examples

Permanent drawer

Always visible next to the content.

var selected by rememberSaveable { mutableIntStateOf(0) }
val items = listOf(
    Icons.Rounded.Inbox to "Inbox",
    Icons.Rounded.Send to "Sent",
    Icons.Rounded.Star to "Starred",
)

Box(Modifier.fillMaxWidth().height(260.dp)) {
    PermanentNavigationDrawer(
        drawerContent = {
            PermanentDrawerSheet(Modifier.padding(end = 0.dp)) {
                Text("Mail", Modifier.padding(24.dp), style = MaterialTheme.typography.titleLarge)
                items.forEachIndexed { index, (icon, label) ->
                    NavigationDrawerItem(
                        icon = { Icon(icon, contentDescription = null) },
                        label = { Text(label) },
                        selected = selected == index,
                        onClick = { selected = index },
                        modifier = Modifier.padding(horizontal = 12.dp),
                    )
                }
            }
        },
    ) {
        Box(Modifier.fillMaxWidth().padding(24.dp), contentAlignment = Alignment.TopStart) {
            Text(items[selected].second, style = MaterialTheme.typography.headlineMedium)
        }
    }
}

Parameters

NameTypeDefaultDescription
drawerContent@Composable () -> UnitUsually a ModalDrawerSheet, DismissibleDrawerSheet or PermanentDrawerSheet.
drawerStateDrawerStaterememberDrawerState(Closed)Modal and dismissible drawers only.
gesturesEnabledBooleantrueAllows opening and closing by swipe.

Guidelines

Do:

Don't:

Accessibility

Related components