NutrientFloatingToolbar

fun NutrientFloatingToolbar(coordinator: ToolbarCoordinator, modifier: Modifier = Modifier, state: FloatingToolbarState = rememberFloatingToolbarState(), vibrant: Boolean = true, draggable: Boolean = true, collapsible: Boolean = false, windowInsets: WindowInsets = WindowInsets.safeDrawing)

A Material 3 Expressive floating toolbar rendering of a ToolbarCoordinator.

Like NutrientMainToolbar this is a pure renderer over the coordinator's state: it paints items (visible items inline, overflow items behind a "more" menu), honors frame.isVisible, and emits ToolbarActions via coordinator.dispatch(…). Unlike the main toolbar it is a free-floating pill that can dock against any of the four window edges, laying its items out horizontally when docked top/bottom and vertically when docked start/end.

Dragging. When draggable is true the pill carries a drag handle; releasing a drag docks the pill (with a spatial spring) against the edge whose dock zone contains the drag handle — i.e. the finger, so wherever the user is touching decides, regardless of where the pill body extends: the outer 20% of the window's long axis belongs to the two short-axis edges — top/bottom in portrait, start/end in landscape — and the middle strip is halved between the other two edges. A fling instead throws the pill to the allowed edge the gesture points at (the settle spring inherits the throw velocity, so the pill keeps flying instead of stopping dead). While the drag is in flight the pill previews the zone under it live — crossing from the bottom zone into a side zone reflows the pill from horizontal to vertical mid-drag, with the drag handle as the epicenter: the handle stays pinned under the finger while the rest of the pill transforms around it (see FloatingToolbarState.previewedEdge). Restricting allowedEdges to a single edge pins the toolbar there (the handle is hidden), mirroring the legacy ToolbarCoordinatorLayout contract where one allowed position disables dragging.

Motion. All animations run on the Material 3 expressive motion scheme's spring tokens (see ExpressiveMotion): show/hide slides out of the docked edge with a spatial spring plus an effects-spec fade, the horizontal↔vertical flip is a single spring-driven reflow in which the container size and every item's slot interpolate together (see FlippingToolbarLayout), the drag release settles with the default spatial spring, and buttons scale down on press with the fast spatial spring.

Color. The container and buttons follow the Material 3 floating-toolbar roles: the vibrant variant (vibrant = true) paints primaryContainer with vibrant icon-button colors, the standard variant surfaceContainer. Icons are tinted by these roles — any tint baked into a ToolbarIcon.Resource/ToolbarIcon.Vector is deliberately ignored so the pill stays strictly on-scheme; ToolbarIcon.Composed content renders as-is.

Inline search. Like NutrientMainToolbar, it honors the coordinator's ToolbarCoordinator.searchSession: while a session is active the pill hides and a full-width search pill springs in at the top edge, themed from the ambient Material 3 color scheme.

Collapsing. With collapsible = true the pill has two sizes: tapping any item in the expanded menu dispatches it, remembers it as the active item, and collapses the pill down to just that one button; tapping the collapsed button expands the full menu again (nothing is dispatched). The collapse/expand runs through the same spring size transform as the orientation flip. Programmatic control via FloatingToolbarState.expand / FloatingToolbarState.collapse / FloatingToolbarState.activeItemId.

Place it as an overlay filling the document area (e.g. the last child of a Box); it positions the pill within itself and keeps it inside windowInsets.