What is the best method for arranging various react components in sync?

I am striving to achieve a specific style.

My current code looks like this:

<Box display="flex" flexDirection="row" alignItems="center" width={1}>
<Box flexGrow="1">
    <Typography variant="h6">
        {subscription.PlanName}
        <Box
            px={1}
            py={0.5}
            color={"primary.contrastText"}
            className={classes.success}
            display="flex"
            alignItems="center"
            justifyContent="space-between"
        >
            {subscription.Status}
        </Box>
    </Typography>
    <Typography variant="caption" component="div">Purchased on: <b>{moment(subscription.StartDate).format("DD-MM-YYYY")}</b></Typography>
    <Typography variant="caption" component="div">Expiring on: <b>{moment(subscription.EndDate).format("DD-MM-YYYY")}</b></Typography>
</Box>
<Box>
    <Button
        variant="outlined"
        color="primary"
        onClick={Actions.openBillingDrawer}>
        UPDATE CREDITS
    </Button>
</Box>
<Box>
    <Button
        variant="contained"
        color="primary"
        onClick={Actions.openBillingDrawer}>
        UPGRADE PLAN
    </Button>

Additionally, I would like a different style for the UPDATE CREDITS button. Please provide the correct button styling for that as well.

Answer №1

While this may not be precisely what you were aiming for, it serves as a solid starting point. Your layout features the correct division of boxes, appropriate sizing of the green box, and an iconButton:

<Box
  display="flex"
  flexDirection="row"
  alignItems="center"
  width={1}
  justifyContent="space-between"
>
  <Box>
    <Box display="flex" alignItems="flex-end" margin="5px 0">
      <Typography variant="h4" style={{ lineHeight: "0.8" }}>
        Basic Plan
      </Typography>
      <Box
        color="primary.contrastText"
        bgcolor="success.main"
        fontSize="8px"
        padding="2px 4px"
        marginLeft="6px"
      >
        ACTIVE
      </Box>
    </Box>
    <Typography variant="caption" component="div" color="textSecondary">
      Purchased on: <b>01-01-2020</b>
    </Typography>
    <Typography variant="caption" component="div" color="textSecondary">
      Expiring on: <b>02-02-2020</b>
    </Typography>
  </Box>
  <Box>
    <Button
      variant="outlined"
      color="primary"
      endIcon={<ArrowDropDownIcon />}
    >
      UPDATE CREDITS
    </Button>
    <Button variant="contained" color="primary">
      UPGRADE PLAN
    </Button>
  </Box>
</Box>

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

Is it possible to create HTML tables without including paragraphs within the cells using docutils rst2html?

If my input rst file looks like this: +--------------------------------+ | Table H1 | +-------------+------------------+ | Table H2a | Table H2b | +=============+==================+ | a1 | b1 | +------ ...

Error: The function 'require(...)' is not a valid function when working with Sequelize in Node.js

I'm just starting out in web development and I'm attempting to build a Full Stack project using Mysql Express React Node.js. However, I've encountered a TypeError issue when using Sequelize with Node.js. Being new to this, I'm having tr ...

When attempting to download a PDF file from Flask to the client, the file appears to be

I am encountering an issue with my Flask server that sends a PDF file using the send_file function. When testing this route on Postman, I am able to view and download the PDF successfully. However, when attempting to download it through my React frontend, ...

I am experiencing an issue with the checkbox in my React app where the state is not updating after it has been

I am currently building a todo app using React, but I'm encountering an issue where nothing happens when I click the checkbox. I've provided my code below: App.js import './App.css'; import React from 'react' import TodoItem ...

Achieving Material-UI functionality in Reactjs without the need for Node.js or NPM

Are there any alternative sources for a minified version of material-ui specifically designed for React? I am considering including the jsx files in html externally, so I'm curious if there are any static or CDN resources available besides the tradit ...

I am encountering a horizontal scroll bar despite setting the width to 100%

