Convert Figma logo to code with AI

rcbyr logokeen-slider

The HTML touch slider carousel with the most native feeling you will get.

4,645
213
4,645
131

Top Related Projects

39,745

Most modern mobile touch slider with hardware accelerated transitions

7,299

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

28,515

the last carousel you'll ever need

4,864

Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.

A lightweight carousel library with fluid motion and great swipe precision.

Quick Overview

Keen Slider is a lightweight, modern, and touch-friendly slider library for creating responsive carousels and sliders in web applications. It's designed to be flexible, performant, and easy to use, with support for various input methods including mouse, touch, and keyboard navigation.

Pros

  • Lightweight and performant with no dependencies
  • Responsive and touch-friendly, works well on mobile devices
  • Highly customizable with a wide range of options and API methods
  • Supports various slider types including infinite loop and multi-slide layouts

Cons

  • Limited built-in styling options, requiring more custom CSS for advanced designs
  • Lacks some advanced features found in more complex slider libraries
  • Documentation could be more comprehensive for complex use cases
  • Smaller community compared to some more established slider libraries

Code Examples

Creating a basic slider:

import KeenSlider from 'keen-slider'

const slider = new KeenSlider('#my-keen-slider')

Adding navigation arrows:

const slider = new KeenSlider('#my-keen-slider', {
  loop: true,
  created: (s) => {
    document.querySelector('.arrow-left').addEventListener('click', () => s.prev())
    document.querySelector('.arrow-right').addEventListener('click', () => s.next())
  }
})

Creating a multi-slide layout:

const slider = new KeenSlider('#my-keen-slider', {
  slides: {
    perView: 3,
    spacing: 15,
  },
})

Getting Started

  1. Install Keen Slider:

    npm install keen-slider
    
  2. Import and initialize in your JavaScript file:

    import KeenSlider from 'keen-slider'
    import 'keen-slider/keen-slider.min.css'
    
    const slider = new KeenSlider('#my-keen-slider')
    
  3. Add the necessary HTML structure:

    <div id="my-keen-slider" class="keen-slider">
      <div class="keen-slider__slide">Slide 1</div>
      <div class="keen-slider__slide">Slide 2</div>
      <div class="keen-slider__slide">Slide 3</div>
    </div>
    

Competitor Comparisons

39,745

Most modern mobile touch slider with hardware accelerated transitions

Pros of Swiper

  • More feature-rich with extensive options and modules
  • Larger community and ecosystem, with better documentation
  • Supports multiple frameworks (React, Vue, Angular, etc.)

Cons of Swiper

  • Larger file size and potentially heavier performance impact
  • More complex API, which can be overwhelming for simple use cases
  • Requires additional CSS file for styling

Code Comparison

Swiper:

const swiper = new Swiper('.swiper-container', {
  slidesPerView: 3,
  spaceBetween: 30,
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
});

Keen Slider:

const slider = new KeenSlider('#my-keen-slider', {
  slidesPerView: 3,
  spacing: 30,
  pagination: true,
});

Both libraries offer similar functionality, but Swiper's API is more verbose and configurable. Keen Slider provides a simpler, more straightforward approach for basic slider needs.

Swiper is better suited for complex, feature-rich sliders with specific requirements, while Keen Slider excels in simplicity and performance for basic to moderate slider implementations. The choice between the two depends on the project's specific needs and complexity.

7,299

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

Pros of Glide

  • More mature project with a larger community and longer history
  • Supports a wider range of browsers, including older versions
  • Offers more built-in events and API methods for advanced customization

Cons of Glide

  • Larger file size, which may impact page load times
  • Less performant for complex animations and transitions
  • Requires more configuration for responsive designs

Code Comparison

Glide initialization:

new Glide('.glide').mount()

Keen Slider initialization:

new KeenSlider('.keen-slider')

Both libraries offer simple initialization, but Keen Slider generally requires less configuration for basic setups. Glide often needs additional options for responsive behavior, while Keen Slider handles this more automatically.

Glide's API tends to be more verbose for custom animations:

glide.on('run.after', function() {
  // Custom animation logic
})

Keen Slider's API is often more concise:

slider.on('slideChanged', (s) => {
  // Custom animation logic
})

