Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove box shadow of material UI accordion component in react?

I am trying to implement accordion using Material UI.

Here is the code:

      <Accordion>
            <AccordionSummary expandIcon={<ExpandMoreIcon />} aria-controls="panel1a-content" id="panel1a-header">
                <Typography>Accordion 1</Typography>
            </AccordionSummary>
            <AccordionDetails>
                <Typography>Lorem ipsum</Typography>
                <Typography>Lorem ipsum</Typography>
                <Typography>Lorem ipsum</Typography>
            </AccordionDetails>
        </Accordion>

Here is what I get as output

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

As one can see there is a box shadow around the accordion and I want to remove it.
After inspecting the component I was able to find the class responsible for the box shadow.

enter image description here

When I disable the box shadow the shadow around the accordion disappears.
I followed the MUI documentation on how to customize MUI component.

Here is my code:

      <Accordion sx={{ "& .MuiPaper-root-MuiAccordion-root": { boxShadow: "none" } }}>
            <AccordionSummary expandIcon={<ExpandMoreIcon />} aria-controls="panel1a-content" id="panel1a-header">
                <Typography>Accordion 1</Typography>
            </AccordionSummary>
            <AccordionDetails>
                <Typography>Lorem ipsum</Typography>
                <Typography>Lorem ipsum</Typography>
                <Typography>Lorem ipsum</Typography>
            </AccordionDetails>
        </Accordion>

But the changes don’t happen. Please guide me if I am missing something.

>Solution :

Just set elevation prop to zero.

<Accordion elevation={0}>...</Accordion>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading