Material-UI Collapse

-
Pro Component

Toggle the visibility of content across your project with a few classes and our JavaScript plugins.


Examples

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
import React from "react";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import Collapse from "@material-ui/core/Collapse";
import Box from "@material-ui/core/Box";
import Button from "@material-ui/core/Button";

export default function Example() {
  const [collapseOpen, setCollapseOpen] = React.useState(false);
  return (
    <>
      <Box display="inline-flex" marginRight=".5rem" marginBottom="1rem">
        <Button
          variant="outlined"
          color="primary"
          onClick={() => setCollapseOpen(!collapseOpen)}
        >
          Button outlined
        </Button>
      </Box>
      <Box display="inline-flex" marginRight=".5rem" marginBottom="1rem">
        <Button
          variant="contained"
          color="primary"
          onClick={() => setCollapseOpen(!collapseOpen)}
        >
          Button contained
        </Button>
      </Box>
      <Collapse in={collapseOpen} unmountOnExit>
        <Card>
          <CardContent>
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
            terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
            labore wes anderson cred nesciunt sapiente ea proident.
          </CardContent>
        </Card>
      </Collapse>
    </>
  );
}

Accordion

Collapsible Group Item #1

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

import React from "react";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import CardHeader from "@material-ui/core/CardHeader";
import Collapse from "@material-ui/core/Collapse";

export default function Example() {
  const [collapseOpen, setCollapseOpen] = React.useState(1);
  const subheaderTypographyProps = {
    component: "div",
  };
  return (
    <>
      <Card>
        <CardHeader
          subheader={
            <>
              <a
                href="#mui"
                onClick={(e) => {
                  e.preventDefault();
                  setCollapseOpen(collapseOpen === 1 ? -1 : 1);
                }}
              >
                Collapsible Group Item #1
              </a>
            </>
          }
          subheaderTypographyProps={subheaderTypographyProps}
        ></CardHeader>
        <Collapse in={collapseOpen === 1} unmountOnExit>
          <CardContent>
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
            terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
            labore wes anderson cred nesciunt sapiente ea proident.
          </CardContent>
        </Collapse>
      </Card>
      <Card>
        <CardHeader
          subheader={
            <>
              <a
                href="#mui"
                onClick={(e) => {
                  e.preventDefault();
                  setCollapseOpen(collapseOpen === 2 ? -1 : 2);
                }}
              >
                Collapsible Group Item #2
              </a>
            </>
          }
          subheaderTypographyProps={subheaderTypographyProps}
        ></CardHeader>
        <Collapse in={collapseOpen === 2} unmountOnExit>
          <CardContent>
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
            terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
            labore wes anderson cred nesciunt sapiente ea proident.
          </CardContent>
        </Collapse>
      </Card>
      <Card>
        <CardHeader
          subheader={
            <>
              <a
                href="#mui"
                onClick={(e) => {
                  e.preventDefault();
                  setCollapseOpen(collapseOpen === 3 ? -1 : 3);
                }}
              >
                Collapsible Group Item #3
              </a>
            </>
          }
          subheaderTypographyProps={subheaderTypographyProps}
        ></CardHeader>
        <Collapse in={collapseOpen === 3} unmountOnExit>
          <CardContent>
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus
            terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer
            labore wes anderson cred nesciunt sapiente ea proident.
          </CardContent>
        </Collapse>
      </Card>
    </>
  );
}

Props

If you want to see more examples and properties please check the official Material-UI Documentation.