Overall, Glide offers more flexibility for complex use cases, while Keen Slider provides a more streamlined experience for common slider implementations.

28,515

the last carousel you'll ever need

Pros of Slick

  • Extensive feature set with numerous options for customization
  • Well-established and widely adopted in the community
  • Supports a variety of content types, including responsive images and videos

Cons of Slick

  • Larger file size and potential performance impact due to jQuery dependency
  • Less modern codebase, which may lead to maintenance challenges
  • Limited touch and mobile support compared to newer alternatives

Code Comparison

Slick initialization:

$('.slider').slick({
  dots: true,
  infinite: true,
  speed: 300,
  slidesToShow: 3
});

Keen Slider initialization:

new KeenSlider("#my-keen-slider", {
  slides: 3,
  loop: true,
  dots: true
})

Key Differences

  • Keen Slider is a more modern, lightweight alternative to Slick
  • Keen Slider is written in TypeScript and doesn't require jQuery
  • Slick offers more built-in features, while Keen Slider focuses on performance and flexibility
  • Keen Slider provides better touch and mobile support out of the box
  • Slick has a larger community and more extensive documentation, but Keen Slider is gaining popularity

Both sliders have their strengths, with Slick offering a comprehensive feature set and Keen Slider providing a more modern, performant solution. The choice between them depends on project requirements and preferences.

4,864

Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.

Pros of Splide

  • More comprehensive documentation and examples
  • Built-in accessibility features
  • Wider range of customization options and extensions

Cons of Splide

  • Larger file size compared to Keen Slider
  • Steeper learning curve for advanced features

Code Comparison

Keen Slider initialization:

new KeenSlider("#my-keen-slider", {
  slides: {
    perView: 3,
    spacing: 15,
  },
})

Splide initialization:

new Splide("#my-splide-slider", {
  perPage: 3,
  gap: "1rem",
}).mount()

Both libraries offer similar basic functionality for creating sliders, with Splide providing more built-in options for customization. Keen Slider's API is generally more concise, while Splide's API offers more granular control over slider behavior.

Splide excels in accessibility and extensive documentation, making it easier for developers to create feature-rich, accessible sliders. However, this comes at the cost of a larger file size and potentially more complex setup for advanced use cases.

Keen Slider, on the other hand, offers a more lightweight solution with a simpler API, which may be preferable for projects where file size is a concern or when a more minimalistic approach is desired.

A lightweight carousel library with fluid motion and great swipe precision.

Pros of Embla Carousel

  • Smaller bundle size, making it more lightweight
  • Better performance, especially for mobile devices
  • More customizable with plugins and options

Cons of Embla Carousel

  • Steeper learning curve due to more complex API
  • Less built-in features, requiring additional setup for some functionalities

Code Comparison

Embla Carousel:

import EmblaCarousel from 'embla-carousel'

const embla = EmblaCarousel(emblaNode, { loop: false })

Keen Slider:

import KeenSlider from 'keen-slider'

new KeenSlider(sliderRef.current, { loop: false })

Both libraries offer similar basic setup, but Embla Carousel provides more advanced options for customization. Keen Slider has a simpler API, making it easier to get started quickly.

Embla Carousel focuses on performance and flexibility, allowing developers to build complex carousels with custom behaviors. It's particularly well-suited for mobile-first projects.

Keen Slider, on the other hand, provides a more straightforward approach with built-in features like touch controls and responsive breakpoints. It's ideal for projects that need a quick and easy carousel implementation.

Ultimately, the choice between these libraries depends on the specific requirements of your project, such as performance needs, desired customization level, and development timeline.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Keen-Slider

Easily create sliders, carousels and much more.


Features

  • Library Agnostic: Works well in JavaScript, TypeScript, React, Vue, Angular, React Native etc.
  • Lightweight: No dependencies, only ~5.5KB gzipped
  • Mobile First: Supports multi touch and is fully responsive
  • Great Performance: Native touch/swipe behavior
  • Compatible: Works in all common browsers, including >= IE 10 and React Native
  • Open Source: Freely available under the MIT license
  • Extensible: Rich but simple API

Getting Started

Used by

Contributing

Please open an issue if you find a bug or need some help. You are also free to create a pull request.

NPM DownloadsLast 30 Days