Convert Figma logo to code with AI

metafizzy logoflickity

:leaves: Touch, responsive, flickable carousels

7,516
605
7,516
117

Top Related Projects

7,271

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

28,370

the last carousel you'll ever need

39,523

Most modern mobile touch slider with hardware accelerated transitions

4,828

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.

3,481

Siema - Lightweight and simple carousel in pure JavaScript

Quick Overview

Flickity is a JavaScript library for creating touch-responsive, draggable, and flickable carousels and sliders. It offers a smooth, physics-based animation and supports various features like free scrolling, wraparound, and responsive design.

Pros

  • Smooth, intuitive touch and mouse dragging
  • Responsive and mobile-friendly design
  • Extensive customization options and API
  • Supports various content types (images, videos, HTML)

Cons

  • Relatively large file size compared to simpler slider libraries
  • May have a steeper learning curve for advanced customizations
  • Limited built-in accessibility features
  • Occasional performance issues with large numbers of slides

Code Examples

  1. Basic initialization:
const elem = document.querySelector('.main-carousel');
const flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true
});
  1. Using as a jQuery plugin:
$('.main-carousel').flickity({
  cellAlign: 'left',
  contain: true,
  wrapAround: true
});
  1. Accessing Flickity methods:
const flkty = new Flickity('.main-carousel');
flkty.next();
flkty.select(2);
flkty.resize();

Getting Started

  1. Install Flickity via npm:
npm install flickity
  1. Include Flickity in your HTML:
<link rel="stylesheet" href="node_modules/flickity/css/flickity.css">
<script src="node_modules/flickity/dist/flickity.pkgd.min.js"></script>
  1. Create your HTML structure:
<div class="main-carousel">
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
</div>
  1. Initialize Flickity in your JavaScript:
const elem = document.querySelector('.main-carousel');
const flkty = new Flickity(elem, {
  // options
  cellAlign: 'left',
  contain: true
});

Competitor Comparisons

7,271

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

Pros of Glide

  • Lightweight and dependency-free, resulting in smaller bundle size
  • More flexible and customizable with various options and API methods
  • Supports both horizontal and vertical sliding out of the box

Cons of Glide

  • Less extensive documentation compared to Flickity
  • Fewer built-in features like lazy loading or adaptive height
  • May require more manual setup for advanced functionality

Code Comparison

Flickity initialization:

var elem = document.querySelector('.main-carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true
});

Glide initialization:

new Glide('.glide', {
  type: 'carousel',
  startAt: 0,
  perView: 3
}).mount();

Both libraries offer simple initialization, but Glide's API is more concise and allows for easier configuration of multiple options. Flickity's initialization is more verbose but provides a more explicit setup.

Flickity excels in providing a polished, ready-to-use carousel with minimal configuration, while Glide offers more flexibility and customization options for developers who need fine-grained control over their slider implementation.

28,370

the last carousel you'll ever need

Pros of Slick

  • Wider browser support, including older versions of Internet Explorer
  • More extensive customization options and settings
  • Larger community and ecosystem, with numerous plugins and extensions available

Cons of Slick

  • Heavier file size compared to Flickity, which may impact page load times
  • Requires jQuery as a dependency, potentially increasing overhead
  • Less focus on performance optimization and modern web standards

Code Comparison

Slick initialization:

$('.slider').slick({
  slidesToShow: 3,
  slidesToScroll: 1,
  autoplay: true,
  autoplaySpeed: 2000,
});

Flickity initialization:

var elem = document.querySelector('.carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true,
  wrapAround: true
});

Both libraries offer simple initialization, but Slick relies on jQuery while Flickity uses vanilla JavaScript. Slick provides more options in the initial setup, while Flickity focuses on a cleaner API with additional methods for customization.

Flickity generally offers better performance and a more modern approach, making it suitable for projects prioritizing speed and efficiency. Slick, on the other hand, provides broader compatibility and extensive customization options, making it a good choice for projects requiring support for older browsers or complex carousel configurations.

39,523

Most modern mobile touch slider with hardware accelerated transitions

Pros of Swiper

  • More feature-rich with advanced functionality like virtual slides and parallax effects
  • Better support for mobile devices with touch events and responsive breakpoints
  • Larger community and more frequent updates

Cons of Swiper

  • Larger file size and potentially higher performance overhead
  • Steeper learning curve due to more complex API and configuration options
  • May be overkill for simple carousel needs

Code Comparison

Flickity initialization:

var elem = document.querySelector('.main-carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true
});

Swiper initialization:

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

Both libraries offer easy initialization, but Swiper provides more configuration options out of the box. Flickity's API is simpler and more straightforward, while Swiper offers greater flexibility at the cost of complexity. Choose Flickity for simpler carousels with a focus on smooth animations and ease of use. Opt for Swiper when you need advanced features, mobile optimization, and don't mind a slightly steeper learning curve.

4,828

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

Pros of Splide

  • Lightweight and performant, with a smaller file size
  • More flexible and customizable, offering a wider range of options
  • Better support for touch devices and mobile responsiveness

Cons of Splide

  • Less mature community and ecosystem compared to Flickity
  • Fewer built-in features and effects out of the box
  • Steeper learning curve for advanced customizations

Code Comparison

Flickity initialization:

var elem = document.querySelector('.main-carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true
});

Splide initialization:

