
Draggable layered layouts with collapsible headers and expandable bottom content; seekable animations that track the finger, content-measured sizes, insets-aware, state-restoring gestures, compare slider and animated lists.
Draggable, layered layouts for Compose Multiplatform.
Collapsible headers and expandable bottom content whose animations follow your finger.
![]() |
![]() |
![]() |
![]() |
CollapsibleHeaderContainer |
ExpandableContent |
CompareSlider |
AnimatedColumn |
animateEnterExit, sharedElement and sharedBounds move exactly with the finger.PaddingValues.| Component | What it does |
|---|---|
CollapsibleHeaderContainer |
A header above the content that collapses with scrolling and switches between an expanded and a collapsed header. |
AnimatableCollapsibleHeaderContainer |
The same container, with a transition between both headers that follows the drag. |
ExpandableContent |
A bottom layout that is dragged from a compact bar into a full screen, like a mini player. |
CompareSlider |
Two layouts side by side that are compared by dragging a slider between them, like a before and after image. |
SwipeToConfirm |
A thumb that is slid to the end of a track to confirm an action that must not happen by accident. |
AnimatedColumn |
A column that animates its items to their new position when the list is sorted, filtered or changed, and fades items in and out. |
The collapsible headers and ExpandableContent settle in one of the two DraggableLayoutStates:
Collapsed or Expanded. CompareSlider stays wherever it is dropped.
Strata is published to Maven Central. Add the artifacts you need to the common source set of your shared module:
// build.gradle.kts of your shared module
kotlin {
sourceSets {
commonMain.dependencies {
// CollapsibleHeaderContainer, AnimatableCollapsibleHeaderContainer, ExpandableContent,
// CompareSlider, SwipeToConfirm
implementation("dev.leonp.strata:gesture-draggable:0.2.1")
// AnimatedColumn
implementation("dev.leonp.strata:layout-animated:0.2.1")
}
}
}The header collapses before the content scrolls and expands again once the content reached its
start. Apply the PaddingValues handed to each slot, they contain the window insets.
CollapsibleHeaderContainer(
expandedHeader = { padding ->
Text(
text = "Expanded header",
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.primaryContainer)
.padding(padding)
.padding(24.dp),
)
},
collapsedHeader = { padding ->
Text(
text = "Collapsed header",
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.primaryContainer)
.padding(padding)
.padding(16.dp),
)
},
) { padding ->
LazyColumn(contentPadding = padding) {
items(50) { index -> Text("Item $index", Modifier.padding(16.dp)) }
}
}Leave out collapsedHeader to let the header collapse down to the top insets, and pass
insets = WindowInsets(0, 0, 0, 0) when a parent, such as a Scaffold, already handles them.
AnimatableCollapsibleHeaderContainer runs a transition between both headers. Its header slots
are an AnimatableCollapsibleHeaderScope, so shared elements and enter and exit animations work
directly:
SharedTransitionLayout {
AnimatableCollapsibleHeaderContainer(
expandedHeader = { padding ->
Column(Modifier.fillMaxWidth().padding(padding).padding(24.dp)) {
Text(
text = "Strata",
style = MaterialTheme.typography.displaySmall,
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState("title"),
animatedVisibilityScope = this@AnimatableCollapsibleHeaderContainer,
),
)
Text(
text = "Scroll to collapse",
modifier = Modifier.animateEnterExit(
enter = fadeIn(tween(400, delayMillis = 600, easing = LinearEasing)),
exit = fadeOut(tween(400, easing = LinearEasing)),
),
)
}
},
collapsedHeader = { padding ->
Text(
text = "Strata",
style = MaterialTheme.typography.titleLarge,
modifier = Modifier
.padding(padding)
.padding(16.dp)
.sharedBounds(
sharedContentState = rememberSharedContentState("title"),
animatedVisibilityScope = this@AnimatableCollapsibleHeaderContainer,
),
)
},
) { padding ->
LazyColumn(contentPadding = padding) { /* … */ }
}
}Place ExpandableContent at the bottom of a full size parent, so it grows upwards. The content
lambda receives the state to show and runs in an ExpandableContentScope:
SharedTransitionLayout {
Box(Modifier.fillMaxSize()) {
ScreenContent()
ExpandableContent(
modifier = Modifier
.align(Alignment.BottomCenter)
// The background belongs to the layout, so it grows with the drag right away.
.background(MaterialTheme.colorScheme.surfaceContainerHigh),
) { layoutState ->
when (layoutState) {
DraggableLayoutState.Collapsed -> MiniPlayer(
modifier = Modifier.windowInsetsPadding(WindowInsets.navigationBars),
)
DraggableLayoutState.Expanded -> FullPlayer(
modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars),
)
}
}
}
}Inside MiniPlayer and FullPlayer, give elements that exist in both states the same
rememberSharedContentState key, and fade everything else with animateEnterExit.
To expand or collapse the layout from code, for example when a button is tapped, hoist the state
and call its suspending expand() and collapse(). They animate the layout like a settling drag
and are cancelled when a drag or another call interrupts them:
val state = rememberExpandableContentState()
val scope = rememberCoroutineScope()
ExpandableContent(state = state) { /* … */ }
Button(onClick = { scope.launch { state.expand() } }) { Text("Open player") }CompareSlider shows before left of a slider and after right of it. Drag the thumb to reveal
more of one side. Give the layout a size, it fills the constraints it gets:
CompareSlider(
before = { Image(painter = originalPainter, contentDescription = "Before", ...) },
after = { Image(painter = editedPainter, contentDescription = "After", ...) },
thumb = { SliderThumb() },
modifier = Modifier
.fillMaxWidth()
.aspectRatio(3f / 4f)
.clip(RoundedCornerShape(28.dp)),
sliderThickness = 2.dp,
sliderColor = Color.White,
)Both slots are measured at the full size of the layout and only clipped at the slider, so they are never scaled or squeezed. Elements inside a slot, such as a label in a corner, stay where they are while the slider moves. The slider starts in the middle, and its position survives configuration changes and process death.
SwipeToConfirm confirms an action once the thumb was dragged far enough along the track. The
thumb is as high as the track, so give the track a height and the thumb an aspect ratio. A thumb
that is released before confirmationThreshold snaps back, however fast it was released:
val state = rememberSwipeToConfirmState()
SwipeToConfirm(
thumb = { PayThumb(modifier = Modifier.aspectRatio(1f)) },
modifier = Modifier
.fillMaxWidth()
.height(64.dp),
state = state,
onConfirm = { pay() },
confirmationThreshold = 0.7f,
colors = SwipeToConfirmDefaults.colors(
backgroundColor = MaterialTheme.colorScheme.secondaryContainer,
progressColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f),
),
) {
Text(
text = "Slide to pay",
modifier = Modifier
.align(Alignment.Center)
.alpha(1f - state.progress),
)
}state.progress goes from 0f to 1f and drives the label. A confirmed track does not accept
drags, call state.reset() to use it again. Without colors, the track draws neither a background
nor a fill.
Transitions are seeked by the drag position instead of played over time. Seeking maps the drag progress linearly onto the total duration of the transition, so durations and delays define where in the drag an animation runs:
// Total duration: 1000 ms. This fades in during the last 20 % of the drag.
fadeIn(tween(durationMillis = 200, delayMillis = 800, easing = LinearEasing))
// And this fades out during the first 20 %.
fadeOut(tween(durationMillis = 200, easing = LinearEasing))A few tips:
tween specs on one shared timeline. The duration of a spring is only estimated and
silently changes the total duration.tween as the boundsTransform of shared elements, so they move evenly along
the drag.Hoist the state to keep it outside of the layout. It saves the settled state automatically:
val headerState = rememberCollapsibleHeaderContainerState()
val expandableState = rememberExpandableContentState()AnimatedColumn is part of the separate layout-animated artifact.
AnimatedColumn animates its items to their new position whenever items changes, for example
when the list is sorted or filtered, or when an item is added or removed. Give every item a stable
and unique key, so its state survives a reorder, and call animateItem() on the modifier of the
item:
AnimatedColumn(
items = tasks,
key = { task -> task.id },
modifier = Modifier.fillMaxWidth(),
) { task ->
TaskCard(
task = task,
modifier = Modifier.animateItem(),
)
}Items that move slide to their new position, new items fade in, and removed items fade out where
they were. animateItem takes a placementSpec and fadeSpecs, pass null to turn either off.
Items without animateItem move and disappear without a transition.
Unlike LazyColumn, every item is composed and the column does not scroll on its own. Use it
inside any scrollable container, such as a Column with verticalScroll, for short lists.
The demo module shows every component in all its states. Its home screen is grouped by component, each with sub menus for animated variants, non-animated variants and other configurations, such as content that does not scroll, custom insets and both components on one screen. Navigation is built with Navigation 3.
./gradlew :androidApp:installDebug
| Module | Contents |
|---|---|
strata/gesture/draggable |
The library, published as gesture-draggable: collapsible headers, expandable content and the compare slider. |
strata/gesture/draggable-previews |
The unpublished Compose previews of the library. |
strata/layout/animated |
The library, published as layout-animated: AnimatedColumn, a column that animates its items when the list changes. |
theme |
The shared Material 3 theme of the demo and the previews. |
demo |
The shared demo app with Navigation 3. |
androidApp, iosApp
|
The platform entry points of the demo. |
Contributions are welcome, see CONTRIBUTING. Most of the code of the components is written by hand. AI tools only support the work, for example with research, boilerplate, tests and review, and every line is read and owned by the maintainer.
Copyright 2026 PrimoDev23
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Draggable, layered layouts for Compose Multiplatform.
Collapsible headers and expandable bottom content whose animations follow your finger.
![]() |
![]() |
![]() |
![]() |
CollapsibleHeaderContainer |
ExpandableContent |
CompareSlider |
AnimatedColumn |
animateEnterExit, sharedElement and sharedBounds move exactly with the finger.PaddingValues.| Component | What it does |
|---|---|
CollapsibleHeaderContainer |
A header above the content that collapses with scrolling and switches between an expanded and a collapsed header. |
AnimatableCollapsibleHeaderContainer |
The same container, with a transition between both headers that follows the drag. |
ExpandableContent |
A bottom layout that is dragged from a compact bar into a full screen, like a mini player. |
CompareSlider |
Two layouts side by side that are compared by dragging a slider between them, like a before and after image. |
SwipeToConfirm |
A thumb that is slid to the end of a track to confirm an action that must not happen by accident. |
AnimatedColumn |
A column that animates its items to their new position when the list is sorted, filtered or changed, and fades items in and out. |
The collapsible headers and ExpandableContent settle in one of the two DraggableLayoutStates:
Collapsed or Expanded. CompareSlider stays wherever it is dropped.
Strata is published to Maven Central. Add the artifacts you need to the common source set of your shared module:
// build.gradle.kts of your shared module
kotlin {
sourceSets {
commonMain.dependencies {
// CollapsibleHeaderContainer, AnimatableCollapsibleHeaderContainer, ExpandableContent,
// CompareSlider, SwipeToConfirm
implementation("dev.leonp.strata:gesture-draggable:0.2.1")
// AnimatedColumn
implementation("dev.leonp.strata:layout-animated:0.2.1")
}
}
}The header collapses before the content scrolls and expands again once the content reached its
start. Apply the PaddingValues handed to each slot, they contain the window insets.
CollapsibleHeaderContainer(
expandedHeader = { padding ->
Text(
text = "Expanded header",
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.primaryContainer)
.padding(padding)
.padding(24.dp),
)
},
collapsedHeader = { padding ->
Text(
text = "Collapsed header",
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.primaryContainer)
.padding(padding)
.padding(16.dp),
)
},
) { padding ->
LazyColumn(contentPadding = padding) {
items(50) { index -> Text("Item $index", Modifier.padding(16.dp)) }
}
}Leave out collapsedHeader to let the header collapse down to the top insets, and pass
insets = WindowInsets(0, 0, 0, 0) when a parent, such as a Scaffold, already handles them.
AnimatableCollapsibleHeaderContainer runs a transition between both headers. Its header slots
are an AnimatableCollapsibleHeaderScope, so shared elements and enter and exit animations work
directly:
SharedTransitionLayout {
AnimatableCollapsibleHeaderContainer(
expandedHeader = { padding ->
Column(Modifier.fillMaxWidth().padding(padding).padding(24.dp)) {
Text(
text = "Strata",
style = MaterialTheme.typography.displaySmall,
modifier = Modifier.sharedBounds(
sharedContentState = rememberSharedContentState("title"),
animatedVisibilityScope = this@AnimatableCollapsibleHeaderContainer,
),
)
Text(
text = "Scroll to collapse",
modifier = Modifier.animateEnterExit(
enter = fadeIn(tween(400, delayMillis = 600, easing = LinearEasing)),
exit = fadeOut(tween(400, easing = LinearEasing)),
),
)
}
},
collapsedHeader = { padding ->
Text(
text = "Strata",
style = MaterialTheme.typography.titleLarge,
modifier = Modifier
.padding(padding)
.padding(16.dp)
.sharedBounds(
sharedContentState = rememberSharedContentState("title"),
animatedVisibilityScope = this@AnimatableCollapsibleHeaderContainer,
),
)
},
) { padding ->
LazyColumn(contentPadding = padding) { /* … */ }
}
}Place ExpandableContent at the bottom of a full size parent, so it grows upwards. The content
lambda receives the state to show and runs in an ExpandableContentScope:
SharedTransitionLayout {
Box(Modifier.fillMaxSize()) {
ScreenContent()
ExpandableContent(
modifier = Modifier
.align(Alignment.BottomCenter)
// The background belongs to the layout, so it grows with the drag right away.
.background(MaterialTheme.colorScheme.surfaceContainerHigh),
) { layoutState ->
when (layoutState) {
DraggableLayoutState.Collapsed -> MiniPlayer(
modifier = Modifier.windowInsetsPadding(WindowInsets.navigationBars),
)
DraggableLayoutState.Expanded -> FullPlayer(
modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars),
)
}
}
}
}Inside MiniPlayer and FullPlayer, give elements that exist in both states the same
rememberSharedContentState key, and fade everything else with animateEnterExit.
To expand or collapse the layout from code, for example when a button is tapped, hoist the state
and call its suspending expand() and collapse(). They animate the layout like a settling drag
and are cancelled when a drag or another call interrupts them:
val state = rememberExpandableContentState()
val scope = rememberCoroutineScope()
ExpandableContent(state = state) { /* … */ }
Button(onClick = { scope.launch { state.expand() } }) { Text("Open player") }CompareSlider shows before left of a slider and after right of it. Drag the thumb to reveal
more of one side. Give the layout a size, it fills the constraints it gets:
CompareSlider(
before = { Image(painter = originalPainter, contentDescription = "Before", ...) },
after = { Image(painter = editedPainter, contentDescription = "After", ...) },
thumb = { SliderThumb() },
modifier = Modifier
.fillMaxWidth()
.aspectRatio(3f / 4f)
.clip(RoundedCornerShape(28.dp)),
sliderThickness = 2.dp,
sliderColor = Color.White,
)Both slots are measured at the full size of the layout and only clipped at the slider, so they are never scaled or squeezed. Elements inside a slot, such as a label in a corner, stay where they are while the slider moves. The slider starts in the middle, and its position survives configuration changes and process death.
SwipeToConfirm confirms an action once the thumb was dragged far enough along the track. The
thumb is as high as the track, so give the track a height and the thumb an aspect ratio. A thumb
that is released before confirmationThreshold snaps back, however fast it was released:
val state = rememberSwipeToConfirmState()
SwipeToConfirm(
thumb = { PayThumb(modifier = Modifier.aspectRatio(1f)) },
modifier = Modifier
.fillMaxWidth()
.height(64.dp),
state = state,
onConfirm = { pay() },
confirmationThreshold = 0.7f,
colors = SwipeToConfirmDefaults.colors(
backgroundColor = MaterialTheme.colorScheme.secondaryContainer,
progressColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f),
),
) {
Text(
text = "Slide to pay",
modifier = Modifier
.align(Alignment.Center)
.alpha(1f - state.progress),
)
}state.progress goes from 0f to 1f and drives the label. A confirmed track does not accept
drags, call state.reset() to use it again. Without colors, the track draws neither a background
nor a fill.
Transitions are seeked by the drag position instead of played over time. Seeking maps the drag progress linearly onto the total duration of the transition, so durations and delays define where in the drag an animation runs:
// Total duration: 1000 ms. This fades in during the last 20 % of the drag.
fadeIn(tween(durationMillis = 200, delayMillis = 800, easing = LinearEasing))
// And this fades out during the first 20 %.
fadeOut(tween(durationMillis = 200, easing = LinearEasing))A few tips:
tween specs on one shared timeline. The duration of a spring is only estimated and
silently changes the total duration.tween as the boundsTransform of shared elements, so they move evenly along
the drag.Hoist the state to keep it outside of the layout. It saves the settled state automatically:
val headerState = rememberCollapsibleHeaderContainerState()
val expandableState = rememberExpandableContentState()AnimatedColumn is part of the separate layout-animated artifact.
AnimatedColumn animates its items to their new position whenever items changes, for example
when the list is sorted or filtered, or when an item is added or removed. Give every item a stable
and unique key, so its state survives a reorder, and call animateItem() on the modifier of the
item:
AnimatedColumn(
items = tasks,
key = { task -> task.id },
modifier = Modifier.fillMaxWidth(),
) { task ->
TaskCard(
task = task,
modifier = Modifier.animateItem(),
)
}Items that move slide to their new position, new items fade in, and removed items fade out where
they were. animateItem takes a placementSpec and fadeSpecs, pass null to turn either off.
Items without animateItem move and disappear without a transition.
Unlike LazyColumn, every item is composed and the column does not scroll on its own. Use it
inside any scrollable container, such as a Column with verticalScroll, for short lists.
The demo module shows every component in all its states. Its home screen is grouped by component, each with sub menus for animated variants, non-animated variants and other configurations, such as content that does not scroll, custom insets and both components on one screen. Navigation is built with Navigation 3.
./gradlew :androidApp:installDebug
| Module | Contents |
|---|---|
strata/gesture/draggable |
The library, published as gesture-draggable: collapsible headers, expandable content and the compare slider. |
strata/gesture/draggable-previews |
The unpublished Compose previews of the library. |
strata/layout/animated |
The library, published as layout-animated: AnimatedColumn, a column that animates its items when the list changes. |
theme |
The shared Material 3 theme of the demo and the previews. |
demo |
The shared demo app with Navigation 3. |
androidApp, iosApp
|
The platform entry points of the demo. |
Contributions are welcome, see CONTRIBUTING. Most of the code of the components is written by hand. AI tools only support the work, for example with research, boilerplate, tests and review, and every line is read and owned by the maintainer.
Copyright 2026 PrimoDev23
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.