View: what it is, container properties and React Native

Author: IT Sectr Published: 2026-07-05 Reading time: 10 min

The View component in React Native is the basic building block of the user interface, an analog of the HTML div element for mobile platforms. View supports nesting at any depth, manages the arrangement of child elements through Flexbox, and handles touch events. According to React Native Docs, 2024, View is the most frequently used component in applications — virtually every screen is built from nested View containers. The component renders into native UIView on iOS and android.view.View on Android, ensuring native performance and accessibility.

Key Takeaways

  • View — the basic React Native container, an analog of HTML div for mobile screens
  • The component supports Flexbox for positioning child elements
  • View renders into native iOS and Android views
  • Supports touch events, gestures, and animations via the Animated API
  • View has no visual representation by default — styles are set through StyleSheet

What is View in React Native

View is a fundamental React Native component that serves as a container for other components. It supports styling through StyleSheet, layout through Flexbox, touch handling, animations, and transformations. View is an abstraction over native container elements: UIView on iOS and android.view.View on Android.

In React Native, it is not possible to use HTML elements — instead, all layouts are built from View. Even Text and Image are usually wrapped in View for positioning. The component can be empty (just a container) or contain any number of child elements at any nesting depth.

View supports rendering on both platforms from a single JavaScript codebase. Flexbox properties, margins, background, shadows, and borders work identically on iOS and Android. Platform differences are minimal — for example, shadows on iOS use shadowColor/shadowOffset, while on Android they use elevation.

According to React Native Layout Docs, 2024, View is optimized for mobile devices: it does not create extra native views during flatten optimization and correctly handles cascading updates when parent styles change.

View Component Properties and API

The View component has a rich set of props for controlling appearance, layout, and interactivity. All props fall into several categories: style props, touch events, accessibility, and platform-specific features. Let’s explore the key groups.

View Style Props

View supports all standard CSS properties for mobile platforms. Key ones include: flexDirection, justifyContent, alignItems for positioning; margin, padding for spacing; backgroundColor, borderRadius for appearance; width, height, maxHeight for sizing.

Touch Events and Gestures

View can handle touch events through the onStartShouldSetResponder, onMoveShouldSetResponder, and onResponderGrant props. These events allow implementing custom gestures without libraries. For standard taps, onTouchStart, onTouchEnd, and onPress (via Pressable or TouchableOpacity) are used.

Platform-Specific Props

On iOS, shadowColor, shadowOffset, shadowOpacity, shadowRadius are available for shadows. On Android, these properties are ignored — instead, elevation is used (a card-like shadow). The onLayout callback is triggered when the View’s dimensions change, which is useful for adaptive layouts.

Layout with View and Flexbox

Flexbox is the only layout mechanism in React Native (unlike the web, where Grid and Float are available). All element positioning is done through Flexbox properties of the View component. By default, View has flexDirection set to column, not row as on the web, which matches the vertical orientation of mobile screens.

Key Flexbox Properties in View

flexDirection determines the main axis direction: column (default) or row. justifyContent controls distribution along the main axis (flex-start, center, space-between). alignItems — along the cross axis (stretch — default value). flex specifies the proportion of available space for a child element.

js
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

const CardLayout = () => (
    <View style={styles.card}>
        <View style={styles.row}>
            <View style={styles.avatar} />
            <View style={styles.content}>
                <Text style={styles.name}>John Doe</Text>
                <Text style={styles.role}>Developer</Text>
            </View>
        </View>
    </View>
);

The example shows a typical structure: an outer View — card, an inner row — a row with an avatar and text block, content — a column with name and role. This nested View structure is the standard for any React Native screen.

Differences Between View and HTML div

Although View is conceptually similar to HTML div, there are key differences that are important to understand when porting code from the web to React Native. These differences relate to rendering, styles, and default behavior.

