Currently, my code looks like this.
HTML
return (
<Card {...props} className={` ${classes.root} ${rootClassName}`} onClick={onClick}>
{children}
<div className={classes.box}>
<ul>
{props.pizzas?.toppings?.map((topping) => (
<li key={topping.id} className={classes.list}>{topping.name}</li>
))}
</ul>
</div>
</Card>
);
CSS
const useStyles = makeStyles((theme: Theme) => ({
root: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
textAlign: 'center',
padding: theme.spacing(2, 2, 2),
height: theme.typography.pxToRem(500),
'&:hover': {
cursor: 'pointer',
},
},
box: {
height: '300px',
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
},
list: {
flex: '0 0 70px',
}
}));
My list looks like the below picture. I want the list to wrap if there is space without overlapping each other, and if there is space at the bottom which there is right now to stack together if there are more toppings.
Thanks!
display in a horizontal row](https://stackoverflow.com/questions/885691/how-to-make-a-ul-display-in-a-horizontal-row)
– Ronnie Royston Oct 25 '22 at 04:25