Convert Figma logo to code with AI

pawelgrzybek logosiema

Siema - Lightweight and simple carousel in pure JavaScript

3,481
411
3,481
63

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.

🎠 A carousel component for Vue.js

Quick Overview

Siema is a lightweight and simple carousel plugin for JavaScript. It's designed to be minimal, with no dependencies, and easy to customize. Siema focuses on providing smooth animations and a responsive design out of the box.

Pros

  • Lightweight and dependency-free
  • Easy to set up and use
  • Smooth animations and responsive design
  • Customizable with various options and methods

Cons

  • Limited built-in features compared to more complex carousel libraries
  • No built-in navigation controls (dots, arrows)
  • May require additional code for advanced functionality
  • Limited browser support for older versions (IE10+)

Code Examples

Basic initialization:

const mySiema = new Siema();

Customized carousel:

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: () => {},
});

Using methods to control the carousel:

// Go to next slide
mySiema.next();

// Go to previous slide
mySiema.prev();

// Go to specific slide
mySiema.goTo(3);

Getting Started

  1. Install Siema:

    npm install siema
    
  2. Import and initialize Siema in your JavaScript file:

    import Siema from 'siema';
    
    const mySiema = new Siema();
    
  3. Add HTML structure for your carousel:

    <div class="siema">
      <div>Slide 1</div>
      <div>Slide 2</div>
      <div>Slide 3</div>
    </div>
    
  4. Optionally, add custom styles or use Siema's methods to control the carousel:

    // Add navigation buttons
    const prev = document.querySelector('.prev');
    const next = document.querySelector('.next');
    
    prev.addEventListener('click', () => mySiema.prev());
    next.addEventListener('click', () => mySiema.next());
    

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

  • More feature-rich with options like autoplay, keyboard navigation, and touch swipe
  • Supports multiple slide types (carousel, slider, slideshow)
  • Extensive documentation and API

Cons of Glide

  • Larger file size due to more features
  • Steeper learning curve for advanced customizations
  • Requires more configuration for simple use cases

Code Comparison

Siema:

const mySiema = new Siema();
document.querySelector('.prev').addEventListener('click', () => mySiema.prev());
document.querySelector('.next').addEventListener('click', () => mySiema.next());

Glide:

new Glide('.glide').mount();
document.querySelector('.prev').addEventListener('click', () => glide.go('<'));
document.querySelector('.next').addEventListener('click', () => glide.go('>'));

Summary

Siema is lightweight and simple, ideal for basic carousel needs. It has a smaller footprint and is easier to implement for straightforward use cases. Glide offers more advanced features and customization options, making it suitable for complex projects requiring extensive functionality. However, this comes at the cost of a larger file size and potentially more complex setup. The choice between the two depends on the specific requirements of your project and the level of control you need over the slider behavior.

28,370

the last carousel you'll ever need

Pros of Slick

  • More feature-rich with extensive customization options
  • Supports responsive breakpoints for different screen sizes
  • Offers a wide variety of animation effects and transitions

Cons of Slick

  • Larger file size and potentially heavier performance impact
  • Requires jQuery as a dependency
  • More complex setup and configuration process

Code Comparison

Siema initialization:

const mySiema = new Siema();

Slick initialization:

$('.your-class').slick({
  setting-name: setting-value
});

Key Differences

Siema is a lightweight, dependency-free carousel library focused on simplicity and performance. It offers a minimal API and is easy to set up, making it ideal for basic carousel needs.

Slick, on the other hand, is a more comprehensive slider solution with numerous features and customization options. It's better suited for complex slider requirements but comes at the cost of increased file size and dependency on jQuery.

Choose Siema for simple, lightweight carousels with minimal setup. Opt for Slick when you need advanced features, responsive designs, and don't mind the additional overhead.

39,523

Most modern mobile touch slider with hardware accelerated transitions

Pros of Swiper

  • More feature-rich with advanced functionality like lazy loading, parallax effects, and virtual slides
  • Extensive documentation and active community support
  • Better suited for complex, production-level projects

Cons of Swiper

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

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: () => {},
});

Swiper initialization:

const swiper = new Swiper('.swiper-container', {
  slidesPerView: 1,
  spaceBetween: 30,
  loop: true,
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

Siema is lightweight and simple, ideal for basic slider needs. Swiper offers more features and customization options but comes with added complexity and larger file size. Choose based on project requirements and complexity.

4,828

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

Pros of Splide

  • More feature-rich with advanced options like lazy loading, autoplay, and touch/mouse drag
  • Better documentation and examples
  • Actively maintained with regular updates

Cons of Splide

  • Larger file size due to more features
  • Steeper learning curve for basic implementations

Code Comparison

Siema:

const mySiema = new Siema();
document.querySelector('.prev').addEventListener('click', () => mySiema.prev());
document.querySelector('.next').addEventListener('click', () => mySiema.next());

Splide:

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

Summary

Splide offers a more comprehensive solution with advanced features and better documentation, making it suitable for complex projects. However, this comes at the cost of a larger file size and potentially more complex setup.

Siema, on the other hand, provides a lightweight and simple solution for basic carousel needs. It's easier to implement for straightforward use cases but lacks advanced features and ongoing maintenance.

Choose Splide for feature-rich, well-supported carousels, and Siema for lightweight, simple implementations.

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

Pros of Embla Carousel

  • More feature-rich, including support for autoplay, loop, and responsive breakpoints
  • Better performance optimization, especially for mobile devices
  • Actively maintained with regular updates and improvements

Cons of Embla Carousel

  • Larger file size and potentially more complex setup compared to Siema
  • Steeper learning curve due to more configuration options
  • May be overkill for simple carousel needs

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: () => {},
});

