Creating dynamic height children with Flexbox in React Native

I am relatively new to using Flexbox, Exponent, and React Native, so I'm not entirely sure if I am implementing this correctly. Any assistance you can offer would be greatly appreciated, and I have included a snack below that could serve as a starting point.

On my screen, there is a header at the top that measures 40px in height, and a tab bar at the bottom also measuring 40px tall.

What I envision is a full-width, full-height column between them with rows of content containing charts on the left, and a header (Billing, Budget, Labor) positioned to the right of the chart with varying numbers of data rows below it. These rows consist of a key aligned to the left (Invoiced, Not Invoiced, Total, etc.) and a value aligned to the right (500.00, 250.00, 750.00, etc.).

Since the number of data rows varies (3, 4, 3, etc.), I do not want to manually set the heights of each row for the charts. Additionally, I do not want these rows to expand to the height of the central column but instead provide white space beneath them.

Is there a way to construct this layout so that: 1. Rows do not occupy the full height of the center column and align at the top, leaving empty space below. 2. Charts are aligned to the left next to their respective data. 3. Data values (e.g., 500.00) are right-aligned next to their keys (e.g., Invoiced).

https://i.sstatic.net/9VLbg.png https://i.sstatic.net/BGQ0u.png

Your guidance would be immensely helpful. If possible, including an example using snack.expo.io would be fantastic! The current representation demonstrates how the rows stretch to match the height, resulting in considerable wasted space and no room at the bottom. Moreover, the alignment between the key and values within the data is not ideal, where the key appears on the left while the value is right-aligned.

Answer №1

I made some updates to a few lines, do you think it looks better now? Check it out here:

The use of flex: 1 allows a view to occupy all available space, so if there are two views at the same level in a hierarchy both set with flex: 1, they will evenly split the vertical space between them. For more information, refer to: https://facebook.github.io/react-native/docs/layout-props.html#flex

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why isn't the float left property working as expected?

Why won't my image float to the left? I'm using a class called align-left with float: left but it's not working. You can see the live version at - (check out the review grid halfway down under the heading 'High customer satisfaction r ...

switch control navbar feature in Django

I am currently working on a project and I am attempting to manage the color change of the navbar logo. After visiting the "about" page on my application, I want the navbar to change color, with half of it turning yellow to better complement the purple back ...

Getting field values from Firestore in a React application

Within my firestore document, I have three fields that store boolean values critical for subsequent processing. To access these boolean values in my program, I need to figure out how to read the fields of a document. This process should be straightforward, ...

To add an image, simply click on the designated area instead of using the traditional file input button. The image will then be displayed in the specified image container and resized on the client-side

Objective: I am aiming to enhance the image upload functionality by enabling users to click on an <img> element to initiate the file selection process, instead of using the traditional <input type="file"> button. There will be three placeholde ...

What is the best way to align an element based on the position of another element?

I have integrated a calendar icon above a fullcalendar, and when I click on the icon, a react-datepicker pops up. Here is my CSS : .react-datepicker { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 0.8rem; background-color: ...

Using Angular to Bind Checkbox Value in Typescript

I have a challenge of creating a quiz where a card is displayed with 4 questions structured like this: <div class="col-md-6"> <div class="option" id="Answer1"> <label class="Answer1"> <input value= "Answer1" type="checkbox ...

How to effectively implement light and dark themes using SCSS colors?

Currently, I am utilizing Vue.js and SCSS along with PrimeVue and Element plus, where I am importing their variables. My objective is to dynamically change the theme color. In my dark-variables.scss file, I have defined various color variables for differe ...

The CSS cubic-bezier fails to smoothly transition back to its initial position

I created an animation that works perfectly when hovering over the target elements, however, it doesn't smoothly transition back to its original position when the cursor moves outside of the target element. Instead, it snaps back abruptly and unattrac ...

Is there a way to utilize the reset() function within an input form?

Is there a way to automatically reset the textbox when submitting a value? Below is my code: <!DOCTYPE html> <html> <body> <ul id="myList"> </ul> <input type="text" id="myText" value="&q ...

Learn how to showcase vertical text in React Native similar to a drawer

Looking for a way to display text vertically in a dynamic manner, where the length of the text can vary. Below are some examples for reference: Example 1 Example 2 <View> <View style={{}}> <View style={{ marginTop: 30, flexDire ...

Issue with QuickSand Script not displaying properly on Internet Explorer 7

My website features an edited version of Quicksand that displays correctly on Chrome, Opera, and Firefox, but runs into CSS issues on IE. Oddly enough, when I was using the static version, the CSS displayed properly even on IE until I added the Quicksand e ...

Guidelines for centering 2 images with JavaScript

I am faced with a unique challenge involving 2 images, where one image has a designated Mask area and the other image is supposed to be visible through the Masked area of the first image. My goal is to align the second image in the center of the Mask area ...

Adding a prefix to the imported CSS file

My React app, created with create-react-app, is designed to be integrated as a "widget" within other websites rather than functioning as a standalone application. To achieve this, I provide website owners with minified JS and CSS files that they can inser ...

Suggestions for arranging nested list items securely?

Hello, I'm new to web design and would greatly appreciate any assistance. I've been learning HTML and CSS through a live project but have run into trouble with positioning nested list items. This is how my web browser renders the page: Here&a ...

Is there a different value for -webkit-filter: brightness() in Safari? Any tips on how to adjust for this

It has come to my attention that Safari prefers the brightness setting for the -webkit-filter to be a percentage, while other browsers use a less straightforward scale. Take note of the difference in brightness changes between Chrome and Safari in the fol ...

Certain computers are experiencing issues with Safari where the sprites background is not resizing correctly

Currently, I am working on a responsive CSS web design project that involves incorporating various sprites for different button states. After testing the website in Firefox, Opera, IE (compatible from IE8), Chrome, and Safari, I have ensured that everythi ...

How can I wrap text in Angular for better readability?

I've created a calendar in my code that displays events for each day. However, some event descriptions are too long and get cut off on the display. Even after attempting to use Word Wrap, I still can't see the full text of these events unless I c ...

Unusual spacing problem detected on iPad device

When I visit my demo site on my iPad, I'm having a strange issue where the player seems to be shifted to the top. This is how it looks on my iPad Mini running iOS 6.1 and tested on both Chrome and Safari: Here is the link to the demo site (change the ...

Arrange the navigation bar in a straight line

I am facing an issue with my navigation bar... I want it to be centered but it is not working. I want it to fill from left to right. I have tried using the following CSS: text-align: center in .navbar a text-align: center in navbar. .navbar { backgr ...

Positioning of the dropdown in Material UI AutoComplete menus

Is there a way to turn off autocomplete auto position? I would like the autocomplete options to always appear at the bottom. Check out this link for more information! ...