FormidableLabs / nuka-carousel

Small, fast, and accessibility-first React carousel library with an easily customizable UI and behavior to fit your brand and site.
https://commerce.nearform.com/open-source/nuka-carousel
Other
3.07k stars 595 forks source link

Restore slidesToShow and related props #1065

Closed DominiqueDeJong8 closed 3 months ago

DominiqueDeJong8 commented 4 months ago

Is there an existing issue for this?

Code of Conduct

Feature Request

Would it be possible to restore the slidesToShow prop and everything related to it to v8+ so NukaCarousel can be used to render more than 1 slide at once? This no longer seems to be possible.
melvin-chen commented 3 months ago

Hey @DominiqueDeJong8,

In v8+, we're opting for using min-width and native styling to determine the number of slides to show at a time. In the previous versions, slidesToShow would cause every slide to be a fixed width (e.g., every slide would have to be 25% of the total width if we wanted to have 4 slides). In v8, we're allowing slides to be their own width via the min-width property to account for uniquely sized slides (if you want to highlight the first slide by making it larger) and to make sure it's natively responsive.

TL;DR, with the new API, if you want X slides per screen, you would set a style for the slide component as min-width: [100/X]% (e.g., 4 slides per screen = min-width: 25%; on the slide component).

Here's an example on CodeSandbox with vanilla React and CSS

DominiqueDeJong8 commented 3 months ago

@melvin-chen Thanks for your response, I suppose this approach makes sense I'll implement this way of working in our project.