React Native · Expo SDK 57 New
Glass Card Stack
A swipeable card deck with Previous and Next buttons, for iOS, Android and the web.
Requires GestureHandlerRootView from react-native-gesture-handler around your app.
Installation
For Expo SDK 57 or later.
Add a components.json to your app first, as the Expo guide shows.
npx shadcn@4.14.1 add @glassyui-native/glass-card-stack && npx expo install --fixAdds 13 files to components/glassyui, then matches react-native-gesture-handler, react-native-reanimated, react-native-worklets, expo-haptics, expo-blur and expo-glass-effect to your Expo SDK. Rebuild your development build after adding native packages.
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>
);
}
It also uses Glass Provider. Install them together:
npx shadcn@4.14.1 add @glassyui-native/glass-card-stack @glassyui-native/glass-provider && npx expo install --fixAPI reference
GlassCardStack
A controlled deck, generic over T extends { id: string }, with a position count between Previous and Next.
| Prop | Type | Default | Description |
|---|---|---|---|
itemsRequired | readonly T[] | None | The cards in order; each id must be unique and stable. |
activeIndex / onIndexChangeRequired | number / (index: number) => void | None | The current card, clamped to the items, and its change handler. |
renderCardRequired | (item: T, index: number) => ReactNode | None | Card contents; only the previous, current and next two cards render. |
labelRequired | string | None | Names the deck in the Previous and Next buttons' accessible names. |
height | number | 220 | Card height in points; the deck adds 24 for the stacked edges. |
haptics | boolean | true | Plays a selection haptic on each card change, on iOS and Android. |
style | StyleProp<ViewStyle> | None | Applies to the outer view. |
testID | string | None | Set on the swipeable deck, not the outer view. |
- Types
GlassCardStackProps- Accessibility
- Only the current card is exposed and takes input; Previous, Next and a polite live position count give accessible navigation.