How to Create Side-by-Side Views in React Native (Using flexDirection)

TL;DR
To place components side-by-side in React Native, wrap them in a parent View with `flexDirection: 'row'`. This layout trick is foundational for building headers, cards, and profile sections. If you’re new to flexbox, check out [Flexbox Froggy](https://flexboxfroggy.com) for an interactive way to learn it.

Why Side-by-Side Layouts Matter

  • Most real-world mobile UIs include rows — avatars and usernames, input fields and icons, or columns of content. Mastering horizontal layout is a must.
  • React Native uses a flexbox-based layout system, with 'column' as the default flexDirection.
  • To align components side-by-side, you need to change the parent container's flexDirection to 'row'.

How flexDirection Works

  • By default, Views stack vertically because flexDirection defaults to 'column'.
  • To change that to a horizontal layout, apply flexDirection: 'row' on the parent View.
  • Children Views inside the parent will now appear side-by-side, left to right.
  • Need help mastering flexbox? Try learning it visually with Flexbox Froggy — it's a fun game that teaches you how justifyContent and alignItems actually work.

Code Example: Side-by-Side Boxes

SideBySideViews.tsx
import React from 'react';
import { View, StyleSheet } from 'react-native';

export const SideBySideViews = () => {
  return (
    <View style={styles.container}>
      <View style={styles.boxA} />
      <View style={styles.boxB} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    padding: 20,
  },
  boxA: {
    width: 100,
    height: 100,
    backgroundColor: 'tomato',
  },
  boxB: {
    width: 100,
    height: 100,
    backgroundColor: 'skyblue',
  },
});
  • Here’s a simple example showing two boxes displayed side-by-side using flexDirection: 'row'.

Tips for Real Apps

  • Use justifyContent and alignItems for spacing and alignment inside the row.
  • Test responsiveness on different screen sizes — avoid fixed widths unless needed.
  • Give each View meaningful style names (e.g., avatarContainer, textColumn) for better code clarity.

Key Takeaways

  • Use flexDirection: 'row' on the parent View to align child components horizontally.
  • Combine with justifyContent and alignItems to control layout spacing and alignment.
  • Flexbox layouts are powerful — learn once and use across mobile and web (React, CSS).

Hey! If you're enjoying this content, I write regularly about building apps with React Native, Expo, Firebase, and modern frontend tools.
👉 Join my newsletter here

I'm Matt — a Senior React Native developer with 6+ years of experience. I've shipped over 30 web and mobile apps, led dev teams, and specialize in launching MVPs fast using tools like Expo, TypeScript, Firebase, and AI. Whether it's B2B SaaS, marketplaces, or social platforms, I've probably built something like it.

Have a Product in Mind?

We help founders and small teams turn product ideas into working apps. Send us a message—we’d love to hear what you're building.