The Wayback Machine - https://web.archive.org/web/20241126223120/https://www.geeksforgeeks.org/react-native-height/
Open In App

React Native Height

Last Updated : 26 May, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The following approach covers how to set Height in react-native. For this, we are going to use Height property. It basically provides a particular height to a given component.

Syntax:

height : value

Now let’s start with the implementation:

  • Step 1: Open your terminal and install expo-cli by the following command.

    npm install -g expo-cli
  • Step 2: Now create a project by the following command.

    expo init myapp
  • Step 3: Now go into your project folder i.e. myapp

    cd myapp

Project Structure: It will look like the following.

Example: Now let’s implement the Height. Here we are going to provide different heights to different text views.

App.js

App.js




import React from 'react';
import { StyleSheet, View , Text } from 'react-native';
export default function App() {
  
  return (
    <View style={{marginTop : 25}}>
      <View style={{height : 100 , backgroundColor : "red"  , 
      alignItems : 'center'}}>
        <Text>Height 100</Text>
      </View>
      <View style={{height : 200 , backgroundColor : "green"  , 
      alignItems : 'center'}}>
        <Text>Height 200</Text>
      </View>
      <View style={{height : 300 , backgroundColor : "yellow"  , 
      alignItems : 'center'}}>
        <Text>Height 300</Text>
      </View>
    </View>
  );
}


Start the server by using the following command.

npm run android

Output: If your emulator did not open automatically then you need to do it manually. First, go to your android studio and run the emulator. Now start the server again.

Reference: https://reactnative.dev/docs/height-and-width



Previous Article
Next Article

Similar Reads

