Skip to main content

CamoDialog

Concept​

1. Why​

A dialog interrupts the user to confirm or inform. It opens through the platform's navigator: showCamoDialog in Flutter, and a Navigation 3 entry registered with Camouflage dialog metadata in Compose (see Overlays). CamoDialog is the content component: title, message, actions, optional custom content. The dialog frame around it (scrim, centering, focus trap, back/Esc) comes from core, and is placed by the navigator integration.

The title and message are values. The actions are CamoButton widgets, so button appearances, tones and any button renderer override apply inside dialogs too.

2. Shape​

Written like a page, in its own file:

// Flutter: delete_item_dialog.dart
class DeleteItemDialog extends StatelessWidget {
const DeleteItemDialog({super.key});
static Future<bool?> show(BuildContext context) =>
showCamoDialog<bool>(context: context, builder: (_) => const DeleteItemDialog());
@override
Widget build(BuildContext context) => CamoDialog(
title: 'Delete item?', message: "This can't be undone.",
confirm: CamoButton(text: 'Delete', tone: Tone.error, onPressed: () => Navigator.pop(context, true)),
dismiss: CamoButton(text: 'Cancel', appearance: Appearance.ghost, onPressed: () => Navigator.pop(context, false)),
);
}
// screen: if (await DeleteItemDialog.show(context) == true) notifier.onEvent(DeleteRequested(item));
// Compose: DeleteItemDialog.kt: a registered route
@Serializable data class DeleteItem(val id: String) : NavKey

fun EntryProviderScope<NavKey>.deleteItemDialog(backStack: NavBackStack, results: CamoNavResults) =
entry<DeleteItem>(metadata = CamoDialogSceneStrategy.dialog()) { key ->
CamoDialog(
title = "Delete item?", message = "This can't be undone.",
confirm = { CamoButton(text = "Delete", tone = Tone.Error, onClick = { results.set(key, true); backStack.removeLastOrNull() }) },
dismiss = { CamoButton(text = "Cancel", appearance = Appearance.Ghost, onClick = { backStack.removeLastOrNull() }) },
)
}
// screen: backStack.add(DeleteItem(item.id)); results.consume<Boolean>(DeleteItem(item.id)) { if (it) viewModel.delete(item) }

Material mapping preview: the M3 Basic dialog.

  • Container: surfaceContainerHigh, shapes.extraLarge, level5.
  • Title: headlineSmall.
  • Message: bodyMedium in onSurfaceVariant.
  • Actions: end-aligned, with dismiss to the start of confirm.
  • Scrim: scrim at 32%.

See Material Skin.

3. API​

Contract​

fun CamoDialog(
message: String,
confirm: Widget, // usually CamoButton(…) that closes with a result
title: String? = null,
dismiss: Widget? = null, // usually CamoButton(appearance = Ghost) that closes without one
content: Slot? = null, // optional custom content below the message (a list, a form)
)
ParameterWhat it's for
messagethe main text. It's a value, drawn by the renderer in the skin's body style.
titleoptional heading. It's also the dialog's accessible name.
confirm, dismissaction widgets. They close the dialog through the navigator: Navigator.pop(context, result) in Flutter, or set a result + remove the entry in Compose.
contentlayout content for richer dialogs (a radio list, a small form). It's a slot, because it's layout, not text.

Dismissal (scrim tap, back, Esc) is handled by the dialog frame, and closes the dialog without a result. To stop it (for example while saving), use PopScope (Flutter) or OnDismissRequest { … } (Compose), or open it with dismissible = false.

State → renderer: DialogState(title?, message, dismissible, onDismissRequest) (the last two from the frame; a skin with a ✕ uses them). Slots: DialogSlots(confirm, dismiss?, content?).

Tokens used​

  • colors.surfaceContainerHigh, onSurface, onSurfaceVariant, scrim
  • shapes.extraLarge, elevation.level5
  • typography.headlineSmall (title), bodyMedium (message)
  • spacing.xl padding, spacing.s between actions, spacing.l between title, message and content
  • motion.durationMedium + easingEmphasized for enter; durationShort for exit

