A Compose Multiplatform card slider for Android and iOS: one large active card, a
fan of receded cards stacked behind it, and a queue of upcoming cards ahead — with 1:1 drag
tracking, real fling physics, and snap-to-card settling. All from a single commonMain
implementation, no View system anywhere.
Drag through cards · flick to jump up to 3 · tap a queued card to bring it forward ·
tap-to-seek scrubber · tap the active card for details · circular-reveal theme switch.
▶ Watch the full preview video (mp4)
This library is a full Compose Multiplatform migration of the classic View/XML-era
cardslider-android (originally by
Ramotion) — a custom
RecyclerView.LayoutManager + SnapHelper pair from the pre-Compose world. The port keeps the
original's exact motion design and replaces the machinery:
| Original (2017, View/XML) | This library (Compose Multiplatform) | |
|---|---|---|
| Layout engine | RecyclerView.LayoutManager (~700 LoC) |
SubcomposeLayout with windowed composition |
| Card transforms | ViewUpdater with per-frame border compensation |
One pure function of scroll position |
| Snapping | LinearSnapHelper + LinearSmoothScroller |
splineBasedDecay fling + distance-matched tween |
| Platforms | Android only | Android + iOS from commonMain |
The geometry is a faithful reproduction, not an approximation: the same card scales
(0.65 / 0.95 / 0.8), the same stacked-card travel (half-speed left stack), the same live 12dp
visual gap chain on the right queue, the same DecelerateInterpolator settle curve at
~0.5 ms/px, and the same up-to-3-cards fling cap.
| Light | Dark | Theme reveal |
|---|---|---|
![]() |
![]() |
![]() |
The bundled sample is a ground-up redesign of the original demo around one idea - the card is the screen: a blurred ambient render of the active card's photo fills the background, the slider floats over it as the hero, and everything else lives on translucent glass. Highlights:
- Circular-reveal theme switch - a custom sun/moon toggle that expands the incoming theme as a circle growing out of the switch itself, with the transparent status/navigation bars adapting their icon contrast to the in-app theme (which can override the system setting).
- Tap-to-seek scrubber - wired to the slider's continuous
scrollPosition, so it creeps with your finger mid-drag and doubles as a seek bar. - Liquid glass - panels and chips blur whatever sits behind them live, via Haze, with iOS-style continuous-corner squircle shapes on every rounded surface.
- Glass info panel with an embedded crossfading mini-map tile (luminance-inverted in dark mode) and the animated location dot.
- Contemporary type system - Unbounded for the display headlines, Plus Jakarta Sans for everything else (both OFL).
- Fluid card sizing across phone / foldable / tablet widths, edge-to-edge layout, and the original's 350 ms directional label choreography throughout.
Via JitPack:
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
maven("https://jitpack.io")
}
}
// build.gradle.kts
dependencies {
implementation("com.github.Micoder-dev.CardSlider-CMP:card-slider:<tag>")
}The JitPack artifact is Android-only (JitPack builds on Linux). For iOS, include the
:card-slidermodule directly or use the Maven Central artifact once published (io.github.micoder:card-slider).
CardSlider(
itemCount = items.size,
modifier = Modifier.fillMaxWidth(),
) { index ->
// Any composable — you own the card's content entirely.
Image(
painter = painterResource(items[index].photo),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
)
}With hoisted state, custom geometry, and click handling:
val state = rememberCardSliderState()
val scope = rememberCoroutineScope()
CardSlider(
itemCount = items.size,
state = state,
cardWidth = 148.dp, // scales cleanly — pass any size
cardHeight = 210.dp,
activeCardLeft = 50.dp, // where the active card docks; the stack lives inside it
cardsGap = 12.dp,
cardShape = RoundedCornerShape(10.dp),
onCardClick = { index ->
when {
index == state.activeIndex -> openDetails(index)
index > state.activeIndex -> scope.launch { state.animateToIndex(index) }
}
},
) { index -> Card(items[index]) }
// Observe:
val active = state.activeIndex // nearest card, updates continuously
val offset = state.scrollPosition // continuous position in card-widths (parallax, etc.)
val moving = state.isScrollInProgress // false only at rest — the SCROLL_STATE_IDLE analog| Symbol | What it does |
|---|---|
CardSlider(itemCount, ...) { index -> } |
The slider. Only visible cards are composed, so itemCount can be huge |
rememberCardSliderState(initialActiveIndex) |
Hoistable state, survives configuration changes and process death |
CardSliderState.activeIndex |
Index docked in the active slot (continuous during motion) |
CardSliderState.scrollPosition |
Fractional position in card-widths |
CardSliderState.isScrollInProgress |
true while dragging or settling |
CardSliderState.animateToIndex(i) / scrollToIndex(i) |
Programmatic navigation |
CardSliderDefaults |
The original's constants: sizes, scales (0.65/0.95/0.8), elevations (12/16/8), snap easing |
CardSlider-CMP/
├── card-slider/ # the library (commonMain, KMP: androidTarget + iosArm64/iosSimulatorArm64)
│ └── src/commonMain/kotlin/io/github/micoder/cardslider/
│ ├── CardSlider.kt # SubcomposeLayout + drag/fling + exact transform math
│ ├── CardSliderState.kt # hoistable state
│ └── CardSliderDefaults.kt # geometry & motion constants
└── sample/composeApp/ # Android + iOS demo (the destination explorer above)
├── src/commonMain/ # shared UI + original photo/map/font assets
├── src/androidMain/ # MainActivity
└── src/iosMain/ # MainViewController()
Android
./gradlew :sample:composeApp:assembleDebug
# install from sample/composeApp/build/outputs/apk/debug/iOS — the shared UI is exposed via MainViewController() in
sample/composeApp/src/iosMain. Embed the ComposeApp framework in an Xcode project:
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ vc: UIViewController, context: Context) {}
}iOS frameworks require macOS + Xcode to compile; the Android artifacts build anywhere.
- Kotlin 2.2.21 · Compose Multiplatform 1.11.1 · AGP 8.11.0 · Gradle 8.13
- Sample extras: Haze for backdrop-blur glass
- Library
minSdk21 · sampleminSdk24
- Original View/XML implementation: Ramotion/cardslider-android (MIT), migrated from Micoder-dev/cardslider-android.
- Demo photography and map imagery are the original demo's assets.
Copyright 2026 Micoder-dev
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
https://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.



