React Native Design
Seth HobsonCommunityCreated by Seth Hobson
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides patterns and reference material for developing cross-platform mobile applications using React Native. It covers styling with StyleSheet, implementing navigation structures with React Navigation, and creating animations using Reanimated 3. The content includes code examples for common UI components, navigation configurations, and layout techniques, alongside best practices for maintaining type safety and component structure.
What it does
- Provides patterns for styling components using StyleSheet and dynamic style objects.
- Demonstrates how to configure Stack and Tab navigators with React Navigation.
- Offers examples for creating animations using Reanimated 3 shared values and worklets.
- Includes guidance on implementing responsive Flexbox layouts.
- Outlines best practices for TypeScript integration and component memoization.
- Provides solutions for common issues like gesture conflicts and navigation type errors.
When to use it
- When building cross-platform mobile applications with React Native.
- When setting up navigation flows using React Navigation 6+.
- When creating animations using the Reanimated 3 library.
- When defining responsive layouts and styling components.
- When implementing platform-specific design adjustments for iOS and Android.
Advantages
- Centralizes patterns for styling, navigation, and animation in one reference.
- Includes type-safe navigation configuration examples.
- Provides reusable code snippets for common UI elements.
- Offers clear guidance on handling platform-specific differences.
Usage examples
- “How do I set up a basic Stack Navigator in React Native?”
- The skill provides a code example using createNativeStackNavigator, including the definition of a RootStackParamList for type safety and screen configuration.
- “Show me how to create a dynamic style for a card component.”
- The skill provides a pattern for passing props to a component to conditionally apply styles from a StyleSheet object.
- “How can I animate a button press using Reanimated?”
- The skill provides a code snippet demonstrating the use of useSharedValue, useAnimatedStyle, and withSpring to animate a component scale on press.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/wshobson/react-native-design/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip react-native-design.zip -d .agents/skills
Documentation by Seth Hobson
React Native Design
Master React Native styling patterns, React Navigation, and Reanimated 3 to build performant, cross-platform mobile applications with native-quality user experiences.
When to Use This Skill
Building cross-platform mobile apps with React Native
Implementing navigation with React Navigation 6+
Creating performant animations with Reanimated 3
Styling components with StyleSheet and styled-components
Building responsive layouts for different screen sizes
Implementing platform-specific designs (iOS/Android)
Creating gesture-driven interactions with Gesture Handler
Optimizing React Native performance
Detailed section: Core Concepts
Originally a 6471-byte section in this SKILL.md. Moved to references/details.md to fit Codex's 8 KB skill body cap.
Quick Start Component
import React from 'react';
import {
View,
Text,
StyleSheet,
Pressable,
Image,
} from 'react-native';
import Animated, {
useSharedValue,
useAnimatedStyle,
withSpring,
} from 'react-native-reanimated';
interface ItemCardProps {
title: string;
subtitle: string;
imageUrl: string;
onPress: () => void;
}
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
export function ItemCard({ title, subtitle, imageUrl, onPress }: ItemCardProps) {
const scale = useSharedValue(1);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }],
}));
return (
<AnimatedPressable
style={[styles.card, animatedStyle]}
onPress={onPress}
onPressIn={() => { scale.value = withSpring(0.97); }}
onPressOut={() => { scale.value = withSpring(1); }}
>
<Image source={{ uri: imageUrl }} style={styles.image} />
<View style={styles.content}>
<Text style={styles.title} numberOfLines={1}>
{title}
</Text>
<Text style={styles.subtitle} numberOfLines={2}>
{subtitle}
</Text>
</View>
</AnimatedPressable>
);
}
const styles = StyleSheet.create({
card: {
backgroundColor: '#ffffff',
borderRadius: 16,
overflow: 'hidden',
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 8,
elevation: 4,
},
image: {
width: '100%',
height: 160,
backgroundColor: '#f3f4f6',
},
content: {
padding: 16,
gap: 4,
},
title: {
fontSize: 18,
fontWeight: '600',
color: '#1f2937',
},
subtitle: {
fontSize: 14,
color: '#6b7280',
lineHeight: 20,
},
});Best Practices
Use TypeScript: Define navigation and prop types for type safety
Memoize Components: Use
React.memoanduseCallbackto prevent unnecessary rerendersRun Animations on UI Thread: Use Reanimated worklets for 60fps animations
Avoid Inline Styles: Use StyleSheet.create for performance
Handle Safe Areas: Use
SafeAreaVieworuseSafeAreaInsetsTest on Real Devices: Simulator/emulator performance differs from real devices
Use FlatList for Lists: Never use ScrollView with map for long lists
Platform-Specific Code: Use Platform.select for iOS/Android differences
Common Issues
Gesture Conflicts: Wrap gestures with
GestureDetectorand usesimultaneousHandlersNavigation Type Errors: Define
ParamListtypes for all navigatorsAnimation Jank: Move animations to UI thread with
runOnUIworkletsMemory Leaks: Cancel animations and cleanup in useEffect
Font Loading: Use
expo-fontorreact-native-assetfor custom fontsSafe Area Issues: Test on notched devices (iPhone, Android with cutouts)
Files
- ATTRIBUTION.mdAdded by AutoGineer975 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md3.9 KiB
- references/details.md6.4 KiB
- references/navigation-patterns.md19.7 KiB
- references/reanimated-patterns.md17.0 KiB
- references/styling-patterns.md18.4 KiB
references/reanimated-patterns.md
React Native Reanimated 3 Patterns
Core Concepts
Shared Values and Animated Styles
import Animated, {
useSharedValue,
useAnimatedStyle,
withSpring,
withTiming,
withDelay,
withSequence,
withRepeat,
Easing,
} from 'react-native-reanimated';
function BasicAnimations() {
// Shared value - can be modified from JS or UI thread
const opacity = useSharedValue(0);
const scale = useSharedValue(1);
const rotation = useSharedValue(0);
// Animated style - runs on UI thread
const animatedStyle = useAnimatedStyle(() => ({
opacity: opacity.value,
transform: [
{ scale: scale.value },
{ rotate: `${rotation.value}deg` },
],
}));
const animate = () => {
// Spring animation
scale.value = withSpring(1.2, {
damping: 10,
stiffness: 100,
});
// Timing animation with easing
opacity.value = withTiming(1, {
duration: 500,
easing: Easing.bezier(0.25, 0.1, 0.25, 1),
});
// Sequence of animations
rotation.value = withSequence(
withTiming(15, { duration: 100 }),
withTiming(-15, { duration: 100 }),
withTiming(0, { duration: 100 })
);
};
return (
<Animated.View style={[styles.box, animatedStyle]} />
);
}Animation Callbacks
import { runOnJS, runOnUI } from 'react-native-reanimated';
function AnimationWithCallbacks() {
const translateX = useSharedValue(0);
const [status, setStatus] = useState('idle');
const updateStatus = (newStatus: string) => {
setStatus(newStatus);
};
const animate = () => {
translateX.value = withTiming(
200,
{ duration: 1000 },
(finished) => {
'worklet';
if (finished) {
// Call JS function from worklet
runOnJS(updateStatus)('completed');
}
}
);
};
return (
<Animated.View
style={[
styles.box,
useAnimatedStyle(() => ({
transform: [{ translateX: translateX.value }],
})),
]}
/>
);
}Gesture Handler Integration
Pan Gesture
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import Animated, {
useSharedValue,
useAnimatedStyle,
withSpring,
clamp,
} from 'react-native-reanimated';
function DraggableBox() {
const translateX = useSharedValue(0);
const translateY = useSharedValue(0);
const context = useSharedValue({ x: 0, y: 0 });
const panGesture = Gesture.Pan()
.onStart(() => {
context.value = { x: translateX.value, y: translateY.value };
})
.onUpdate((event) => {
translateX.value = event.translationX + context.value.x;
translateY.value = event.translationY + context.value.y;
})
.onEnd((event) => {
// Apply velocity decay
translateX.value = withSpring(
clamp(translateX.value + event.velocityX / 10, -100, 100)
);
translateY.value = withSpring(
clamp(translateY.value + event.velocityY / 10, -100, 100)
);
});
const animatedStyle = useAnimatedStyle(() => ({
transform: [
{ translateX: translateX.value },
{ translateY: translateY.value },
],
}));
return (
<GestureDetector gesture={panGesture}>
<Animated.View style={[styles.box, animatedStyle]} />
</GestureDetector>
);
}Pinch and Rotate Gestures
function ZoomableImage() {
const scale = useSharedValue(1);
const rotation = useSharedValue(0);
const savedScale = useSharedValue(1);
const savedRotation = useSharedValue(0);
const pinchGesture = Gesture.Pinch()
.onUpdate((event) => {
scale.value = savedScale.value * event.scale;
})
.onEnd(() => {
savedScale.value = scale.value;
// Snap back if too small
if (scale.value < 1) {
scale.value = withSpring(1);
savedScale.value = 1;
}
});
const rotateGesture = Gesture.Rotation()
.onUpdate((event) => {
rotation.value = savedRotation.value + event.rotation;
})
.onEnd(() => {
savedRotation.value = rotation.value;
});
const composed = Gesture.Simultaneous(pinchGesture, rotateGesture);
const animatedStyle = useAnimatedStyle(() => ({
transform: [
{ scale: scale.value },
{ rotate: `${rotation.value}rad` },
],
}));
return (
<GestureDetector gesture={composed}>
<Animated.Image
source={{ uri: imageUrl }}
style={[styles.image, animatedStyle]}
/>
</GestureDetector>
);
}Tap Gesture with Feedback
function TappableCard({ onPress, children }: TappableCardProps) {
const scale = useSharedValue(1);
const opacity = useSharedValue(1);
const tapGesture = Gesture.Tap()
.onBegin(() => {
scale.value = withSpring(0.97);
opacity.value = withTiming(0.8, { duration: 100 });
})
.onFinalize(() => {
scale.value = withSpring(1);
opacity.value = withTiming(1, { duration: 100 });
})
.onEnd(() => {
runOnJS(onPress)();
});
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }],
opacity: opacity.value,
}));
return (
<GestureDetector gesture={tapGesture}>
<Animated.View style={[styles.card, animatedStyle]}>
{children}
</Animated.View>
</GestureDetector>
);
}Common Animation Patterns
Fade In/Out
function FadeInView({ visible, children }: FadeInViewProps) {
const opacity = useSharedValue(0);
useEffect(() => {
opacity.value = withTiming(visible ? 1 : 0, { duration: 300 });
}, [visible]);
const animatedStyle = useAnimatedStyle(() => ({
opacity: opacity.value,
display: opacity.value === 0 ? 'none' : 'flex',
}));
return (
<Animated.View style={animatedStyle}>
{children}
</Animated.View>
);
}Slide In/Out
function SlideInView({ visible, direction = 'right', children }) {
const translateX = useSharedValue(direction === 'right' ? 100 : -100);
const opacity = useSharedValue(0);
useEffect(() => {
if (visible) {
translateX.value = withSpring(0);
opacity.value = withTiming(1);
} else {
translateX.value = withSpring(direction === 'right' ? 100 : -100);
opacity.value = withTiming(0);
}
}, [visible, direction]);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateX: translateX.value }],
opacity: opacity.value,
}));
return (
<Animated.View style={animatedStyle}>
{children}
</Animated.View>
);
}Staggered List Animation
function StaggeredList({ items }: { items: Item[] }) {
return (
<FlatList
data={items}
keyExtractor={(item) => item.id}
renderItem={({ item, index }) => (
<StaggeredItem item={item} index={index} />
)}
/>
);
}
function StaggeredItem({ item, index }: { item: Item; index: number }) {
const translateY = useSharedValue(50);
const opacity = useSharedValue(0);
useEffect(() => {
translateY.value = withDelay(
index * 100,
withSpring(0, { damping: 15 })
);
opacity.value = withDelay(
index * 100,
withTiming(1, { duration: 300 })
);
}, [index]);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateY: translateY.value }],
opacity: opacity.value,
}));
return (
<Animated.View style={[styles.listItem, animatedStyle]}>
<Text>{item.title}</Text>
</Animated.View>
);
}Pulse Animation
function PulseView({ children }: { children: React.ReactNode }) {
const scale = useSharedValue(1);
useEffect(() => {
scale.value = withRepeat(
withSequence(
withTiming(1.05, { duration: 500 }),
withTiming(1, { duration: 500 })
),
-1, // infinite
false // no reverse
);
return () => {
cancelAnimation(scale);
};
}, []);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }],
}));
return (
<Animated.View style={animatedStyle}>
{children}
</Animated.View>
);
}Shake Animation
function ShakeView({ trigger, children }) {
const translateX = useSharedValue(0);
useEffect(() => {
if (trigger) {
translateX.value = withSequence(
withTiming(-10, { duration: 50 }),
withTiming(10, { duration: 50 }),
withTiming(-10, { duration: 50 }),
withTiming(10, { duration: 50 }),
withTiming(0, { duration: 50 })
);
}
}, [trigger]);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateX: translateX.value }],
}));
return (
<Animated.View style={animatedStyle}>
{children}
</Animated.View>
);
}Advanced Patterns
Interpolation
import { interpolate, Extrapolation } from 'react-native-reanimated';
function ParallaxHeader() {
const scrollY = useSharedValue(0);
const headerStyle = useAnimatedStyle(() => {
const height = interpolate(
scrollY.value,
[0, 200],
[300, 100],
Extrapolation.CLAMP
);
const opacity = interpolate(
scrollY.value,
[0, 150, 200],
[1, 0.5, 0],
Extrapolation.CLAMP
);
const translateY = interpolate(
scrollY.value,
[0, 200],
[0, -50],
Extrapolation.CLAMP
);
return {
height,
opacity,
transform: [{ translateY }],
};
});
return (
<View style={styles.container}>
<Animated.View style={[styles.header, headerStyle]}>
<Text style={styles.headerTitle}>Header</Text>
</Animated.View>
<Animated.ScrollView
onScroll={useAnimatedScrollHandler({
onScroll: (event) => {
scrollY.value = event.contentOffset.y;
},
})}
scrollEventThrottle={16}
>
{/* Content */}
</Animated.ScrollView>
</View>
);
}Color Interpolation
import { interpolateColor } from 'react-native-reanimated';
function ColorTransition() {
const progress = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => {
const backgroundColor = interpolateColor(
progress.value,
[0, 0.5, 1],
['#6366f1', '#8b5cf6', '#ec4899']
);
return { backgroundColor };
});
const toggleColor = () => {
progress.value = withTiming(progress.value === 0 ? 1 : 0, {
duration: 1000,
});
};
return (
<Pressable onPress={toggleColor}>
<Animated.View style={[styles.box, animatedStyle]} />
</Pressable>
);
}Derived Values
import { useDerivedValue } from 'react-native-reanimated';
function DerivedValueExample() {
const x = useSharedValue(0);
const y = useSharedValue(0);
// Derived value computed from other shared values
const distance = useDerivedValue(() => {
return Math.sqrt(x.value ** 2 + y.value ** 2);
});
const angle = useDerivedValue(() => {
return Math.atan2(y.value, x.value) * (180 / Math.PI);
});
const animatedStyle = useAnimatedStyle(() => ({
transform: [
{ translateX: x.value },
{ translateY: y.value },
{ rotate: `${angle.value}deg` },
],
opacity: interpolate(distance.value, [0, 200], [1, 0.5]),
}));
return (
<Animated.View style={[styles.box, animatedStyle]} />
);
}Layout Animations
import Animated, {
Layout,
FadeIn,
FadeOut,
SlideInLeft,
SlideOutRight,
ZoomIn,
ZoomOut,
} from 'react-native-reanimated';
function AnimatedList() {
const [items, setItems] = useState([1, 2, 3, 4, 5]);
const addItem = () => {
setItems([...items, items.length + 1]);
};
const removeItem = (id: number) => {
setItems(items.filter((item) => item !== id));
};
return (
<View style={styles.container}>
<Button title="Add Item" onPress={addItem} />
{items.map((item) => (
<Animated.View
key={item}
style={styles.item}
entering={FadeIn.duration(300).springify()}
exiting={SlideOutRight.duration(300)}
layout={Layout.springify()}
>
<Text>Item {item}</Text>
<Pressable onPress={() => removeItem(item)}>
<Text>Remove</Text>
</Pressable>
</Animated.View>
))}
</View>
);
}Swipeable Card
function SwipeableCard({ onSwipeLeft, onSwipeRight }) {
const translateX = useSharedValue(0);
const rotateZ = useSharedValue(0);
const context = useSharedValue({ x: 0 });
const SWIPE_THRESHOLD = 120;
const panGesture = Gesture.Pan()
.onStart(() => {
context.value = { x: translateX.value };
})
.onUpdate((event) => {
translateX.value = event.translationX + context.value.x;
rotateZ.value = interpolate(
translateX.value,
[-200, 0, 200],
[-15, 0, 15]
);
})
.onEnd((event) => {
if (translateX.value > SWIPE_THRESHOLD) {
translateX.value = withTiming(500, { duration: 200 }, () => {
runOnJS(onSwipeRight)();
});
} else if (translateX.value < -SWIPE_THRESHOLD) {
translateX.value = withTiming(-500, { duration: 200 }, () => {
runOnJS(onSwipeLeft)();
});
} else {
translateX.value = withSpring(0);
rotateZ.value = withSpring(0);
}
});
const animatedStyle = useAnimatedStyle(() => ({
transform: [
{ translateX: translateX.value },
{ rotate: `${rotateZ.value}deg` },
],
}));
const leftIndicatorStyle = useAnimatedStyle(() => ({
opacity: interpolate(
translateX.value,
[0, SWIPE_THRESHOLD],
[0, 1],
Extrapolation.CLAMP
),
}));
const rightIndicatorStyle = useAnimatedStyle(() => ({
opacity: interpolate(
translateX.value,
[-SWIPE_THRESHOLD, 0],
[1, 0],
Extrapolation.CLAMP
),
}));
return (
<GestureDetector gesture={panGesture}>
<Animated.View style={[styles.card, animatedStyle]}>
<Animated.View style={[styles.likeIndicator, leftIndicatorStyle]}>
<Text>LIKE</Text>
</Animated.View>
<Animated.View style={[styles.nopeIndicator, rightIndicatorStyle]}>
<Text>NOPE</Text>
</Animated.View>
{/* Card content */}
</Animated.View>
</GestureDetector>
);
}Bottom Sheet
const MAX_TRANSLATE_Y = -SCREEN_HEIGHT + 50;
const MIN_TRANSLATE_Y = 0;
const SNAP_POINTS = [-SCREEN_HEIGHT * 0.5, -SCREEN_HEIGHT * 0.25, 0];
function BottomSheet({ children }) {
const translateY = useSharedValue(0);
const context = useSharedValue({ y: 0 });
const panGesture = Gesture.Pan()
.onStart(() => {
context.value = { y: translateY.value };
})
.onUpdate((event) => {
translateY.value = clamp(
context.value.y + event.translationY,
MAX_TRANSLATE_Y,
MIN_TRANSLATE_Y
);
})
.onEnd((event) => {
// Find closest snap point
const destination = SNAP_POINTS.reduce((prev, curr) =>
Math.abs(curr - translateY.value) < Math.abs(prev - translateY.value)
? curr
: prev
);
translateY.value = withSpring(destination, {
damping: 50,
stiffness: 300,
});
});
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ translateY: translateY.value }],
}));
const backdropStyle = useAnimatedStyle(() => ({
opacity: interpolate(
translateY.value,
[MIN_TRANSLATE_Y, MAX_TRANSLATE_Y],
[0, 0.5]
),
pointerEvents: translateY.value < -50 ? 'auto' : 'none',
}));
return (
<>
<Animated.View style={[styles.backdrop, backdropStyle]} />
<GestureDetector gesture={panGesture}>
<Animated.View style={[styles.bottomSheet, animatedStyle]}>
<View style={styles.handle} />
{children}
</Animated.View>
</GestureDetector>
</>
);
}Performance Tips
Memoization
// Memoize animated style when dependencies don't change
const animatedStyle = useAnimatedStyle(
() => ({
transform: [{ translateX: translateX.value }],
}),
[],
); // Empty deps if no external dependencies
// Use useMemo for complex calculations outside worklets
const threshold = useMemo(() => calculateThreshold(screenWidth), [screenWidth]);Worklet Best Practices
// Do: Keep worklets simple
const simpleWorklet = () => {
"worklet";
return scale.value * 2;
};
// Don't: Complex logic in worklets
// Move complex logic to JS with runOnJS
// Do: Use runOnJS for callbacks
const onComplete = () => {
setIsAnimating(false);
};
opacity.value = withTiming(1, {}, (finished) => {
"worklet";
if (finished) {
runOnJS(onComplete)();
}
});Cancel Animations
import { cancelAnimation } from 'react-native-reanimated';
function AnimatedComponent() {
const translateX = useSharedValue(0);
useEffect(() => {
// Start animation
translateX.value = withRepeat(
withTiming(100, { duration: 1000 }),
-1,
true
);
// Cleanup: cancel animation on unmount
return () => {
cancelAnimation(translateX);
};
}, []);
return <Animated.View style={animatedStyle} />;
}Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Seth Hobson
- Publisher
- Seth Hobson (Community)
- Source
- wshobson/agents · plugins/ui-design/skills/react-native-design · commit 4bde316
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Seth Hobson or Seth Hobson.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download react-native-design.zip