Component theme​

theme.components.dialog: DialogTheme?. 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
shapeShapeshapes.extraLargecontainer corners
minWidth / maxWidthDp280 / 560width bounds
paddingPaddingspacing.xl (24)inner padding
titleStyle / messageStyleCamoTextStyleheadlineSmall / bodyMediumtext styles
titleAlignStart | CenterStarttitle and message alignment (ADR-28)
actionsLayoutEnd | Center | FullWidthRow | StackedEndhow confirm and dismiss are arranged (ADR-28). Stacked puts confirm on top, full width.
showCloseButtonBooleanfalsea ✕ at the top end, shown only when the dialog is dismissible (ADR-25)
elevationElevationLevelLevel5depth
scrimAlphaFloat0.32scrim opacity over colors.scrim (used by the dialog frame)
stackedScrimEach | TopOnlyEachwhen opened above another overlay: add its own scrim or share one
colorsDialogColors(container, title, message)surfaceContainerHigh, onSurface, onSurfaceVariantevery color the dialog uses

Accessibility​

  • Role dialog (modal). The title is its accessible name (or the message if there's no title). The screen reader is confined to the dialog while it's open.
  • Focus moves into the dialog when it opens, is trapped while it's open, and returns to the opener on close (the overlay frame does this).
  • Escape and system back are dismissal requests.
  • The scrim isn't focusable.

4. Build steps​

  1. The dialog frame in core, and the navigator integration (Overlays build steps).
  2. CamoDialog + DialogRenderer. The DebugSkin renderer is a centered box with the title, message, content, and a row of actions.
  3. Sample:
    • DeleteItemDialog (destructive confirm with tone = Error) returning Boolean;
    • SortOrderDialog with a content radio list, returning the chosen order;
    • a dialog opened from inside a nested promo-theme section, which must show the promo theme.
  4. Tests:
    • the caller receives the result (Flutter Future, Compose CamoNavResults);
    • a scrim tap, back and Esc close without a result;
    • PopScope / OnDismissRequest can veto dismissal;
    • the nested theme is used;
    • focus returns to the opener;
    • the title is the accessible name.

Done when

  • A screen opens a dialog with one line (Flutter show, Compose backStack.add) and gets a typed result.
  • The dialog from the nested section shows the nested theme.
  • Focus is trapped while open and restored on close.

5. Edge cases​

CaseDecided behavior
Opened from a nested providerFlutter: showCamoDialog captures the skin and theme at the call site. Compose: the entry renders inside the NavDisplay's provider tree (see Overlays §5).
Skin switch while openIt stays open and re-renders with the new skin.
Blocking dismissal while savingPopScope(canPop: !saving) (Flutter) / OnDismissRequest { !saving } (Compose), or dismissible = false.
Long message at 200% font scaleThe message and content scroll inside the dialog. The title and actions stay visible. Max height is 90% of the window.
Small window / landscapeWidth is min(560, window width − 48). There's no full-screen dialog in v1.
RTLThe action order mirrors (confirm stays at the end).
A dialog whose visibility is app state (Compose without Navigation 3)Use the frame directly: if (show) CamoDialogFrame(onDismissRequest = { show = false }) { CamoDialog(…) }.
Stacked dialogsAllowed (LIFO). Guidance: avoid them.
Action arrangement (ADR-23, ADR-28)confirm and dismiss are separate slots, arranged by DialogTheme.actionsLayout, whose default comes from the skin: Minimal, Material and Fluent end-aligned side by side; Cupertino side by side, stacked vertically when a label doesn't fit half the width; Carbon a full-width row with equal halves. The contract stays the same.
More than two actions, or custom layoutPut them in content: the developer owns that layout.
A hero icon above the title (Material only)Not in core (ADR-23). Put an icon at the top of content, or a future Material skin can offer it as a DialogTheme field.
Changed in the M6 build (2026-10-28)
  • DialogTheme gains actionGap, sectionGap (between the title, message, content and actions) and closeIcon.
  • The frame sizes the dialog from the space it's given (the window): at most maxWidth, 48 narrower than that space and never negative, 90% of its height.
  • Fluent's dialog sits at shadow64 (Level5), so with the Acrylic surface it's frosted glass.

Implementation​

1. Why​

CamoDialog is the content of a dialog. In Compose, a dialog is a Navigation 3 entry registered with CamoDialogSceneStrategy.dialog() metadata, drawn inside core's CamoDialogFrame (Overlays). This note covers the content component and the frame's dialog layout.

2. Shape​

3. API​

@Composable
public fun CamoDialog(
message: String,
confirm: @Composable () -> Unit,
modifier: Modifier = Modifier,
title: String? = null,
dismiss: (@Composable () -> Unit)? = null,
content: (@Composable ColumnScope.() -> Unit)? = null,
)

A dialog as a registered route, in its own file:

@Serializable data object SortOrderPicker : NavKey

fun EntryProviderScope<NavKey>.sortOrderDialog(backStack: NavBackStack<NavKey>, results: CamoNavResults) =
entry<SortOrderPicker>(metadata = CamoDialogSceneStrategy.dialog()) {
var selected by rememberSaveable { mutableStateOf(SortOrder.Newest) }
CamoDialog(
title = "Sort by", message = "Choose how items are ordered.",
confirm = { CamoButton(text = "Apply", onClick = { results.set(SortOrderPicker, selected); backStack.removeLastOrNull() }) },
dismiss = { CamoButton(text = "Cancel", appearance = Appearance.Ghost, onClick = { backStack.removeLastOrNull() }) },
) { SortOrder.entries.forEach { SortRow(it, it == selected) { selected = it } } }
}
  • Semantics: paneTitle = title ?: message on the container.
  • Long content: the message + content are in a Column(Modifier.weight(1f, fill = false).verticalScroll(...)). The title and actions stay outside it.

Layout choices (ADR-28): the renderer reads style.titleAlign (Start | Center) and style.actionsLayout:

  • End / Center: a Row(horizontalArrangement = Arrangement.End / Center, spacedBy(spacing.s)) with dismiss before confirm;
  • FullWidthRow: a Row with each action in Modifier.weight(1f);
  • Stacked: a Column with confirm first, each fillMaxWidth().

style.showCloseButton adds a CamoIconButton(contentDescription = "Close") at the top end, shown only when state.dismissible; it calls state.onDismissRequest, which goes through the frame's veto (OnDismissRequest).

4. Build steps​

  1. The dialog layout inside CamoDialogFrame (centering, width and height limits).
  2. CamoDialog, DialogTheme/Style, and the DebugSkin renderer.
  3. The samples: DeleteItem (Boolean result, tone = Error) and SortOrderPicker (radio content), both registered entries. Plus one standalone CamoDialogFrame usage.
  4. commonTest with a real NavDisplay:
    • results arrive once;
    • a scrim click and Esc pop the entry;
    • OnDismissRequest { false } keeps it;
    • focus is on the first action after open, and back on the opener after close.

Done when

  • Both sample dialogs work as routes on all four targets, and deliver their results.

5. Edge cases​

CaseDecided behavior
Replaced designsEarlier drafts used androidx.compose.ui.window.Dialog (with Android dim clearing), then a custom show host. Both were replaced by core frames + Navigation 3 scenes (ADR-19).
Dialog from a sheetStacked entries. Back pops the dialog first.
Very small windowsWidth is min(style.maxWidth, window − 48 dp).
Changed in the M6 build (2026-10-28)
  • The renderer gets the semantics (paneTitle, the dismiss action) as modifier; the message and content scroll in a Column(Modifier.weight(1f, fill = false).verticalScroll(…)).