I attempted to showcase cards within a mapping loop while also utilizing the Grid in this manner.
<div className={classes.root}>
{data.tableData.childRows.map((el: any, idx: number) => {
return (
<Grid
container
spacing={2}
direction="row"
justify="flex-start"
alignItems="flex-start"
>
<Grid item xs={3}>
<Card className={classes.root} variant="outlined">
<CardContent>
<Typography color="textPrimary" gutterBottom>
Name: {data.name}
</Typography>
<Typography color="textPrimary">
Email: {data.email}
</Typography>
<Typography color="textPrimary">
Gateway: {el.gateway}
</Typography>
<Typography color="textPrimary">
ID: {el.id}
</Typography>
<Typography color="textPrimary">
Created: {el.creationDate}
</Typography>
</CardContent>
<CardActions>
<Button
size="small"
onClick={() => {
alert("button clicked" + data.email);
}}
>
Action
</Button>
</CardActions>
</Card>
</Grid>
</Grid></pre></pre>
<p>The styling I have implemented is as follows:</p>
<pre><code> const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
padding: theme.spacing(2),
},
}));
const classes = useStyles();
However, the cards are currently displayed stacked on top of each other and aligned to the left. Is there a way for me to evenly space the cards in a row?