title: React Material UI Card Content expand
body: <p>I am trying to place 3 different expandable cards on my site using React &amp; Material UI. However I am having difficulties in figuring out how to make each card expand on its own? Currently they all expand when I click on either of the three expand buttons. Any help appreciated. Thanks, Kati</p>
  <p>My code is:</p>
  <pre><code>import React from 'react';
  import { makeStyles } from '@material-ui/core/styles';
  import clsx from 'clsx';
  import Card from '@material-ui/core/Card';
  import CardContent from '@material-ui/core/CardContent';
  import CardActions from '@material-ui/core/CardActions';
  import Collapse from '@material-ui/core/Collapse';
  import IconButton from '@material-ui/core/IconButton';
  import Typography from '@material-ui/core/Typography';
  import FavoriteIcon from '@material-ui/icons/Favorite';
  import ShareIcon from '@material-ui/icons/Share';
  import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
  
  const useStyles = makeStyles((theme) =&gt; ({
    expand: {
      transform: 'rotate(0deg)',
      marginLeft: 'auto',
      transition: theme.transitions.create('transform', {
        duration: theme.transitions.duration.shortest,
      }),
    },
    expandOpen: {
      transform: 'rotate(180deg)',
    }
  }));
  
  const IconBoxes = () =&gt; {
    const classes = useStyles();
    const [expanded, setExpanded] = React.useState(false);
  
    const handleExpandClick = () =&gt; {
      setExpanded(!expanded);
    };
  
    return (
      &lt;Card className=&quot;section section-icons grey lighten-4 center&quot;&gt;
       &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;row&quot;&gt;
        &lt;div className=&quot;col s12 m4&quot;&gt;
            &lt;div className=&quot;card-panel&quot;&gt;
              &lt;i className=&quot;material-icons large teal-text&quot;&gt;room&lt;/i&gt;
              &lt;h4&gt;Pick Where&lt;/h4&gt;
              &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                Corporis, nostrum!&lt;/p&gt;
        &lt;CardActions disableSpacing&gt;
          &lt;IconButton aria-label=&quot;add to favorites&quot;&gt;
            &lt;FavoriteIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton aria-label=&quot;share&quot;&gt;
            &lt;ShareIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton
            className={clsx(classes.expand, {
              [classes.expandOpen]: expanded,
            })}
            onClick={handleExpandClick}
            aria-expanded={expanded}
            aria-label=&quot;show more&quot;
          &gt;
            &lt;ExpandMoreIcon /&gt;
          &lt;/IconButton&gt;
        &lt;/CardActions&gt;
        &lt;Collapse in={expanded} timeout=&quot;auto&quot; unmountOnExit&gt;
          &lt;CardContent&gt;
            &lt;Typography paragraph&gt;Method:&lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10
              minutes.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high
              heat. Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly
              browned, 6 to 8 minutes. Transfer shrimp to a large plate and set aside, leaving chicken
              and chorizo in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, salt and
              pepper, and cook, stirring often until thickened and fragrant, about 10 minutes. Add
              saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Add rice and stir very gently to distribute. Top with artichokes and peppers, and cook
              without stirring, until most of the liquid is absorbed, 15 to 18 minutes. Reduce heat to
              medium-low, add reserved shrimp and mussels, tucking them down into the rice, and cook
              again without stirring, until mussels have opened and rice is just tender, 5 to 7
              minutes more. (Discard any mussels that don’t open.)
            &lt;/Typography&gt;
            &lt;Typography&gt;
              Set aside off of the heat to let rest for 10 minutes, and then serve.
            &lt;/Typography&gt;
          &lt;/CardContent&gt;
        &lt;/Collapse&gt;
        &lt;/div&gt;
        &lt;/div&gt;
        &lt;div className=&quot;col s12 m4&quot;&gt;
            &lt;div className=&quot;card-panel&quot;&gt;
              &lt;i className=&quot;material-icons large teal-text&quot;&gt;store&lt;/i&gt;
              &lt;h4&gt;Travel Shop&lt;/h4&gt;
              &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                Corporis, nostrum!&lt;/p&gt;
        &lt;CardActions disableSpacing&gt;
          &lt;IconButton aria-label=&quot;add to favorites&quot;&gt;
            &lt;FavoriteIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton aria-label=&quot;share&quot;&gt;
            &lt;ShareIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton
            className={clsx(classes.expand, {
              [classes.expandOpen]: expanded,
            })}
            onClick={handleExpandClick}
            aria-expanded={expanded}
            aria-label=&quot;show more&quot;
          &gt;
            &lt;ExpandMoreIcon /&gt;
          &lt;/IconButton&gt;
        &lt;/CardActions&gt;
        &lt;Collapse in={expanded} timeout=&quot;auto&quot; unmountOnExit&gt;
          &lt;CardContent&gt;
            &lt;Typography paragraph&gt;Method:&lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10
              minutes.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high
              heat. Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly
              browned, 6 to 8 minutes. Transfer shrimp to a large plate and set aside, leaving chicken
              and chorizo in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, salt and
              pepper, and cook, stirring often until thickened and fragrant, about 10 minutes. Add
              saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Add rice and stir very gently to distribute. Top with artichokes and peppers, and cook
              without stirring, until most of the liquid is absorbed, 15 to 18 minutes. Reduce heat to
              medium-low, add reserved shrimp and mussels, tucking them down into the rice, and cook
              again without stirring, until mussels have opened and rice is just tender, 5 to 7
              minutes more. (Discard any mussels that don’t open.)
            &lt;/Typography&gt;
            &lt;Typography&gt;
              Set aside off of the heat to let rest for 10 minutes, and then serve.
            &lt;/Typography&gt;
          &lt;/CardContent&gt;
        &lt;/Collapse&gt;
        &lt;/div&gt;
        &lt;/div&gt;
        &lt;div className=&quot;col s12 m4&quot;&gt;
            &lt;div className=&quot;card-panel&quot;&gt;
              &lt;i className=&quot;material-icons large teal-text&quot;&gt;airplanemode_active&lt;/i&gt;
              &lt;h4&gt;Fly Cheap&lt;/h4&gt;
              &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                Corporis, nostrum!&lt;/p&gt;
        &lt;CardActions disableSpacing&gt;
          &lt;IconButton aria-label=&quot;add to favorites&quot;&gt;
            &lt;FavoriteIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton aria-label=&quot;share&quot;&gt;
            &lt;ShareIcon /&gt;
          &lt;/IconButton&gt;
          &lt;IconButton
            className={clsx(classes.expand, {
              [classes.expandOpen]: expanded,
            })}
            onClick={handleExpandClick}
            aria-expanded={expanded}
            aria-label=&quot;show more&quot;
          &gt;
            &lt;ExpandMoreIcon /&gt;
          &lt;/IconButton&gt;
        &lt;/CardActions&gt;
        &lt;Collapse in={expanded} timeout=&quot;auto&quot; unmountOnExit&gt;
          &lt;CardContent&gt;
            &lt;Typography paragraph&gt;Method:&lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10
              minutes.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high
              heat. Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly
              browned, 6 to 8 minutes. Transfer shrimp to a large plate and set aside, leaving chicken
              and chorizo in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, salt and
              pepper, and cook, stirring often until thickened and fragrant, about 10 minutes. Add
              saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil.
            &lt;/Typography&gt;
            &lt;Typography paragraph&gt;
              Add rice and stir very gently to distribute. Top with artichokes and peppers, and cook
              without stirring, until most of the liquid is absorbed, 15 to 18 minutes. Reduce heat to
              medium-low, add reserved shrimp and mussels, tucking them down into the rice, and cook
              again without stirring, until mussels have opened and rice is just tender, 5 to 7
              minutes more. (Discard any mussels that don’t open.)
            &lt;/Typography&gt;
            &lt;Typography&gt;
              Set aside off of the heat to let rest for 10 minutes, and then serve.
            &lt;/Typography&gt;
          &lt;/CardContent&gt;
        &lt;/Collapse&gt;
        &lt;/div&gt;
        &lt;/div&gt;
        &lt;/div&gt;
       &lt;/div&gt;
      &lt;/Card&gt;
      
    );
  }
  
  export default IconBoxes;
  </code></pre>