NutrientFloatingContextualToolbar

fun NutrientFloatingContextualToolbar(coordinator: ToolbarCoordinator, modifier: Modifier = Modifier, state: FloatingToolbarState = rememberFloatingToolbarState(initialEdge = FloatingToolbarEdge.Top), vibrant: Boolean = true, draggable: Boolean = true, defaultGroupingProvider: ContextualToolbarGroupingProvider? = null, windowInsets: WindowInsets = WindowInsets.safeDrawing)

A Material 3 Expressive floating pill rendering of the contextual (special-mode) toolbars — the annotation creation, document editing and content editing bars — over a ToolbarCoordinator. The floating counterpart of NutrientContextualToolbar, and the companion of NutrientFloatingToolbar: both pills share one frame, so they dock against the same window edges, drag and fling identically, run on the same expressive spring motion, and paint the same Material 3 floating-toolbar color roles (vibrant picks primaryContainer, otherwise surfaceContainer).

The pill renders the coordinator's contextualToolbar state slice and paints nothing while it is null; the mode's binder keeps driving that state, so tools activate, groups regroup, and the undo/redo state updates exactly as they do in the docked bar. Items are grouped with the same presets as the docked bar (ToolbarCoordinator.setContextualToolbarGroupingProvider, the host's defaultGroupingProvider, or the built-in presets), sized to what fits along the pill. The layout along the main axis follows the docked bar's order: the drag handle, then with ContextualToolbarState.usesBackButtonWhenHorizontal on the close button leading the grouped items (a back arrow while the pill is horizontal, a circled X when vertical), or with it off a circled X trailing them; anything that does not fit demotes into a trailing "more" menu. A hidden item keeps its slot, like the docked bar, so the pill does not reflow when it returns.

The pill docks only where the bar allows: ContextualToolbarState.allowedPositions narrows the state's edges (a top-only bar such as content editing pins the pill to the top and hides the handle), and a pill left at an edge the current bar forbids moves to one it permits.

Group semantics follow the docked bar: tapping a tool group activates the tool the group's icon shows (the selected child, else the most recently used one); long-pressing it opens the group's children in a Material 3 dropdown, as does tapping a pure container group such as "More". Every action reaches the coordinator stamped with the bar's kind (see ToolbarAction.ItemClicked.kind), and the close button dispatches R.id.pspdf__toolbar_close_button like the docked bar.

A host uses this together with PdfActivityConfiguration.Builder.defaultContextualToolbarEnabled(false), so the SDK does not also mount the docked bar, and overlays it on the document like NutrientFloatingToolbar. The state is independent from the main pill's, so each remembers its own docked edge.