new Splide('.splide', {
  type: 'loop',
  perPage: 3,
  focus: 'center',
}).mount();

Both libraries offer simple initialization, but Splide provides more options for customization in the initial setup. Flickity's syntax is more straightforward, while Splide's configuration object allows for more detailed control over the slider's behavior.

Splide excels in performance and flexibility, making it a strong choice for developers who need fine-grained control over their sliders. However, Flickity's mature ecosystem and ease of use may be preferable for simpler projects or those requiring quick implementation.

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

Pros of Embla Carousel

  • Lightweight and performant, with a smaller bundle size
  • Supports touch gestures and smooth animations out of the box
  • Highly customizable with a plugin system for extended functionality

Cons of Embla Carousel

  • Less extensive documentation compared to Flickity
  • Fewer built-in features, requiring more custom implementation for advanced use cases
  • Smaller community and ecosystem around the project

Code Comparison

Flickity initialization:

var elem = document.querySelector('.main-carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true
});

Embla Carousel initialization:

import EmblaCarousel from 'embla-carousel'

const embla = EmblaCarousel(document.querySelector('.embla'), {
  loop: false,
  align: 'start'
})

Both carousels offer simple initialization, but Embla Carousel uses a more modern import syntax and a slightly different options structure. Flickity provides more built-in options, while Embla Carousel focuses on core functionality and relies on plugins for advanced features.

3,481

Siema - Lightweight and simple carousel in pure JavaScript

Pros of Siema

  • Lightweight and minimalistic (only 3KB gzipped)
  • No dependencies, pure JavaScript
  • Simple API and easy to customize

Cons of Siema

  • Limited built-in features compared to Flickity
  • Less extensive documentation and examples
  • Smaller community and fewer updates

Code Comparison

Siema initialization:

const mySiema = new Siema({
  selector: '.siema',
  duration: 200,
  easing: 'ease-out',
  perPage: 1,
  startIndex: 0,
  draggable: true,
  multipleDrag: true,
  threshold: 20,
  loop: false,
  rtl: false,
  onInit: () => {},
  onChange: () => {},
});

Flickity initialization:

var elem = document.querySelector('.main-carousel');
var flkty = new Flickity(elem, {
  cellAlign: 'left',
  contain: true,
  wrapAround: false,
  autoPlay: false,
  prevNextButtons: true,
  pageDots: true,
  draggable: true,
  freeScroll: false,
  groupCells: false,
  adaptiveHeight: false,
  percentPosition: true,
  setGallerySize: true,
});

Both libraries offer simple initialization with various options. Flickity provides more built-in features and customization options out of the box, while Siema focuses on a minimalistic approach with core functionality.

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

Flickity

Touch, responsive, flickable carousels

See flickity.metafizzy.co for complete docs and demos.

Install

Download

CDN

Link directly to Flickity files on unpkg.

<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css">
<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>

Package managers

Bower: bower install flickity --save

npm: npm install flickity --save

License

Commercial license

If you want to use Flickity to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Purchase a Flickity Commercial License at flickity.metafizzy.co

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use Flickity under the terms of the GPLv3.

Read more about Flickity's license.

Usage

Flickity works with a container element and a set of child cell elements

<div class="carousel">
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
  ...
</div>

Options

var flky = new Flickity( '.gallery', {
  // options, defaults listed

  accessibility: true,
  // enable keyboard navigation, pressing left & right keys

  adaptiveHeight: false,
  // set carousel height to the selected slide

  autoPlay: false,
  // advances to the next cell
  // if true, default is 3 seconds
  // or set time between advances in milliseconds
  // i.e. `autoPlay: 1000` will advance every 1 second

  cellAlign: 'center',
  // alignment of cells, 'center', 'left', or 'right'
  // or a decimal 0-1, 0 is beginning (left) of container, 1 is end (right)

  cellSelector: undefined,
  // specify selector for cell elements

  contain: false,
  // will contain cells to container
  // so no excess scroll at beginning or end
  // has no effect if wrapAround is enabled

  draggable: '>1',
  // enables dragging & flicking
  // if at least 2 cells

  dragThreshold: 3,
  // number of pixels a user must scroll horizontally to start dragging
  // increase to allow more room for vertical scroll for touch devices

  freeScroll: false,
  // enables content to be freely scrolled and flicked
  // without aligning cells

  friction: 0.2,
  // smaller number = easier to flick farther

  groupCells: false,
  // group cells together in slides

  initialIndex: 0,
  // zero-based index of the initial selected cell

  lazyLoad: true,
  // enable lazy-loading images
  // set img data-flickity-lazyload="src.jpg"
  // set to number to load images adjacent cells

  percentPosition: true,
  // sets positioning in percent values, rather than pixels
  // Enable if items have percent widths
  // Disable if items have pixel widths, like images

  prevNextButtons: true,
  // creates and enables buttons to click to previous & next cells

  pageDots: true,
  // create and enable page dots

  resize: true,
  // listens to window resize events to adjust size & positions

  rightToLeft: false,
  // enables right-to-left layout

  setGallerySize: true,
  // sets the height of gallery
  // disable if gallery already has height set with CSS

  watchCSS: false,
  // watches the content of :after of the element
  // activates if #element:after { content: 'flickity' }

  wrapAround: false
  // at end of cells, wraps-around to first for infinite scrolling

});

By Metafizzy 🌈🐻

NPM DownloadsLast 30 Days