Learus / react-material-ui-carousel

A Generic carousel UI component for React using Material UI.
MIT License
550 stars 219 forks source link

show multiple items #229

Open SamehArmouche opened 8 months ago

SamehArmouche commented 8 months ago

Can I show multiple item in Carousel? Actual behaviour image Expected behaviour image

karmatys8 commented 8 months ago

I have achieved this by making a Carousel of Grid containers. Here is the code for 3 items on one slide:

<Carousel>
  {groupedItems.map(itemsArray => (
    <Grid container spacing={2} key={itemsArray.id}>
      {itemsArray.map(item => (
        <Grid item xs={4} key={item.idx}>
          <ItemComponent key={item.id} />
        </Grid>
      ))}
    </Grid>
  ))}
</Carousel>

Note that to use it properly groupedItems should contain arrays with 3 elements each and preferably an id.

BryanLopez35 commented 4 months ago

I have achieved this by making a Carousel of Grid containers. Here is the code for 3 items on one slide:

<Carousel>
  {groupedItems.map(itemsArray => (
    <Grid container spacing={2} key={itemsArray.id}>
      {itemsArray.map(item => (
        <Grid item xs={4} key={item.idx}>
          <ItemComponent key={item.id} />
        </Grid>
      ))}
    </Grid>
  ))}
</Carousel>

Note that to use it properly groupedItems should contain arrays with 3 elements each and preferably an id.

This works for me, thanks a lot!