CardStack

CardStack is an animated card stack component for React Native and React, from the dissolve library. Wallet style card stack: tap to focus, drag down to put back, swipe to cycle.

A Wallet style stack. Cards overlap and show their top strip; tap one and it comes forward while the others slide down and compress under it. Drag the focused card down to put it back, swipe it sideways to go to the next one. One calm curve, no bounce, and a fixed height so nothing around it relayouts.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add card-stack --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/card-stack.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add card-stack --web
npx shadcn@latest add https://dissolve.rselmi.com/r/card-stack.json

Usage

CardStack.tsx (React Native)
import { CardStack } from '@/components/dissolve/card-stack';

<CardStack
  items={cards}
  keyExtractor={(c) => c.id}
  renderCard={(c) => <PaymentCard card={c} />}
  onFocus={setActive}
/>
CardStack.tsx (React)
import { CardStack } from '@/components/dissolve/card-stack';

<CardStack
  items={cards}
  keyExtractor={(c) => c.id}
  renderCard={(c) => <PaymentCard card={c} />}
  onFocus={setActive}
/>

Props

PropTypeDefaultDescription
itemsT[]requiredThe cards, top of the stack first.
renderCard(item: T, index: number) => ReactNoderequiredRenders one card face. It is clipped to the card radius.
cardHeightnumberwidth / 1.586Card height. The default is the ISO payment card ratio.
peeknumber60Visible strip of each card in the stack.
onFocus(index: number | null) => voidCalled with the focused index, or null when back to the stack.
keyExtractor(item: T, index: number) => stringStable keys for the cards.
hapticsbooleantrueLight impact on focus, soft on restack, a tick when cycling.
classNamestringContainer: margins, padding.
cardClassNamestring'rounded-[20px]' + shadowCard chrome: corner radius and shadow. Replaces the default, a soft shadow cast upward on the card behind.

Source

Previous: SignaturePad · Next: BeforeAfter · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.