Nutrient Tab Bar
A tab bar for the documents of a DocumentCoordinator, one tab per document.
The bar mirrors the coordinator: documents become tabs, the visible document is the selected tab, and tapping, closing or dragging a tab is forwarded back to the coordinator. Use it with a com.pspdfkit.jetpack.compose.views.DocumentView by collecting com.pspdfkit.jetpack.compose.interactors.DocumentState.documentCoordinator, and hide the SDK's own tab bar with com.pspdfkit.configuration.activity.TabBarHidingMode.HIDE:
val coordinator by documentState.documentCoordinator.collectAsState()
Box {
DocumentView(documentState, Modifier.fillMaxSize())
coordinator?.let {
NutrientTabBar(documentCoordinator = it, tabShape = RoundedCornerShape(28.dp), tabSpacing = 8.dp)
}
}A tap or a close updates the tabs at once so the bar can animate; the coordinator call that swaps the document follows NutrientTabBarDefaults.AnimationDurationMillis later, because replacing the document blocks the main thread long enough to freeze a running tab animation.
Parameters
The coordinator whose documents the bar shows.
The Modifier for the bar.
Which tabs show a close button.
The bar's colors, UiColorScheme.tabBar by default.
The bar's dimensions, see NutrientTabBarDefaults.dimensions.
Shape every tab is clipped to.
Gap between neighbouring tabs. A non-zero gap replaces the separator between touching tabs.
Padding around the row of tabs, inside the bar's background.
Window insets the bar's background extends into while its tabs stay clear of them, see NutrientTabBarDefaults.windowInsets.
State of the scrolling row, for callers that want to scroll it themselves.
What to draw inside every tab, NutrientTabBarDefaults.TabContent by default.
A horizontal row of tabs driven by the caller's own state.
The tabs share the available width equally and never get narrower than NutrientTabBarDimensions.tabMinWidth plus the close button; once they no longer fit, the row scrolls. The selected tab is filled with TabBarColors.selectedTabColor. Touching tabs (a zero tabSpacing) show a thin separator in the same color at their end edge; spaced tabs don't.
A long press picks a tab up for reordering when onTabMove is set. It is called live for every position change during the drag and returns whether the caller applied the move, the contract ItemTouchHelper.Callback.onMove had.
Parameters
Tabs in display order. Each NutrientTabBarTab.id must be unique.
Id of the selected tab, or null for none. It is scrolled into view whenever it changes.
Called when an unselected tab is tapped.
Called when a tab's close button is tapped, or its content calls NutrientTabBarTabScope.closeTab.
The Modifier for the bar.
Which tabs show a close button.
The bar's colors, UiColorScheme.tabBar by default.
The bar's dimensions, see NutrientTabBarDefaults.dimensions.
Shape every tab is clipped to.
Gap between neighbouring tabs.
Padding around the row of tabs, inside the bar's background.
Window insets the bar's background extends into while its tabs stay clear of them, see NutrientTabBarDefaults.windowInsets.
Applies a live reorder from one index to another; null disables drag-reorder.
State of the scrolling row, for callers that want to scroll it themselves.
What to draw inside every tab, NutrientTabBarDefaults.TabContent by default.