React Native · Expo SDK 57 New
Glass Card Stack
A stack of cards that follows your finger and settles with a velocity-aware spring, with navigation controls and selection haptics.
npx shadcn@4.14.1 add @glassyui-native/glass-card-stackInstallation
Install Glass Card Stack
npx shadcn@4.14.1 add @glassyui-native/glass-card-stack
npx expo install --fixRebuild your development build after adding native modules. The Expo guide covers the registry and glass provider.
Usage
Glass Card Stack usage
import { useState } from 'react';
import { Text, View } from 'react-native';
import { GlassCardStack } from '@/components/glassyui/glass-card-stack';
import { useGlassTheme } from '@/components/glassyui/glass-provider';
const CARDS = [
{ id: 'morning', title: 'Morning', detail: 'Make room for the important work.' },
{ id: 'afternoon', title: 'Afternoon', detail: 'A little time to explore.' },
{ id: 'evening', title: 'Evening', detail: 'Finish the day at your own pace.' },
];
export default function CardStackExample() {
const { colors } = useGlassTheme();
const [index, setIndex] = useState(0);
return (
<View style={{ gap: 12 }}>
<GlassCardStack
items={CARDS}
activeIndex={index}
onIndexChange={setIndex}
label="Daily plan"
testID="native-card-stack"
renderCard={(card) => (
<View style={{ flex: 1, justifyContent: 'space-between' }}>
<Text style={{ color: colors.mutedForeground, fontSize: 14 }}>Daily plan</Text>
<View style={{ gap: 8 }}>
<Text style={{ color: colors.foreground, fontSize: 28, fontWeight: '600' }}>
{card.title}
</Text>
<Text style={{ color: colors.mutedForeground, fontSize: 16 }}>{card.detail}</Text>
</View>
</View>
)}
/>
<Text style={{ color: colors.foreground }} testID="native-stack-value">
{CARDS[index].title}
</Text>
</View>
);
}
API
| Prop | Type | Use |
|---|---|---|
items | T[] where T extends { id: string } | The ordered cards. |
activeIndex / onIndexChange | number / (index: number) => void | The selected card and its change handler. |
renderCard | (item: T, index: number) => ReactNode | The contents of each card. |
label | string | Names the deck in its navigation controls. |
height | number | Card height in points; defaults to 220. |
haptics | boolean | Defaults to true on native platforms. |
Each component also accepts style and testID.
Notes
- Drag left for the next card or right for the previous card. A short drag returns to the current card. Release velocity affects spring settling.
- Wrap the app in GestureHandlerRootView, above GlassProvider. Vertical drags remain available to the parent scroll view.
- Keep activeIndex controlled. Cards need unique, stable ids. Only the current card accepts input; Previous and Next provide accessible navigation.
- Reduce Motion keeps selection and navigation but removes drag animation, tilt, and spring travel. Selection haptics run on native platforms unless disabled.