I am just starting out as a beginner in web development. I decided to create a webpage to practice my HTML and CSS skills. However, when I set the width of all elements to 100%, I noticed that I am getting a horizontal scroll bar. I have tried troubleshoot ...

Guide on implementing a personalized 'editComponent' feature in material-table

I'm currently integrating 'material-table' into my project. In the 'icon' column, I have icon names that I want to be able to change by selecting them from an external dialog. However, I am encountering issues when trying to update ...

How can one destructure deeply nested props within a constructor in React?

Within my class component, I am encountering an issue with the constructor: constructor(props) { super(props); this.state = { dirty: this.props.form.dirty // error occurs here! }; } The linting tool eslint is indicating an error relate ...

Comparing React's defaultProps to ES6 default parameters in destructuring: the impact on performance

Recently, I encountered a dilemma regarding optimizing React performance in one of my stateless functional components. In this component, I had defined defaultProps with row: false, but I found it inconvenient as the defaultProps were placed at the end of ...

Trouble encountered while setting up CORS in Spring Boot and ReactJS

Having thoroughly reviewed all the MDN documentation on CORS, I am attempting to retrieve resources from a Spring Boot server at localhost:8080 within a ReactJS application at localhost:3000. However, I am not receiving the expected response. Here is the c ...

Looking to reset the autocomplete input in Material-ui following an onChange event? Here's how you can do it!

When using the hooks version of Material UI, I'm running into an issue where I can't clear the autocomplete after an onChange event: // @flow import React, { useRef, useState } from "react"; import "./Autocomplete.scss"; import AutocompleteUI fr ...

Arrangement of images in an array

Here's the scenario I'm facing. https://i.stack.imgur.com/FbAfw.jpg So, I have an array of images that I want to use to create a gallery with a specific layout. I've tried using grid and playing around with :nth-child(even) and :nth-child( ...

React Router V6 - page is not found in browsing history

Currently, I am encountering an issue with react router v6. While on the detail page, if I press the arrow in Chrome to go back to the previous page, it takes me to the page before the previous one. I checked the history by long pressing on the back arrow, ...

React TypeScript: The properties of 'X' are not compatible. 'Y' cannot be assigned to 'Z' type

I am currently working on a React-TypeScript application, specifically creating a component for inputting credit card numbers. My goal is to have the FontAwesome icon inside the input update to reflect the brand image as the user enters their credit card n ...

What could be causing the unexpected behavior of req.query in NEXT.js?

In the latest version of NextJS App Router, I have the following code located in the file app\api\products\route.tsx import { initMongoose } from "@/lib/mongoose"; import Product from "@/models/products"; import { NextApi ...

What is the best way to pass an object as a parameter?

I'm facing an issue passing my lineChart object into the data param. Even though I have defined it and it is returning values, it still shows as undefined. Can someone provide assistance? if(!createdIssueslength ){ return null } else { c ...

What could be the reason for only one of my states being modified when I call my function?

Currently, I have a single state in React.js consisting of two key-value pairs for length validation and character validation: const [validation, setValidationState] = useState({ lengthValidation: "", characterValidation: "", }); These states are e ...

Causing an element to extend beyond its parent element's boundaries

I have implemented Material Design Lite for creating cards on my website. I encountered an issue where the menu I added to the card only displays within the bounds of the card. I would like it to overflow similar to this example () Here is a link to my fi ...

What could be causing the alignment issue with this html photo gallery?

Struggling to center a photo library on my webpage is really frustrating me. Does anyone have any tips? I've experimented with different ways to center it in the code, but nothing seems to do the trick :/ HTML: <div style="display: inline-block; ...

I currently have some code for a toggle button and a collapse feature, but I'm struggling to integrate the two

I need assistance with implementing a toggle animation I found here: https://codepen.io/7harrypotterrr/pen/OrBwPY. I'm unsure how to apply it to my code and replace the current toggle button that is in use here: https://codepen.io/7harrypotterrr/pen/e ...