Component-Driven Development for Mobile Apps
How to build mobile apps that scale — a practical introduction to atomic design, component isolation, and building UI from the bottom up.
Abhinav Birajdar
Creator
The Problem with Screen-First Development
Most mobile projects start the same way: a designer hands over screen mockups, and developers build each screen top-to-bottom. It works at first. Then the product grows.
Suddenly, three different screens have three slightly different versions of the same button. Four screens share a card layout that evolved differently in each place. A design change to "the card" means hunting through the entire codebase.
Component-driven development (CDD) solves this by inverting the process: build components first, screens second.
Atomic Design for Mobile
Atomic design, popularized by Brad Frost for the web, maps perfectly onto mobile development.
Atoms — The smallest indivisible UI elements
- Text, Icon, Avatar, Badge, Divider, Spinner
- Have no dependencies on other components
- Handle only visual presentation
Molecules — Combinations of atoms that form a functional unit
- ListItem (Icon + Text + Badge)
- InputField (Label + TextInput + HelperText)
- SearchBar (Icon + TextInput + ClearButton)
Organisms — Complex, standalone UI sections
- Header (Avatar + Title + Menu Button)
- ProductCard (Image + Molecule stack + Button)
- CommentList (Header + multiple ListItems)
Templates — Page-level layouts without real content
- Define the structure and spacing of screens
- No business logic or real data
Screens — Templates filled with real data and behavior
- Connect to state management
- Handle navigation
- Bind to API data
Folder Structure
text1src/ 2├── components/ 3│ ├── atoms/ 4│ │ ├── Text/ 5│ │ │ ├── Text.tsx 6│ │ │ ├── Text.test.tsx 7│ │ │ └── index.ts 8│ │ ├── Icon/ 9│ │ ├── Avatar/ 10│ │ ├── Badge/ 11│ │ └── Spinner/ 12│ │ 13│ ├── molecules/ 14│ │ ├── ListItem/ 15│ │ ├── InputField/ 16│ │ ├── SearchBar/ 17│ │ └── Card/ 18│ │ 19│ ├── organisms/ 20│ │ ├── Header/ 21│ │ ├── ProductCard/ 22│ │ └── CommentList/ 23│ │ 24│ └── templates/ 25│ ├── FeedTemplate/ 26│ └── DetailTemplate/ 27│ 28├── screens/ 29│ ├── HomeScreen.tsx 30│ ├── ProductScreen.tsx 31│ └── ProfileScreen.tsx 32│ 33└── features/ # Business logic, state, API calls 34 ├── products/ 35 └── auth/
Writing a Good Atom
Atoms are the most reused components in your system. Write them to be:
- Flexible — Accept all the props the use cases require
- Typed — Full TypeScript types, no
any - Themed — Colors from the design system, never hardcoded
- Accessible — Labels, roles, and states set correctly
tsx1// atoms/Badge/Badge.tsx 2import { View, Text, StyleSheet } from 'react-native'; 3import { useTheme } from '@/hooks/useTheme'; 4 5type BadgeVariant = 'default' | 'success' | 'warning' | 'error' | 'info'; 6type BadgeSize = 'sm' | 'md' | 'lg'; 7 8interface BadgeProps { 9 label: string; 10 variant?: BadgeVariant; 11 size?: BadgeSize; 12 icon?: React.ReactNode; 13} 14 15export function Badge({ 16 label, 17 variant = 'default', 18 size = 'md', 19 icon, 20}: BadgeProps) { 21 const { colors } = useTheme(); 22 23 return ( 24 <View 25 style={[styles.container, styles[size], { backgroundColor: colors.badge[variant].bg }]} 26 accessibilityRole="text" 27 accessibilityLabel={label} 28 > 29 {icon && <View style={styles.icon}>{icon}</View>} 30 <Text style={[styles.label, styles[`label_${size}`], { color: colors.badge[variant].text }]}> 31 {label} 32 </Text> 33 </View> 34 ); 35}
Writing a Good Molecule
Molecules compose atoms. They add behavior but remain context-free (no navigation, no API calls).
tsx1// molecules/ListItem/ListItem.tsx 2interface ListItemProps { 3 title: string; 4 subtitle?: string; 5 leading?: React.ReactNode; 6 trailing?: React.ReactNode; 7 onPress?: () => void; 8 disabled?: boolean; 9 testID?: string; 10} 11 12export function ListItem({ 13 title, 14 subtitle, 15 leading, 16 trailing, 17 onPress, 18 disabled = false, 19 testID, 20}: ListItemProps) { 21 return ( 22 <Pressable 23 onPress={onPress} 24 disabled={disabled} 25 style={({ pressed }) => [styles.container, pressed && styles.pressed, disabled && styles.disabled]} 26 accessibilityRole={onPress ? 'button' : 'text'} 27 accessibilityLabel={subtitle ? `${title}, ${subtitle}` : title} 28 testID={testID} 29 > 30 {leading && <View style={styles.leading}>{leading}</View>} 31 <View style={styles.content}> 32 <Text style={styles.title}>{title}</Text> 33 {subtitle && <Text style={styles.subtitle}>{subtitle}</Text>} 34 </View> 35 {trailing && <View style={styles.trailing}>{trailing}</View>} 36 </Pressable> 37 ); 38}
Key Principles
Keep components stateless — State belongs in screens and feature modules, not atoms or molecules. A Button doesn't know why it's loading; a screen does.
One job per component — A ProductCard should display product data. It should not fetch data, handle navigation, or manage cart state.
Props over config objects — Flat, explicit props are easier to type, document, and test than complex config objects.
Export from index files — Makes imports clean and allows internal refactoring without changing consumers:
typescript1// components/atoms/index.ts 2export { Badge } from './Badge'; 3export { Avatar } from './Avatar'; 4export { Spinner } from './Spinner'; 5 6// Usage anywhere in the app: 7import { Badge, Avatar, Spinner } from '@/components/atoms';
Testing Components in Isolation
The biggest payoff of CDD is testability. Components with no side effects are trivially testable.
tsx1import { render, screen } from '@testing-library/react-native'; 2import { Badge } from '@/components/atoms'; 3 4describe('Badge', () => { 5 it('renders the label', () => { 6 render(<Badge label="New" />); 7 expect(screen.getByText('New')).toBeTruthy(); 8 }); 9 10 it('applies success variant styles', () => { 11 render(<Badge label="Active" variant="success" />); 12 const badge = screen.getByRole('text'); 13 expect(badge.props.style).toContainEqual( 14 expect.objectContaining({ backgroundColor: expect.any(String) }) 15 ); 16 }); 17});
Conclusion
Component-driven development is a mindset shift more than a technical one. The payoff compounds over time: a codebase built this way stays clean as it grows, onboards new developers faster, and makes design changes cheap instead of expensive.
Start with your most-used atoms, build molecules from them, and let screens become what they should be — thin layers that connect your component library to your data.