Skip to content

DrawerLayout

DrawerLayout owns the spatial relationship between main content and logical start/end drawers.

DrawerLayout(
Content(),
StartDrawer(Destinations()).Open(start_open).OnOpenChanged([start_open](bool value) {
start_open = value;
}),
EndDrawer(Tools()).Open(end_open).OnOpenChanged([end_open](bool value) {
end_open = value;
})
)

Construct it with content alone, content plus either side, or content plus both drawers. DrawerLayout resolves available width against DrawerStyle: sufficiently wide layouts can place drawers inline, while constrained layouts use modal placement and a scrim. Drawer open values stay controlled by the application.

Use logical start and end components instead of hard-coding left and right. Buttons in a TopAppBar commonly update the controlling state; no automatic toolbar coupling is required.

DrawerLayout does not replace the meaning of its children. Navigation content should use controls such as NavigationPane, while custom drawer content remains responsible for its own labels and roles; modal placement prevents background interaction while the drawer is active.

  • DrawerLayout(View content).
  • DrawerLayout(View content, StartDrawer start).
  • DrawerLayout(View content, EndDrawer end).
  • DrawerLayout(View content, StartDrawer start, EndDrawer end).
  • DrawerStyle and DrawerMotion configure responsive placement and motion.

See NavigationPane for typical drawer content.

Responsive policy and controlled modal state

Section titled “Responsive policy and controlled modal state”
Viewport class Start drawer preference End drawer preference
Compact Modal Modal
Medium Inline Modal
Expanded Inline Inline

Available layout width can override these preferences. Inline drawers first shrink from preferred_width toward minimum_width while preserving minimum_content_width. If both cannot fit, the end drawer falls back to modal first. This prevents a large window’s narrow nested layout from consuming all its content space.

Inline presentation is automatically visible; .Open(...) is the controlled modal request, not a command to hide a persistent region. Resizing should not require setting both booleans to true. Preserve the values for when that side returns to modal placement. An outside gesture or cancel request must be written back through OnOpenChanged.

background applies to the drawer surface. scrim, shadow, and corner_radius belong to modal presentation; inline drawers are flat and rectangular. preferred_width, minimum_width, and minimum_content_width define the responsive budget. modal_content_reveal reserves visible main content beside a modal drawer, and edge_drag_width defines its edge gesture region. Optional motion contains independent DrawerMotion::open / close animation specs.

Content remains in the application tree; a responsive mode change is not a request to replace its stateful subtree. Keep the drawer declarations stable and update their inputs. Do not build a second copy of the same destination pane in a separate Dialog to emulate the modal mode.