Slider

CMS slider with dynamic number of slides
Scroll
Scroll
Scroll
Scroll
Scroll

Use cases

Dynamic slide count
You need a slider component that has a dynamic amount of slides based on how many items are in the CMS Collection.
Fixed, high amount of slides
You need a fixed amount of slides, but you reach your 20 Collection List per page limit. Set your fixed slide limit by setting a "Limit" on the Collection List.

How to use it

Paste before </body> tag of the page you're working with.

Copy code
<!-- F'in sweet CMS Library for Webflow -->
<script src="https://cdn.jsdelivr.net/npm/@finsweet/cms-library@1/cms-library.js"></script>

<script>
// immediately/self invoked function. This function executes right away
(function() {
  // create a new Library instance and store it in a variable called "fsSlider"
  var fsSlider = new FsLibrary('.fs-dynamic-feed')  // Class of your hidden CMS collection list

  // run slider on our instance
  fsSlider.slider({
    sliderComponent: '.fs-slider',  // Webflow slider component
    itemsPerSlide: 2  // amount of CMS items to show per Slide
  })
})();
</script>

Code explanation

fsSlider

The variable we created to store our Library instance. The name of the variable can be set to whatever you want.

new FsLibrary

The class of the hidden Collection List that holds our dynamic CMS List.

This is our real feed of data that we want to populate inside the Slider component. This should be hidden on the page.

sliderComponent

The class of the Webflow Slider component that will display our dynamic CMS List. This class is placed on the native Webflow Slider component.

itemsPerSlide

The amount of CMS items that are shown in each slide.

For example, a value of "3" would show CMS items 1, 2, 3 in Slide 1, items 4, 5, 6 in Slide 2.

HTML and class setup

IMPORTANT: This is easy to set up. You must understand how to structure your page for this to work.

2 parts:
1) A native Webflow slider component (sliderComponent)

The outer parent of the native Webflow slider component needs a class. In this example, we call it ~.fs-slider~

2) A hidden CMS Collection List (new FsLibrary)

The CMS Collect List that will hold the dynamic information we want to display in the slider. This will be hidden on the page. In this example, we call it ~.fs-dynamic-feed~

What happens

CMS Library is going create a new ~.fs-slide~ for every item inside of your ~.fs-dynamic-feed~. If you have 50 items inside your ~.fs-dynamic-feed~, there will be 50 ~.fs-slide~ elements created. We will then "copy" ~.fs-slide-content~ and paste it in the ~.fs-slide~ that was created for that item.