androidx.compose.material3.adaptive.layout

SupportingPaneScaffoldExperimental

Composable function · from org.jetbrains.compose.material3.adaptive:adaptive-layout:1.3.0

A supporting pane layout shows your main content, and a smaller pane with related content next to it. Think of a recipe with "similar recipes", or a document with comments.

A main pane with a supporting pane next to it
A main pane with a supporting pane next to it
// In an app, call it without arguments: it reads the window size itself.
val navigator = rememberSupportingPaneScaffoldNavigator(
    scaffoldDirective = calculatePaneScaffoldDirective(
        WindowAdaptiveInfo(WindowSizeClass.BREAKPOINTS_V2.computeWindowSizeClass(widthDp = 840, heightDp = 480), Posture()),
    ),
)
Box(Modifier.size(840.dp, 260.dp)) {
    SupportingPaneScaffold(
        directive = navigator.scaffoldDirective,
        scaffoldState = navigator.scaffoldState,
        mainPane = {
            AnimatedPane {
                Column(Modifier.fillMaxSize().padding(16.dp)) {
                    Text("Pasta with tomatoes", style = MaterialTheme.typography.headlineSmall)
                    Text("Boil the pasta. Fry garlic in olive oil, add the tomatoes and cook for 10 minutes.")
                }
            }
        },
        supportingPane = {
            AnimatedPane {
                Column(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surfaceContainerLow).padding(16.dp)) {
                    Text("Similar recipes", style = MaterialTheme.typography.titleMedium)
                    Text("Pesto pasta")
                    Text("Tomato soup")
                }
            }
        },
    )
}

It works like the list-detail layout: create a navigator with rememberSupportingPaneScaffoldNavigator, pass its scaffoldDirective and scaffoldState, and wrap each pane in AnimatedPane.

Use a list-detail layout when the user picks one item from many. Use a supporting pane when the main content is always there and the side pane adds to it.

With a valueExperimental

You say which panes show. For full control or tests.

@Composable
fun SupportingPaneScaffold(
    directive: PaneScaffoldDirective,
    value: ThreePaneScaffoldValue,
    mainPane: @Composable ThreePaneScaffoldPaneScope.() -> Unit,
    supportingPane: @Composable ThreePaneScaffoldPaneScope.() -> Unit,
    modifier: Modifier = Modifier,
    extraPane: (@Composable ThreePaneScaffoldPaneScope.() -> Unit)? = null,
    paneExpansionDragHandle: (@Composable ThreePaneScaffoldScope.(PaneExpansionState) -> Unit)? = null,
    paneExpansionState: PaneExpansionState? = null,
)

directive: PaneScaffoldDirectiveRequired

How many panes fit and how much space goes between them. Pass navigator.scaffoldDirective.

value: ThreePaneScaffoldValueRequired

Which panes show and which are hidden, as a fixed value. Usually you pass scaffoldState instead.

mainPane: @Composable ThreePaneScaffoldPaneScope.() -> UnitRequired

The main content. Wrap it in AnimatedPane { }.

supportingPane: @Composable ThreePaneScaffoldPaneScope.() -> UnitRequired

The related content. Wrap it in AnimatedPane { }.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. See the Modifier guide.

extraPane: (@Composable ThreePaneScaffoldPaneScope.() -> Unit)?Optional

Default: null

An optional third pane. It shows on very wide windows, and replaces the supporting pane on smaller ones.

paneExpansionDragHandle: (@Composable ThreePaneScaffoldScope.(PaneExpansionState) -> Unit)?OptionalSince 1.1

Default: null

A handle between the panes that the user drags to change their widths.

paneExpansionState: PaneExpansionState?OptionalSince 1.1

Default: null

Remembers where the user dragged the handle. Create it with rememberPaneExpansionState.

With a stateExperimental

Animates between layouts. Use this with a navigator.

@Composable
fun SupportingPaneScaffold(
    directive: PaneScaffoldDirective,
    scaffoldState: ThreePaneScaffoldState,
    mainPane: @Composable ThreePaneScaffoldPaneScope.() -> Unit,
    supportingPane: @Composable ThreePaneScaffoldPaneScope.() -> Unit,
    modifier: Modifier = Modifier,
    extraPane: (@Composable ThreePaneScaffoldPaneScope.() -> Unit)? = null,
    paneExpansionDragHandle: (@Composable ThreePaneScaffoldScope.(PaneExpansionState) -> Unit)? = null,
    paneExpansionState: PaneExpansionState? = null,
)

scaffoldState: ThreePaneScaffoldStateRequiredSince 1.1

Which panes show, with animations between changes. Pass navigator.scaffoldState.

Same as above: directive, mainPane, supportingPane, modifier, extraPane, paneExpansionDragHandle, paneExpansionState.

See also