Components, Props & Styling
Break screens into reusable components, pass data down, and style them consistently with themes and design tokens.
Beginner · about 6 hours · difficulty 2/5
Learn first: React Native with Expo, Material Design 3 (Android)
All four stacks now share the same mental model: UI is a function of state. You describe what the screen should look like for the current data, and the framework updates the real views.
Components
- React Native: function components returning JSX. Flutter:
StatelessWidget/StatefulWidget. Compose:@Composablefunctions. SwiftUI:Viewstructs. - Pass data down as props/parameters and events up as callbacks (
onPress,onTap,onClick). - Keep components small and focused; a
ProductCardshould not know how to fetch products.
Styling
- React Native uses JavaScript objects via
StyleSheet.create, with camelCase properties likebackgroundColorand unitless density-independent numbers. - Flutter, Compose and SwiftUI style through widget properties or modifiers (
.padding(),Modifier.padding()). - Centralise design tokens: colours, spacing scale (4, 8, 12, 16...), font sizes and radii. Reference tokens instead of magic numbers.
Images and fonts
Load local assets and remote images with caching (Expo Image, cached_network_image, Coil, AsyncImage). Provide multiple resolutions for local images and load custom fonts before rendering text.
Good enough to move on: you built a reusable card component used in three places with different data, styled only with tokens.
Key concepts
- Declarative UI: UI as a function of state
- Props down, events up
- Component composition
- Styling APIs per framework
- Design tokens and themes
- Images and image caching
- Custom fonts and icons
Mini project
Build a recipe card component (image, title, cook time, tag chips) and render a grid of six different recipes from an array.
Check yourself
Where should the data a card displays come from, and why should the card not fetch it itself?
Free resources
- React Native: Core components (React Native)
- React Native: Style (React Native)
- Flutter: Building user interfaces (Flutter)