Skip to main content

CamoNavigationDrawer

Concept​

1. Why​

A navigation drawer lists destinations with full labels, section headers and dividers. It has two modes:

  • permanent: always visible on wide windows (the desktop sidebar; Apple's sidebar, Fluent's Nav);
  • modal: slides in from the start edge over the content, with a scrim, on phones when there are too many destinations for a bar.

It uses the same CamoNavItem model, and the modal mode reuses the overlay frame machinery, from the side instead of the bottom.

2. Shape​

Material mapping preview: the M3 navigation drawer.

  • 360 wide. surfaceContainerLow (modal) or surface (permanent).
  • Items 56 tall, with a full-width secondaryContainer pill when active.
  • Section titles titleSmall in onSurfaceVariant.
  • The modal drawer has shapes.large end corners and a scrim at 32%.

3. API​

Contract​

fun <T> CamoNavigationDrawer(
sections: List<CamoNavSection<T>>, // one untitled section for simple lists
selected: T,
onSelect: (T) -> Unit,
header: Widget? = null, // app logo, account switcher
)
data class CamoNavSection<T>(val title: String? = null, val items: List<CamoNavItem<T>>)

fun CamoModalDrawer(
open: Boolean,
onDismissRequest: () -> Unit, // scrim tap, back, Esc, drag to the start edge
content: Slot, // a CamoNavigationDrawer
)

The modal drawer's visibility is state (open), not a route: a menu button toggles it, and selecting an item closes it. That's the convention on both platforms. It's layout chrome, not a destination.

State → renderer: DrawerState(modal, selectedKey). Slots: header?, and section titles + NavItemSlots.

Tokens used​

  • colors.surface/surfaceContainerLow, secondaryContainer, onSecondaryContainer, onSurfaceVariant, outlineVariant, scrim
  • typography.labelLarge (items), titleSmall (section titles), shapes.full (item pill), shapes.large (modal corners)
  • motion.durationMedium + easingEmphasized (slide)

Component theme​

theme.components.navigationDrawer: NavigationDrawerTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.

FieldTypeMaterial defaultWhat it's for
indicatorNavIndicator (Pill | Line | Dot | Fill | None)Pillthe selected item's indicator. Line = a start-edge line (Fluent, Carbon); Fill = a filled row (Minimal). The size and shape fields apply to the chosen style.
widthDp360drawer width (max 80% of the window on phones)
itemHeightDp56item rows
itemShapeShapeshapes.fullactive pill
modalShapeShapeshapes.large (end corners)modal container
labelStyle / sectionTitleStyleCamoTextStylelabelLarge / titleSmalltexts
scrimAlphaFloat0.32modal scrim
colorsDrawerColors(container, modalContainer, indicator, selectedContent, content, sectionTitle)M3 valuesevery color it uses

Accessibility​

  • A navigation landmark. Section titles are headings. Items are links/tabs with a selected state.
  • Modal: announced as a pane ("Navigation"). Focus moves in and is trapped. Back/Esc closes it and returns focus to the menu button.
  • It's never drag-only: the scrim, back and Esc also close it.

4. Build steps​

  1. The side frame (reusing the sheet frame's scrim, focus and dismissal logic, horizontally).
  2. CamoNavigationDrawer, CamoModalDrawer, NavigationDrawerRenderer, and the DebugSkin renderer.
  3. Sample: a permanent drawer on desktop (via CamoAdaptiveNavigation), and a modal drawer on phones opened from the top bar's menu button.
  4. Tests:
    • open/close by button, scrim, back, Esc and drag;
    • selecting closes the modal drawer;
    • focus restored to the menu button;
    • RTL slides in from the right.

Done when

  • Both modes work on every platform, and match the bar and rail's selection in the adaptive sample.

5. Edge cases​

CaseDecided behavior
An edge-swipe to open (from the screen edge)Off by default, because it conflicts with system back gestures on Android and iOS. Apps can enable it (CamoModalDrawer(edgeSwipeToOpen = true)).
Long destination listsThe drawer scrolls. The header stays fixed.
Nested destinations (expandable groups)Later.
Changed in the M8 build (2026-11-01)
  • The drawer renderer draws a container (with the fixed header above a scrolling column), the section titles and the items. Items inside a CamoModalDrawer close it when chosen.
  • CamoModalDrawer(open, onDismissRequest): the popup stays until the slide-out finishes; a scrim tap, back, Esc and a drag toward the start edge all call onDismissRequest; RTL slides in from the right. Kotlin uses a focus-trapping popup; Flutter an OverlayPortal (so it needs an Overlay above it, as inside any route) with an autofocus FocusScope and a PopScope for back.
  • edgeSwipeToOpen is not built (it is off by default).
  • Fluent's pane is 260 wide with items 40, a 2 px brand line and a subtle selected row.

Implementation​

1. Why​

The drawer has two modes: permanent (a side panel on wide windows) and modal (slides over the content with a scrim). Kotlin implements the modal one in-layer like the overlay frames: a scrim, a drag-to-close gesture with anchoredDraggable, a focus trap, back and Esc handling.

2. Shape​

3. API​

@Composable
public fun <T> CamoNavigationDrawer(
sections: List<CamoNavSection<T>>,
selected: T,
onSelect: (T) -> Unit,
modifier: Modifier = Modifier,
header: (@Composable () -> Unit)? = null,
)

@Composable
public fun CamoModalDrawer(open: Boolean, onDismissRequest: () -> Unit, modifier: Modifier = Modifier, content: @Composable () -> Unit)
  • Items: full-width rows, selectable(role = Role.Tab); style.indicator draws Pill, Line (start edge), Fill (Minimal) or None. Section titles are headings.
  • Modal drawer: rendered in the provider's overlay layer (above content, below snackbars). AnchoredDraggableState with anchors Closed = -panelWidth and Open = 0 (mirrored in RTL); a fling or a drag past half closes it and calls onDismissRequest. The scrim alpha follows the drag fraction.
  • Modality: the scrim consumes pointer input; focus moves to the first item on open and is trapped inside the panel (focusGroup + focusProperties { exit = { FocusRequester.Cancel } }); the back handler and Esc call onDismissRequest; semantics { paneTitle = "Navigation" }.
  • Width: min(style.width, 0.8 × window width) on phones.

4. Build steps​

  1. CamoNavSection, NavigationDrawerTheme / Style, CamoNavigationDrawer, CamoModalDrawer, the DebugSkin renderer.
  2. UI tests: permanent selection; modal opens, closes by scrim, back, Esc and drag; focus is trapped and returns to the menu button; RTL slides from the right.

Done when

  • The adaptive sample shows a permanent drawer on desktop, and a modal drawer from a top-bar menu button on phones, on all targets.

5. Edge cases​

CaseDecided behavior
open flips while draggingThe state animates to the new target from the current offset.
Selecting an item in the modal drawerThe app calls onSelect and closes the drawer (the sample shows the pattern: navigate, then open = false).
Nested destinations (expandable groups)Later.