Nutrient Contextual Toolbar
State-driven contextual (special-mode) toolbar — the one generic composable behind the annotation, document-editing, and content-editing bars. Renders coordinator's contextualToolbar state slice; nothing is painted while that flow is null.
The API follows NutrientMainToolbar's: a closeButton slot in a NutrientContextualToolbarScope (whose dispatch stamps actions with this bar's kind, the way the bar's own items do) and one flat parameter each for the chrome — shape and border for the top-docked strip, sideDockedShape and sideDockedBorder for a bar docked to a side, shadowElevation, windowInsets, colors — and the enter/exit animation, every one defaulting to NutrientContextualToolbarDefaults. The items themselves are the coordinator's (ToolbarCoordinator.updateContextualItems, ToolbarCoordinator.setContextualToolbarGroupingProvider), grouped and rendered by the bar, so there is no items slot to lose the submenus through.
NutrientContextualToolbar(
coordinator,
shape = RoundedCornerShape(28.dp),
sideDockedShape = RoundedCornerShape(28.dp),
shadowElevation = 8.dp,
colors = NutrientContextualToolbarDefaults.colors().copy(backgroundColor = MaterialTheme.colorScheme.primaryContainer),
)colors are provided to everything inside the bar, so the SDK's buttons, the submenu sheet and a host's own closeButton (UiTheme.colors.mainToolbar.iconColor) read the same scheme; so is itemIndication, the shape and ripple color of every item's pressed, hovered and selected states (see ToolbarItemIndication). windowInsets are reserved inside the bar's surface, so its background bleeds behind them; the default is none, because NutrientToolbarScaffold and the SDK's own mount place the bar inside the insets already.
Width. Like NutrientMainToolbar, a top-docked bar is as wide as its items unless given a width: Modifier.fillMaxWidth() is the edge-to-edge strip the SDK mounts pass, no modifier a pill in a corner. A side-docked bar is always NutrientContextualToolbarDefaults.ToolbarSize thick and as tall as its items.
Layout follows ContextualToolbarState.position: a horizontal Row when docked ToolbarPosition.Top, a vertical Column when docked ToolbarPosition.Start / ToolbarPosition.End. Structure along the main axis: close button, grouped menu items, then the drag handle. Item capacity is computed from the available main-axis extent (48dp uniform items, matching the View bar's math) and fed through ContextualToolbarGroupingResolver — customer grouping via ToolbarCoordinator.setContextualToolbarGroupingProvider (or the deprecated MenuItemGroupingRule bridge), host defaults via defaultGroupingProvider, built-in presets otherwise.
Click routing: menu items dispatch ToolbarAction.ItemClicked; long-pressing a submenu group slides out an attached SubmenuSheet (the View ContextualToolbarSubMenu look and choreography) whose children dispatch ToolbarAction.SubmenuChildClicked; the close button dispatches ToolbarAction.ItemClicked with R.id.pspdf__toolbar_close_button.
Every button that does not own a submenu — the plain bar items, the close button and the items inside an open sheet — names itself with a Material 3 tooltip on long press instead (the View bars' TooltipCompat affordance; see ToolbarTooltipBox).
The composable's footprint includes a 58dp submenu strip on the document side of the bar (below a top-docked bar, beside a side-docked one) — the same space ToolbarCoordinatorLayout budgets for the View bar's submenus in its slot.