
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
slick-carousel
Advanced tools
The slick-carousel npm package is a popular and versatile carousel/slider library for creating responsive and customizable carousels in web applications. It offers a wide range of features including autoplay, lazy loading, and various transition effects.
Basic Carousel
This code initializes a basic carousel with default settings. The carousel will automatically cycle through the items.
<script>
$(document).ready(function(){
$('.your-class').slick();
});
</script>
<div class="your-class">
<div>Your content 1</div>
<div>Your content 2</div>
<div>Your content 3</div>
</div>
Autoplay
This code initializes a carousel with autoplay functionality. The carousel will automatically transition to the next slide every 2 seconds.
<script>
$(document).ready(function(){
$('.your-class').slick({
autoplay: true,
autoplaySpeed: 2000
});
});
</script>
<div class="your-class">
<div>Your content 1</div>
<div>Your content 2</div>
<div>Your content 3</div>
</div>
Lazy Loading
This code initializes a carousel with lazy loading enabled. Images will only be loaded when they are about to be displayed.
<script>
$(document).ready(function(){
$('.your-class').slick({
lazyLoad: 'ondemand'
});
});
</script>
<div class="your-class">
<div><img data-lazy="img1.jpg" alt=""></div>
<div><img data-lazy="img2.jpg" alt=""></div>
<div><img data-lazy="img3.jpg" alt=""></div>
</div>
Fade Transition
This code initializes a carousel with a fade transition effect between slides.
<script>
$(document).ready(function(){
$('.your-class').slick({
fade: true
});
});
</script>
<div class="your-class">
<div>Your content 1</div>
<div>Your content 2</div>
<div>Your content 3</div>
</div>
Swiper is a modern touch slider with hardware-accelerated transitions. It offers a wide range of features including vertical sliders, parallax effects, and more. Swiper is known for its performance and flexibility, making it a strong alternative to slick-carousel.
Owl Carousel is a touch-enabled jQuery plugin that allows you to create beautiful responsive carousel sliders. It offers features like autoWidth, autoHeight, and various transition effects. Owl Carousel is easy to use and highly customizable, similar to slick-carousel.
Flickity is a JavaScript library for creating touch, responsive, flickable carousels. It offers features like cell alignment, free scrolling, and wrap-around. Flickity is known for its smooth animations and ease of use, making it a good alternative to slick-carousel.
the last carousel you'll ever need
http://kenwheeler.github.io/slick
CDN hosted slick is a great way to get set up quick:
In your <head>
add:
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/1.3.8/slick.css"/>
Then, before your closing <body>
tag add:
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.slick/1.3.8/slick.min.js"></script>
bower install --save slick.js
Option | Type | Default | Description |
---|---|---|---|
accessibility | boolean | true | Enables tabbing and arrow key navigation |
autoplay | boolean | false | Enables auto play of slides |
autoplaySpeed | int | 3000 | Auto play change interval |
centerMode | boolean | false | Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts. |
centerPadding | string | '50px' | Side padding when in center mode. (px or %) |
cssEase | string | 'ease' | CSS3 easing |
customPaging | function | n/a | Custom paging templates. See source for use example. |
dots | boolean | false | Current slide indicator dots |
dotsClass | string | 'slick-dots' | Class for slide indicator dots container |
draggable | boolean | true | Enables desktop dragging |
easing | string | 'linear' | animate() fallback easing |
fade | boolean | false | Enables fade |
arrows | boolean | true | Enable Next/Prev arrows |
appendArrows | string | $(element) | Change where the navigation arrows are attached (Selector, htmlString, Array, Element, jQuery object) |
appendDots | string | $(element) | Change where the navigation dots are attached (Selector, htmlString, Array, Element, jQuery object) |
prevArrow | string (html | jQuery selector) | object (DOM node |
nextArrow | string (html | jQuery selector) | object (DOM node |
infinite | boolean | true | Infinite looping |
lazyLoad | string | 'ondemand' | Accepts 'ondemand' or 'progressive' for lazy load technique |
onBeforeChange(this, currentIndex,targetIndex) | method | null | Before slide change callback |
onAfterChange(this, index) | method | null | After slide change callback |
onInit(this) | method | null | When Slick initializes for the first time callback |
onReInit(this) | method | null | Every time Slick (re-)initializes callback |
pauseOnHover | boolean | true | Pauses autoplay on hover |
pauseOnDotsHover | boolean | false | Pauses autoplay when a dot is hovered |
responsive | object | null | Breakpoint triggered settings |
slide | string | 'div' | Slide element query |
slidesToShow | int | 1 | # of slides to show at a time |
slidesToScroll | int | 1 | # of slides to scroll at a time |
speed | int | 300 | Transition speed |
swipe | boolean | true | Enables touch swipe |
swipeToSlide | boolean | false | Swipe to slide irrespective of slidesToScroll |
touchMove | boolean | true | Enables slide moving with touch |
touchThreshold | int | 5 | To advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider. |
useCSS | boolean | true | Enable/Disable CSS Transitions |
variableWidth | boolean | false | Disables automatic slide width calculation |
vertical | boolean | false | Vertical slide direction |
rtl | boolean | false | Change the slider's direction to become right-to-left |
waitForAnimate | boolean | true | Ignores requests to advance the slide while animating |
Method | Argument | Description |
---|---|---|
slick() | options : object | Initializes Slick |
unslick() | Destroys Slick | |
slickNext() | Triggers next slide | |
slickPrev() | Triggers previous slide | |
slickPause() | Pause Autoplay | |
slickPlay() | Start Autoplay | |
slickGoTo() | index : int | Goes to slide by index |
slickCurrentSlide() | Returns the current slide index | |
slickAdd() | element : html or DOM object, index: int, addBefore: bool | Add a slide. If an index is provided, will add at that index, or before if addBefore is set. If no index is provided, add to the end or to the beginning if addBefore is set. Accepts HTML String |
slideRemove() | index: int, removeBefore: bool | Remove slide by index. If removeBefore is set true, remove slide preceding index, or the first slide if no index is specified. If removeBefore is set to false, remove the slide following index, or the last slide if no index is set. |
slickFilter() | filter : selector or function | Filters slides using jQuery .filter syntax |
slickUnfilter() | Removes applied filter | |
slickGetOption(option) | option : string(option name) | Gets an option value. |
slickSetOption(option,value,refresh) | option : string(option name), value : depends on option, refresh : boolean | Sets an option live. Set refresh to true if it is an option that changes the display |
Initialize with:
$(element).slick({
dots: true,
speed: 500
});
Destroy with:
$(element).unslick();
Variable | Type | Default | Description |
---|---|---|---|
$slick-font-path | string | "./fonts/" | Directory path for the slick icon font |
$slick-font-family | string | "slick" | Font-family for slick icon font |
$slick-loader-path | string | "./" | Directory path for the loader image |
$slick-arrow-color | color | white | Color of the left/right arrow icons |
$slick-dot-color | color | black | Color of the navigation dots |
$slick-dot-color-active | color | $slick-dot-color | Color of the active navigation dot |
$slick-prev-character | string | '\2190' | Unicode character code for the previous arrow icon |
$slick-next-character | string | '\2192' | Unicode character code for the next arrow icon |
$slick-dot-character | string | '\2022' | Unicode character code for the navigation dot icon |
$slick-dot-size | pixels | 6px | Size of the navigation dots |
jQuery 1.7
Copyright (c) 2014 Ken Wheeler
Licensed under the MIT license.
Free as in Bacon.
FAQs
the last carousel you'll ever need
The npm package slick-carousel receives a total of 799,014 weekly downloads. As such, slick-carousel popularity was classified as popular.
We found that slick-carousel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.