Embla Carousel initialization:

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

Both carousels offer simple initialization, but Embla Carousel provides more advanced options and features out of the box. Siema's strength lies in its simplicity and lightweight nature, making it ideal for basic carousel needs. Embla Carousel, on the other hand, offers more robust functionality and performance optimizations, suitable for complex carousel implementations.

🎠 A carousel component for Vue.js

Pros of vue-agile

  • Specifically designed for Vue.js, offering seamless integration with Vue components
  • Provides more built-in features like lazy loading and infinite loop
  • Offers responsive breakpoints for different screen sizes

Cons of vue-agile

  • Larger bundle size due to more features and Vue.js dependency
  • Potentially steeper learning curve for developers not familiar with Vue.js
  • Less flexibility for use in non-Vue projects

Code Comparison

vue-agile:

<template>
  <agile>
    <div class="slide">Slide 1</div>
    <div class="slide">Slide 2</div>
    <div class="slide">Slide 3</div>
  </agile>
</template>

Siema:

const mySiema = new Siema();
document.querySelector('.prev').addEventListener('click', () => mySiema.prev());
document.querySelector('.next').addEventListener('click', () => mySiema.next());

vue-agile is tailored for Vue.js applications, offering a component-based approach with more built-in features. Siema, on the other hand, is a lightweight and framework-agnostic carousel that provides more flexibility for use in various project types. The choice between the two depends on the specific project requirements, framework preferences, and desired feature set.

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

Hi. I will be discontinuing active maintenance of Siema. I built it by myself to use on one of my projects. Two years later I consider carousels as an anti-pattern and I would suggest you to find a better UI pattern than carousel for your current project. If you really want to use it, feel free. If you have any questions, please look for the answer in closed issues section. Would you like to contribute or coutinue maintenance of Siema? Fantastic!


Siema - Lightweight and simple carousel with no dependencies

Full docs with examples: https://pawelgrzybek.github.io/siema/.

Siema is a lightweight (only 3kb gzipped) carousel plugin with no dependencies and no styling. As Brad Frost once said "do that shit yourself". It is 100% open source and available on Github. It is free to use on personal and commercial projects. Use it with your favourite module bundler or by manually injecting the script into your project.

Installation

Setup is trivially easy. A little bit of markup...

<div class="siema">
  <div>Hi, I'm slide 1</div>
  <div>Hi, I'm slide 2</div>
  <div>Hi, I'm slide 3</div>
  <div>Hi, I'm slide 4</div>
</div>

If you are using a module bundler like Webpack or Browserify...

yarn add siema
import Siema from 'siema';
new Siema();

...or manually inject the minified script into your website.

<script src="siema.min.js"></script>
<script>
  new Siema();
</script>

Options

Siema comes with a few (optional) settings that you can change by passing an object as an argument. Default values are presented below.

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: () => {},
});

selector (string or DOM element)
The selector to use as a carousel. Siema will use all immediate children of this selector as a slider items. It can be a query string (example) or DOM element (example).

duration (number)
Slide transition duration in milliseconds (example).

easing (string)
It is like a CSS transition-timing-function — describes acceleration curve (example).

perPage (number or object)
The number of slides to be shown. It accepts a number (example) or an object (example) for complex responsive layouts.

startIndex (number)
Index (zero-based) of the starting slide (example).

draggable (boolean)
Use dragging and touch swiping (example).

multipleDrag (boolean)
Allow dragging to move multiple slides.

threshold (number)
Touch and mouse dragging threshold (in px) (example).

loop (boolean)
Loop the slides around (example).

rtl (boolean)
Enables layout for languages written from right to left (like Hebrew or Arabic) (example).

onInit (function)
Runs immediately after initialization (example).

onChange (function)
Runs after slide change (example).

API

As mentioned above, Siema doesn't come with many options - just a few useful methods. Combine it with some very basic JavaScript and voila!

prev(howManySlides = 1, callback)
Go to previous item (example). Optionally slide few items backward by passing howManySlides (number) argument (example). Optional callback (function) available as a third argument (example).

next(howManySlides = 1, callback)
Go to next item (example). Optionally slide few items forward by passing howManySlides (number) argument (example). Optional callback (function) available as a third argument (example).

goTo(index, callback)
Go to item at particular index (number) (example). Optional callback (function) available as a second argument (example).

remove(index, callback)
Remove item at particular index (number) (example). Optional callback (function) available as a second argument (example).

insert(item, index, callback)
Insert new item (DOM element) at specific index (number) (example). Optional callback (function) available as a third argument (example).

prepend(item, callback)
Prepend new item (DOM element) (example). Optional callback (function) available as a second argument (example).

append(item, callback)
Append new item (DOM element) (example). Optional callback (function) available as a second argument (example).

destroy(restoreMarkup = false, callback)
Remove all event listeners on instance (example). Use restoreMarkup to restore the initial markup inside selector (example). Optional callback (function) available as a third argument (example).

currentSlide
Prints current slide index (example).

Browser support

  • IE10
  • Chrome 12
  • Firefox 16
  • Opera 15
  • Safari 5.1
  • Android Browser 4.0
  • iOS Safari 6.0

Extra & Thanks

Siema means 'hello' in Polish. When I play around with some code, I always use random names. That's the whole story behind the name of this one :)

Huge thanks to Jarkko Sibenberg for the cute logo design! I can't thank BrowserStack enough for giving me a free access to their testing amazing service.

NPM DownloadsLast 30 Days