Create an Activity Indicator in react-native using react-native-paper library
React Native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UIs for both platforms. Prerequisites: Basic
2 min read
How to add a divider in react-native using react-native-paper library ?
React native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UI's for both platforms. Prerequisites: Basi
2 min read
How to create Chip in react-native using react-native-paper ?
React native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UI's for both platforms. Prerequisites: Basi
2 min read
How to add a Progress Bar in react-native using react-native-paper library ?
React native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UI's for both platforms. Approach: In this a
3 min read
How to create a button in react-native using react-native-paper library ?
React-native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UI's for both platforms. Prerequisites: Basi
2 min read
Create a Card View in React native using react-native-paper
React Native is a framework developed by Facebook for creating native-style apps for iOS & Android under one common language, JavaScript. Initially, Facebook only developed React Native to support iOS. However, with its recent support of the Android operating system, the library can now render mobile UIs for both platforms. Approach: In this ar
2 min read
How to Get Window Width and Height In React Native ?
In this article, we'll explore two different approaches to obtaining the screen width and height in a React Native application. Scree­n dimensions, including width and height, play a vital role in de­signing user interfaces that adapt se­amlessly to different de­vices and orientations. By understanding these dimensions, deve­lopers empower themselv
3 min read
How to force child div to be 100% of parent div's height without specifying parent's height?
When designing a website, you may want to create a layout where a child div element fills up the height of its parent div element. However, you may not know the exact height of the parent div element and you don't want to specify it. In this article, we will explore different approaches to force a child div element to be 100% of its parent div elem
3 min read
HTML width/height Attribute vs CSS width/height Property
In HTML 5, few elements follow the width and height attributes and maximum elements do not follow this attribute. Like img, iframe, canvas, and svg kind of elements follow the width and height attributes but div, span, article and section type of elements don't follow them.The width and height attributes are affected in img, svg tags, those are wea
3 min read
How to expand floated child div's height to its parent's height in CSS ?
Making the height of the floating child div equal to the height of the parent div is referred to as expanding the height of the floated child div to the height of the parent div. Approach 1: Using the CSS "clearfix" method is the first approach to increase a floated child div's height to match its parent's height. When an element is floated, it is
4 min read
How to Make body height to 100% of the Browser Height ?
As a web developer, you may find yourself in a situation where you want to create a full-screen layout for your website. The way to achieve this is to make the <body> element take up 100% of the height of the browser window. This can be accomplished through the use of CSS. In this article, we will cover the following topics: What is the <b
5 min read
How to Use Routing with React Navigation in React Native ?
Almost every mobile application requires navigating between different screens. React Native provides an elegant and easy-to-use library to add navigation to native applications: react-navigation. It is one of the most popular libraries used for routing and navigating in a React Native application. Transitioning between multiple screens is managed b
4 min read
React vs React Native?
React and React Native, created by Facebook, are popular tools for building user-friendly apps. React is mainly used for web applications, while React Native focuses on mobile apps. They share similar concepts, but each serves a unique purpose. Table of Content React vs React NativeWhat is React ?What is React Native ?Difference between the React a
4 min read
How to decrease input height with floating labels in React-Bootstrap?
React-Bootstrap is a front-end framework that was designed keeping React in mind. Let's learn a little bit about floating labels. Floating labels are the form labels that float over the input fields. For creating floating labels, we wrap <Form.Control> element inside <FloatingLabel>. In this article, we are going to see different ways t
3 min read
How to disable auto height for sliders by using React Bootstrap carousel?
In ReactJS applications, we use Carousel to represent the images in a loop and in an attractive way. In many cases, the images that are added are not of the same height, so the height is been adjusted automatically. As there is no inbuilt functionality to disable the auto height for sliders in React Bootstrap Carousel, we can use different approach
4 min read
How To Set The Height And Width Of Background Image Inline Style In React?
In React, while handling styles dynamically you might encounter setting a background image with specific dimensions using inline styles. While CSS stylesheets are generally preferred for styling, there are cases where inline styles make more sense, such as when you need to apply dynamic values or work within a component-based approach. In this arti
3 min read
Why You Should Choose React Native?
The smartphone app market is ever changing, new apps come every day, and some old ones disappear from our memories, and our phones as well. In this tumultuous ecosystem, developers struggle to keep making apps that will please users, because with each new horizon we conquer, their expectations rise. And so to out-do their previous efforts, develope
4 min read
Android & iOS App development using React Native with Expo
EXPO! How Expo differs from React Native? Should I start my project with Expo? Many questions arise in newbies mind when he/she wants to get a start in the app development journey. But, you are lucky as you have landed in the right place. I will try my best to explain everything in a simple manner. As per official documentation of React Native, it
6 min read
React Native ProgressBarAndroid
In this article, we are going to discuss how to create a Progress Bar for Android applications. We will be using the React Native component ProgressBarAndroid. Syntax: <View> // Other Component <ProgressBarAndroid/> // Other Component <View>ProgressBarAndroid Props: animating: Boolean value which specifies whether to show the prog
2 min read
Difference between React Native and Flutter
In this article, we will discuss two frameworks that have exquisitely maintained and transcended into the top ranks for quite some time now, namely React Native and Flutter. Considering the huge amount of skill, time and money invested in mobile app development, nowadays companies need a faster way of making an app. Also, to code a native app you n
5 min read
Difference between Ionic and React Native
1. Ionic : Ionic is an open-source user interface toolkit for building high-quality mobile apps, desktop apps, and dynamic web apps using web technologies such as HTML, CSS, JavaScript, AngularJS and TypeScript. It allows developers to build hybrid apps and run everywhere and even code be tested using any web browser. It was developed by Max Lynch,
5 min read
How React Native Make Mobile App Development Simpler?
Developed by Facebook, React Native is a framework for building native apps for iOS and Android using JavaScript. So if you know JavaScript, you can use your JavaScript skills to build real native apps for iOS and Android. These apps are truly native, so they are not web apps that look like a mobile app. With React Native, you don't need to know iO
6 min read
How to use Flexbox in React Native ?
Flexbox is used to provide consistency to a layout. It is used to make the layout adaptive to the screen size of the device it is running on. Using flexbox design you can specify that a certain element of layout will span to this fraction of the available space. In React Native, Flexbox is the same as it is for basic CSS. The only difference being
3 min read
Difference Between React Native and Xamarin
Mobile applications are very handy when it comes to using them as our daily driver. Developing an application needs a lot of effort which frameworks reduce it to a greater extent. React Native and Xamarin are two tools that help us in developing mobile apps with ease and reduces the stress for dependencies. Let us Discuss them and see their advanta
3 min read
React Native Debugging
Debugging is very important for building applications and removing errors. A good knowledge of debugging techniques allows for the faster and efficient development of software. Here we are going to discuss a few debugging techniques in React Native. We will be using expo-cli to develop, run and debug our applications which is one of the simplest an
3 min read
React Native View Component
In this article, We are going to see how to create a view component in react-native. For this, we are going to use React Native View component. It’s basically a small container that supports layout with flexbox, style, some touch handling, and accessibility controls. View maps directly to the native view equivalent on whatever platform React Native
6 min read
React Native style Prop
In React Native, we can style our application using JavaScript. All of the core components accept a prop named style. The style names and values usually match how CSS works on the web, except names are written using camel casing. The style prop can be a plain old JavaScript object. We can also pass an array of styles. Syntax: <component_tag styl
2 min read
React Native Width Prop
In React Native if we need to set any dimension of a component is by adding a fixed width and height to style, in this article we will set the width of any component using the width props. Syntax: style={{ width: dimension, height: dimension, }} /> There are three types of dimension width as mentioned below: Fixed Dimensions: All dimensions in R
2 min read
React Native ActivityIndicator Component
In this article, we are going to see how to create an ActivityIndicator in react-native. For this, we are going to use ActivityIndicator component. It is used to display a circular loading indicator. Syntax: <ActivityIndicator /> Props in ActivityIndicator: animating: It will show the indicator if true or hide it if false.color: The foregroun
2 min read
React Native Flexbox flexDirection Property
In this article, We are going to see the Flexbox flexDirection Property in React Native. Flexbox has three main properties. One of them is flexDirection. The flexDirection property is used to determine the alignment of its elements in the horizontal or vertical directions. It established the main axis of the layout. Syntax: flexDirection: 'column|r
2 min read
three90RightbarBannerImg