The accordion's height will expand on its own when one of the accordions in the same row is

Whenever an accordion expands in the same row in MUI, the height of the accordion will automatically increase. See below for the code snippet:

{[1,2,3,4,5].map((i)=>
                                <Accordion style={{backgroundColor: '#F9F9F9', borderRadius: 8, width: '45%', margin: '5px 0px'}}>
                                    <AccordionSummary
                                        expandIcon={<ExpandMoreIcon style={{borderRadius: 100, backgroundColor: '#F3F3F3'}}/>}
                                        aria-controls={`panel${i}a-content`}
                                        id={`panel${i}a-header`}
                                    >
                                    <Typography variant='body2' style={{fontSize: 13, color: '#3A3A3A', textAlign: 'justify', fontWeight: 400}}>
                                        Are the Pack Benefits really free?
                                    </Typography>
                                    </AccordionSummary>
                                    <AccordionDetails style={{ backgroundColor: 'white'}}>
                                    <Typography variant='body2' style={{fontSize: 12, color: '#21212185', textAlign: 'justify'}}>
                                        Yes! Choose any energy plan and enjoy the benefits. 
                                    </Typography>
                                    </AccordionDetails>
                                </Accordion>
                            )}

Answer №1

In order to avoid this problem, it is recommended to enclose each Accordion component within a element like so:

<div>
  <Accordion>
  </Accordion>
</div>

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 feasible to display Material components inside a material-table?

Currently, I am in the process of developing a data display feature for my application and have been exploring various data table components that are constructed using Material UI. One question that has arisen is whether it is feasible to incorporate Mater ...

Encountering a syntax error while utilizing a JavaScript variable in a jQuery selector for a lightbox feature

I'm currently working on creating a lightbox feature and have reached the stage where I am implementing next and previous buttons to navigate through images. I am utilizing console.log to check if the correct href is being retrieved when the next butt ...

No server needed reCAPTCHA

I have successfully integrated reCAPTCHA into a Contact form on my website, which includes three fields: name, email, and message. The data from this form is stored in Firebase for easy access. This implementation was done using React, with the help of th ...

I have the ability to effectively open a modal whenever necessary, but I struggle with closing it afterwards

I've been working on implementing a React bootstrap modal, and while I can successfully open it when needed, I'm running into issues with closing it. I'm not sure what mistake I might be making. Here's my markup: <Modal show={this. ...

I attempted to mock a standalone class method using jest.spyOn, but unexpectedly the real method was executed instead of the mock implementation

Programming Class //Class Definition class User { constructor(){ } getUserData(){ //performs an action without returning anything } } When a button is clicked within a react component, this method gets executed //ReactComponent.tsx handleButtonClick() { ...

Having trouble with the functionality of the cascading menu?

I am having trouble with a drop-down menu. The first level works fine, but I can't seem to get the second level of the menu to display. Appreciate any help you can offer. Thank you. javascript <script type="text/javascript"> $(document).ready( ...

Display or conceal certain HTML form elements based on the selection made in the previous form element

I need assistance with a function that can dynamically show or hide certain HTML form elements based on the user's previous selection using JavaScript. For example, if a user selects "Bleached" from the Dyingtype drop-down menu, there is no need to di ...

Encountered an error trying to access the length property of an undefined variable while passing props

I need help with my shopping app project. I am trying to create a feature where if the cart is empty, it should display a message saying "shopping cart is empty." However, when I try to implement this, I keep getting a type error that says "Cannot read p ...

Using Bootstrap 4, create a responsive design that centers images within a div on mobile devices and positions them differently

I am currently working on a DIV that contains social media buttons. The code for this DIV is as follows: <div class="redes-sociales col-sm-pull-6 col-md-6 col-lg-push-4 float-right py-2"> <img class="img-rounded img-social" alt="f ...

Restore font-weight if a different list item is chosen

I previously inquired about setting the font-weight to bold on a text element when selected. Thanks to @Eric, this has been successfully implemented! However, I am facing an issue where clicking on one text makes it bold, and then clicking on another text ...

Creating a Responsive Bootstrap Webpage

I attempted to replicate a sign-in page using Bootstrap from this link: Prior to this, I had already created a page without using Bootstrap code. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Mainpage.aspx.cs" Inherits="project.Mainpage" ...

How to Keep MUI Draggable Dialog Within Screen Boundaries in React

Currently, I am utilizing the MUI library and focusing on the Draggable Dialog component available here. My main inquiry revolves around how to restrict the dialog from being dragged beyond the screen boundaries. Even after attempting to implement the fo ...

What is the best way to wait for the state to be set before mapping the array

I have some data stored in an array (shown in the screenshot below) that I am trying to map, but I am facing issues accessing it as it is loaded asynchronously. How can I await the data? Is there a way to achieve this within the render function? render() ...

Tips on receiving feedback from an express server regarding an error by utilizing axios within a react application

Currently, I am working with react and express. In my react application, I am trying to utilize axios.post to send user credentials to the express server in hopes of receiving a response. Once I receive the response, my goal is to extract the message and s ...

How does React retain and display the previous values even after they have been updated?

https://codesandbox.io/s/objective-night-tln1w?file=/src/App.js After updating the data in the dropdown, the console displays the correct values. However, the dropdown itself continues to show the previous values. It seems that there may be an error relat ...

An error has occurred in React with a nested JSON object, suggesting that it may actually

I encountered an interesting error with my React file using Axios. While the data retrieval from my post works fine, I am facing a problem when trying to display all posts on one page. Despite my efforts to find a solution, I have not been successful. Bel ...

Creating responsive tabs that transition into a drop-down menu for mobile devices is a useful feature for

I am looking to create a responsive tab design that drops down like the example shown below: Desktop/Large Screen View https://i.stack.imgur.com/hiCYz.png Mobile View https://i.stack.imgur.com/gRxLv.png I have written some code for this, but I am unsure ...

When attempting to create a new portal in Next.js, an issue arises with the undefined document

For my project, I have structured the sections by placing the menu in a header tag, content in a main tag, and contact information in a footer tag within the _document.js file. However, when attempting to create a new portal, I encountered an error stating ...

Having trouble with obtaining precise mouseup and mousedown coordinates

Currently, I am working with react and typescript for my project. I have implemented a canvas element where I am attempting to draw a rectangle based on mouseup and mousedown events. However, the issue I am facing is that the rectangles are being drawn in ...

Using React Material UI to pass parameters to withStyles in the withStyle object

Utilizing the mui withstyle method, I am attempting to customize a radio button by passing a color as a parameter. I aim to incorporate this color in the style object, similar to the example below. Is there a feasible approach to achieving this task? Pres ...