NutrientMainToolbar

fun NutrientMainToolbar(coordinator: ToolbarCoordinator, modifier: Modifier = Modifier, navigationIcon: @Composable () -> Unit = { NutrientMainToolbarNavigationIcon(coordinator) }, title: @Composable NutrientToolbarScope.() -> Unit = { NutrientMainToolbarTitle(coordinator) }, actions: @Composable NutrientToolbarScope.() -> Unit = { NutrientToolbarItems(coordinator, Modifier.weight(1f)) }, searchBar: @Composable NutrientToolbarScope.() -> Unit = { NutrientToolbarSearchBar(coordinator, Modifier.fillMaxWidth()) }, shape: Shape = NutrientMainToolbarDefaults.Shape, shadowElevation: Dp = NutrientMainToolbarDefaults.shadowElevation, windowInsets: WindowInsets = NutrientMainToolbarDefaults.windowInsets(coordinator), colors: MainToolbarColors = NutrientMainToolbarDefaults.colors(), itemIndication: ToolbarItemIndication = NutrientMainToolbarDefaults.ItemIndication, enter: EnterTransition = NutrientMainToolbarDefaults.enterTransition, exit: ExitTransition = NutrientMainToolbarDefaults.exitTransition)

State-driven main toolbar. Renders coordinator's frame and items, emits ToolbarActions via coordinator.dispatch(…).

This is the single composable that paints the top toolbar in all three hosts (PdfActivity, PdfFragment, standalone). The lifecycle binding differs by host; the rendering does not.

The shape is Material 3's TopAppBar: three slots along the bar — navigationIcon, title and actions — and one flat parameter each for the shape, shadowElevation, windowInsets, colors and show/hide animation, every one defaulting to NutrientMainToolbarDefaults. The slots default to the SDK's own pieces, which are public composables (NutrientMainToolbarNavigationIcon, NutrientMainToolbarTitle, NutrientToolbarItems), so a host adds a back button, drops the title, or restyles the bar without giving up the coordinator's items:

NutrientMainToolbar(
coordinator,
Modifier.fillMaxWidth(),
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, null) } },
title = {},
colors = NutrientMainToolbarDefaults.colors().copy(backgroundColor = MaterialTheme.colorScheme.primaryContainer),
)

The default navigationIcon is the icon the coordinator's frame carries (com.pspdfkit.compose.toolbar.state.ToolbarFrame.navigationIcon, set through ToolbarCoordinator.setMainToolbarNavigationIcon or PdfUi.setToolbarNavigationIcon), and nothing when the frame has none — so a PdfUiFragment host gets a back arrow without composing anything. Composing the slot yourself replaces that.

searchBar replaces the three slots while inline search is open. Its default is the SDK search bar filling the width, so the swap happens whatever the slots hold; size it yourself (Modifier.width(280.dp)) or keep the navigation icon next to it by composing the slot. For a bar that is not "navigation, title, actions" at all, the overload taking one content lambda lays out whatever it is given.

Width. The toolbar is as wide as its content, the way Row is, and a caller's width modifier wins: Modifier.fillMaxWidth() is the full-bleed bar (what the SDK's own mount passes), Modifier.width(240.dp) a fixed one, no modifier a floating pill exactly as wide as its icons. A slot that fills the width (Modifier.fillMaxWidth()) grows a wrapping toolbar to the width it was offered, which is how the default searchBar widens a pill while search is open and lets it collapse again afterwards. The toolbar animates that change itself; do not add Modifier.animateContentSize(), which clips to the toolbar's bounds and cuts its shadow off.

title, actions and searchBar are in a NutrientToolbarScope, whose weight() and align() modifiers work like RowScope's: the default actions carry Modifier.weight(1f) so trailing items pin to the far edge of a full-bleed bar.

modifier is applied to the toolbar's outermost node — the show/hide visibility animation — so everything positional works from the call site: BoxScope.align and RowScope.weight (parent data, which reaches your layout only from there), padding, windowInsetsPadding, onSizeChanged. It does not survive the hidden state: the whole subtree is removed once the toolbar has animated away, so a modifier that must reserve layout space while the toolbar is hidden belongs on a container you place around this composable.

shape, shadowElevation and windowInsets are drawn inside the visibility animation, as a Material Surface around the bar (the document title overlay below it keeps its own surface): a pill drawn this way slides and fades away with the toolbar, where a background in the modifier chain would sit still while the bar leaves from under it — and, like every other Nutrient bar, a tap that lands on the toolbar and misses every button stops there instead of reaching the document underneath. colors are provided to everything inside the bar, so the SDK's pieces and your own slots (UiTheme.colors.mainToolbar.iconColor on a navigation icon) read the same scheme — and so is itemIndication, the shape and ripple color every item shows its pressed, hovered and selected states with (see ToolbarItemIndication).


fun NutrientMainToolbar(coordinator: ToolbarCoordinator, modifier: Modifier = Modifier, shape: Shape = NutrientMainToolbarDefaults.Shape, shadowElevation: Dp = NutrientMainToolbarDefaults.shadowElevation, windowInsets: WindowInsets = NutrientMainToolbarDefaults.windowInsets(coordinator), colors: MainToolbarColors = NutrientMainToolbarDefaults.colors(), itemIndication: ToolbarItemIndication = NutrientMainToolbarDefaults.ItemIndication, enter: EnterTransition = NutrientMainToolbarDefaults.enterTransition, exit: ExitTransition = NutrientMainToolbarDefaults.exitTransition, searchBar: @Composable NutrientToolbarScope.() -> Unit = { NutrientToolbarSearchBar(coordinator, Modifier.fillMaxWidth()) }, content: @Composable NutrientToolbarScope.() -> Unit)

NutrientMainToolbar with one content slot in place of the navigation-icon / title / actions three, for a bar that does not fit that shape: the pieces are laid out in a row exactly as composed, sized by what each asked for through NutrientToolbarScope (weight(), align()) or a standard modifier. The SDK's pieces are public, so "my own content" never means giving up the coordinator's items:

NutrientMainToolbar(coordinator, Modifier.align(Alignment.TopEnd)) {
NutrientToolbarItems(coordinator, Modifier.weight(1f))
NutrientMainToolbarTitle(coordinator)
}

searchBar still replaces content while inline search is open. Everything else — width, the flat chrome parameters, modifier's placement, colors reaching the slots — is as documented on the slot overload.