Browse docsCard Stack

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 --fix

Adds 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 --fix

API reference

GlassCardStack

A controlled deck, generic over T extends { id: string }, with a position count between Previous and Next.

PropTypeDefaultDescription
itemsRequiredreadonly T[]NoneThe cards in order; each id must be unique and stable.
activeIndex / onIndexChangeRequirednumber / (index: number) => voidNoneThe current card, clamped to the items, and its change handler.
renderCardRequired(item: T, index: number) => ReactNodeNoneCard contents; only the previous, current and next two cards render.
labelRequiredstringNoneNames the deck in the Previous and Next buttons' accessible names.
heightnumber220Card height in points; the deck adds 24 for the stacked edges.
hapticsbooleantruePlays a selection haptic on each card change, on iOS and Android.
styleStyleProp<ViewStyle>NoneApplies to the outer view.
testIDstringNoneSet 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.