CharacteristicView (React Native)div (HTML)
Default flexDirectioncolumnrow (in block context)
width/heightDefaults to 100% of parentauto based on content
ScrollingNot supported (ScrollView required)overflow: auto/scroll
ShadowsiOS: shadow*, Android: elevationbox-shadow
Event HandlingResponder systemDOM Events
Native RenderingUIView / android.view.ViewDOM element

The most important difference is flexDirection: column by default. This means that without explicit configuration, child elements are arranged vertically, not horizontally. The second difference: View width and height by default stretch to fill all available parent space (analogous to width: 100% in CSS).

Practical Examples with View

Let’s look at two real-world examples of using View in React Native applications: centering content across the full screen and creating a responsive card grid. Both patterns appear in every project.

Example 1: Full-Screen Centering Placeholder

To create an empty state, a View with flex: 1 and centering on both axes is used. This is a standard pattern for loading screens, error states, and empty lists.

js
const EmptyState = ({ message }) => (
    <View style={styles.container}>
        <Text style={styles.icon}>{icon}</Text>
        <Text style={styles.message}>{message}</Text>
    </View>
);

const styles = StyleSheet.create({
    container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
    icon: { fontSize: 48 },
    message: { fontSize: 16, color: '#666', marginTop: 16 },
});

The combination of justifyContent: center and alignItems: center in a View with flex: 1 centers the content on both axes across the full screen. This is the most common pattern of using View in React Native.

Example 2: Card Grid with Flexbox

To display two columns of products or articles, a View with flexDirection: row, flexWrap: wrap and child Views with fixed width is used. This pattern replaces CSS Grid in React Native.

js
const ProductGrid = ({ products }) => (
    <View style={styles.grid}>
        {products.map((product) => (
            <View key={product.id} style={styles.card}>
                <Image source={{ uri: product.image }} />
                <Text>{product.name}</Text>
            </View>
        ))}
    </View>
);

const styles = StyleSheet.create({
    grid: {
        flexDirection: 'row',
        flexWrap: 'wrap',
        justifyContent: 'space-between',
    },
    card: { width: '48%', marginBottom: 16 },
});

In this example, the outer View with flexWrap: wrap works as an analog of CSS Grid. Each card takes up 48% of the width, leaving gaps between columns. This is a typical pattern for catalogs and content feeds.

Frequently Asked Questions

How is View in React Native different from div?

View has flexDirection: column by default (not row like a flex container in HTML), does not support scrolling, width by default stretches to 100% of the parent, and shadows are set through shadow* properties on iOS and elevation on Android.

Can View be clickable?

Yes, View supports touch event handling through onTouchStart, onTouchEnd, and the Responder system. However, for buttons it is better to use TouchableOpacity, Pressable, or Button — they provide visual feedback and comply with the Accessibility API.

Do I need to use View for every element?

Not necessarily. React Native optimizes rendering through View flattening — extra Views without styles and events are removed from the native tree. However, for code readability, it is better to use View as containers for logical interface blocks.

How to make a circular View?

Set borderRadius equal to half the width and height (e.g., width: 50, height: 50, borderRadius: 25). If width and height are set to the same value, the View becomes a circle. This is the standard pattern for avatars.

How to make a View transparent?

Set opacity from 0 to 1 (e.g., opacity: 0.5). You can also use backgroundColor with RGBA (backgroundColor: ‘rgba(0,0,0,0.5)’). The difference is that opacity applies to the entire container and its contents, while RGBA applies only to the background.

Summary

  • View — the basic React Native container, an analog of HTML div for building interfaces
  • The component supports Flexbox with flexDirection: column by default
  • View renders into native UIView (iOS) and android.view.View (Android)
  • Key props: Flexbox style properties, touch events through the Responder system, onLayout for dimensions
  • View flattening automatically removes extra containers from the native tree
  • For buttons, use TouchableOpacity or Pressable instead of View with onTouch
  • Nested Views are the standard architecture of any screen in a React Native application

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also