ComposeParallaxToolbarLayout

fun ComposeParallaxToolbarLayout(titleContent: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit, headerContent: @Composable ParallaxToolbarScope.() -> Unit, content: ParallaxContent, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), subtitleContent: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit? = null, navigationIcon: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit? = null, actions: @Composable ParallaxActionsScope.(collapsed: Boolean) -> Unit? = null, overlayContent: @Composable ParallaxToolbarScope.() -> Unit? = null, bottomContent: @Composable ParallaxToolbarScope.() -> Unit? = null, onStretchTrigger: () -> Unit? = null, headerConfig: ParallaxHeaderConfig = ParallaxToolbarDefaults.headerConfig(), toolbarConfig: ParallaxToolbarConfig = ParallaxToolbarDefaults.toolbarConfig(), titleConfig: ParallaxTitleConfig = ParallaxToolbarDefaults.titleConfig(), bodyConfig: ParallaxBodyConfig = ParallaxToolbarDefaults.bodyConfig(), semanticsConfig: ParallaxSemanticsConfig = ParallaxToolbarDefaults.semanticsConfig(), windowInsets: WindowInsets = ParallaxToolbarDefaults.windowInsets, collapseEnabled: Boolean = true, state: ParallaxToolbarState = rememberParallaxToolbarState())(source)

A collapsing toolbar with a parallax header for Compose Multiplatform.

The header collapses as content scrolls; the title glides into the toolbar and the toolbar background animates to its target color. Every slot receives true once collapsed so it can adapt colors or content.

Parameters

titleContent

Title, positioned by the layout.

headerContent

Content shown in the expanded header, e.g. an image.

content
contentPadding

Padding applied to the body, typically the Scaffold padding.

subtitleContent

Optional subtitle under the title.

navigationIcon

Optional leading toolbar slot.

actions

Optional trailing toolbar slot.

overlayContent

Optional layer drawn above the body and the toolbar, the size of the whole layout. Use it with ParallaxToolbarScope.moveBetween for elements that travel from the header into the toolbar, such as an avatar.

bottomContent

Optional row pinned under the toolbar, such as tabs or a search field. It rides the header's bottom edge while expanded and stays below the toolbar once collapsed. Give it a background; the body scrolls underneath it.

onStretchTrigger

Called when a stretch is released past ParallaxHeaderConfig.stretchTriggerDistance; requires stretchEnabled. Typical use is pull-to-refresh.

semanticsConfig

Strings announced to accessibility services; see ParallaxSemanticsConfig. The layout exposes its state and expand/collapse actions, reads the toolbar before the header and body, marks the title as a heading, and hides the covered header or an exited toolbar from screen readers.

collapseEnabled

Whether scrolling and dragging move the header. When false the header stays where it is and only ParallaxToolbarState.collapse and ParallaxToolbarState.expand move it; the body still scrolls. For a locked state such as loading or editing.

windowInsets

Insets the toolbar and body are pushed inside of. The top inset sits above the toolbar and under the header; the horizontal insets keep the navigation icon, actions and title clear of display cutouts. Defaults to the status bar plus the cutout, the same as Material's top app bar. Pass WindowInsets(0) when the layout does not touch the window edge, for example inside a dialog, a bottom sheet or a split pane.

state

Hoisted state to observe the collapse fraction or expand and collapse programmatically. It also owns the scroll states of both content kinds, unless ParallaxContent.Lazy carries its own list state.

Example with a customized LazyColumn:

ComposeParallaxToolbarLayout(
titleContent = { collapsed -> Text("Title") },
headerContent = { Image(...) },
content = ParallaxContent.Lazy(
content = { collapsed -> items(100) { Text("Row $it") } },
config = ParallaxToolbarDefaults.lazyColumnConfig(
contentPadding = PaddingValues(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
)
)
)

fun ComposeParallaxToolbarLayout(titleContent: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit, headerContent: @Composable ParallaxToolbarScope.() -> Unit, content: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), subtitleContent: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit? = null, navigationIcon: @Composable ParallaxToolbarScope.(collapsed: Boolean) -> Unit? = null, actions: @Composable ParallaxActionsScope.(collapsed: Boolean) -> Unit? = null, overlayContent: @Composable ParallaxToolbarScope.() -> Unit? = null, bottomContent: @Composable ParallaxToolbarScope.() -> Unit? = null, onStretchTrigger: () -> Unit? = null, headerConfig: ParallaxHeaderConfig = ParallaxToolbarDefaults.headerConfig(), toolbarConfig: ParallaxToolbarConfig = ParallaxToolbarDefaults.toolbarConfig(), titleConfig: ParallaxTitleConfig = ParallaxToolbarDefaults.titleConfig(), bodyConfig: ParallaxBodyConfig = ParallaxToolbarDefaults.bodyConfig(), scroll: ScrollState = rememberScrollState(), lazyContent: LazyListScope.(Boolean) -> Unit? = null, lazyListState: LazyListState = rememberLazyListState(), lazyColumnConfig: LazyColumnConfig = LazyColumnConfig())(source)

Deprecated

Use the overload that takes ParallaxContent.

Replace with

ComposeParallaxToolbarLayout(titleContent, headerContent, ParallaxContent.Regular(content), modifier, contentPadding, subtitleContent, navigationIcon, actions, headerConfig, toolbarConfig, titleConfig, bodyConfig, rememberParallaxToolbarState(scroll, lazyListState))

The 1.x entry point, kept so existing call sites compile. It wraps content or lazyContent into a ParallaxContent and scroll into a ParallaxToolbarState, then delegates to the main overload. It will be removed in 3.0.