Slick Slider Integration for Magento 2
A starter module that loads the Slick carousel library into Magento 2 through RequireJS, with the LESS files and a demo route already wired up. Developers then call .slick() on any element to build a carousel.
- Free
- MIT license
- Luma
- Magento 2.4.4 to 2.4.9
- Adobe CertifiedDeveloper since 2021
- 5.0 on UpworkFrom 100+ reviews
- MIT open sourceRead and change the code
- LumaSame module, both themes
- PHP 8.1 to 8.4Magento 2.4.4 to 2.4.9
What it does for your store
The main features, as listed in the module documentation.
-
Built for Magento 2
app/code/Mage2sk/SlickSlider/view/frontend/requirejs-config.js
-
MEQP Compliant
Adobe Magento Extension Quality Program, passes with zero severity-10 violations.
-
Hyva + Luma Ready
Vanilla JS, no jQuery dependency. Drop-in compatible with both default Luma and Hyva themes.
-
Free Forever
Lifetime updates with every Magento release. No subscription, no licence keys, no upsells.
Compatibility
| Magento Open Source | 2.4.4 to 2.4.9 |
|---|---|
| Adobe Commerce | 2.4.4 to 2.4.9 |
| PHP | 8.1, 8.2, 8.3, 8.4 |
| Themes | Luma |
| License | MIT, free and open source |
Documentation
The full module guide, from the README on GitHub.
Overview
The Slick Slider Integration for Magento 2 is a drop-in module for Magento 2 and Adobe Commerce that wires Ken Wheeler's Slick carousel library into Magento's RequireJS pipeline. It provides the module skeleton, RequireJS shim, LESS imports, and a sample demo route so developers can ship product carousels, homepage banners, and category sliders without re-doing the integration plumbing on every project.
Out of the box the Slick Slider Integration for Magento 2 registers a slick RequireJS path with a jQuery shim, imports slick.less and slick-theme.less into the Magento LESS build via _module.less, exposes a magehelper_slickslider/index/index demo route, and ships layout XML plus a sample slick-slider.phtml template. From there developers initialize Slick on any selector with the standard $('.your-class').slick({...}) API - autoplay, responsive breakpoints, dots, arrows, fade, variable width, and every other Slick option are available immediately.
Because the Slick Slider Integration for Magento 2 follows the standard Vendor_Module structure with module.xml, registration.php, requirejs-config.js, routes.xml, and a controller, it doubles as a step-by-step learning project for developers building their first Magento 2 frontend module. Tested on Magento 2.4.x with PHP 8.x.
Best for:
- Frontend developers adding product, brand, or promo carousels to a Luma theme
- Agencies needing a reliable starter for Magento 2 module-with-asset integrations
- Beginners who want a fully wired example of RequireJS shim plus LESS plus layout
What you get
The Slick Slider Integration for Magento 2 ships every piece needed for a clean carousel setup:
- Module skeleton with
module.xml,registration.php, and Composer-friendly layout - RequireJS shim that registers
slickwith a jQuery dependency for safe lazy loading - LESS pipeline with
slick.less,slick-theme.less, and_module.lesswired in - Sample frontend route, controller, layout XML, and
slick-slider.phtmldemo template - Full access to Slick's options: autoplay, responsive breakpoints, dots, arrows, fade
- Step-by-step structure that doubles as a Magento 2 frontend module learning project
Mage2sk : How to use Slick Slider in Magento 2
We will learn here, how to use Slick Slider in Magento 2 step by step.
We can create new module in app/code/ directory..
Step - 1 - Create a directory for the module
- In Magento 2, module name divided into two parts i.e Vendor_Module (for e.g Magento_Theme, Magento_Catalog)
- We will create
Mage2sk_SlickSliderhere, SoMage2skis vendor name andSlickSlideris name of this module. - So first create your namespace directory (
Mage2sk) and move into that directory. - Then create module name directory (
SlickSlider)
Now Go to : app/code/Mage2sk/SlickSlider
Step - 2 - Create module.xml file to declare new module.
- Magento 2 looks for configuration information for each module in that module’s etc directory. so we need to add module.xml file here in our module
app/code/Mage2sk/SlickSlider/etc/module.xmland it's content for our module is :
<?xml version="1.0"?>
<!--
/**
* Mage2sk Use Slick slider in Magento 2
*
* @package Mage2sk_SlickSlider
* @author Kishan Savaliya
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mage2sk_SlickSlider" setup_version="1.0.0" />
</config>
In this file, we register a module with name Mage2sk_SlickSlider and the version is 1.0.0.
Step - 3 - create registration.php
- All Magento 2 module must be registered in the Magento system through the magento
ComponentRegistrarclass. This file will be placed in module's root directory.
In this step, we need to create this file:
app/code/Mage2sk/SlickSlider/registration.php
And it’s content for our module is:
<?php
/**
* Mage2sk Use Slick slider in Magento 2
*
* @package Mage2sk_SlickSlider
* @author Kishan Savaliya
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mage2sk_SlickSlider',
__DIR__
);
Step - 4 - Enable Mage2sk_SlickSlider module.
- By finish above step, you have created an empty module. Now we will enable it in Magento environment.
- Before enable the module, we must check to make sure Magento has recognize our module or not by enter the following at the command line:
php bin/magento module:status
If you follow above step, you will see this in the result:
List of disabled modules:
Mage2sk_SlickSlider
This means the module has recognized by the system but it is still disabled. Run this command to enable it:
php bin/magento module:enable Mage2sk_SlickSlider
The module has enabled successfully if you saw this result:
The following modules has been enabled:
- Mage2sk_SlickSlider
This’s the first time you enable this module so Magento require to check and upgrade module database. We need to run this command:
php bin/magento setup:upgrade
Step - 5 - Create requirejs-config.js file
Create requirejs-config.js this file here in module..
app/code/Mage2sk/SlickSlider/view/frontend/requirejs-config.js
Content for this file is ..
var config = {
paths: {
slick: 'Mage2sk_SlickSlider/js/slick'
},
shim: {
slick: {
deps: ['jquery']
}
}
};
Step - 6 - Add slick.js and slick.min.js files
You can download latest version of slick here
Download that and extract .zip file and copy slick.js and slick.min.js files from there and paste that here..
app/code/Mage2sk/SlickSlider/view/frontend/web/js/slick.js
and
app/code/Mage2sk/SlickSlider/view/frontend/web/js/slick.min.js
Step - 7 - Now add slick.less and slick-theme.less files
Copy .less files from downloaded directory to below mentioned path..
app/code/Mage2sk/SlickSlider/view/frontend/web/css/source/slick.less
and
app/code/Mage2sk/SlickSlider/view/frontend/web/css/source/slick-theme.less
Step - 8 - create _module.less file
Now create _module.less file here..
app/code/Mage2sk/SlickSlider/view/frontend/web/css/source/_module.less
This is important file to run slick slider properly in Magento 2 without any issues.
Content for this file is..
@import 'slick.less';
@import 'slick-theme.less';
- We will display all sliders in one custom action in this module.
Step - 9 - Create frontend router
- Create
routes.xmlfile here..
app/code/Mage2sk/SlickSlider/etc/frontend/routes.xml
Content for this file is ..
<?xml version="1.0"?>
<!--
/**
* Mage2sk Use Slick slider in Magento 2
*
* @package Mage2sk_SlickSlider
* @author Kishan Savaliya
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="magehelper_slickslider" frontName="magehelper_slickslider">
<module name="Mage2sk_SlickSlider" />
</route>
</router>
</config>
- So we can run this URL to check our output.. (http://www.example.com/magehelper_slickslider)
Step - 10 - Create Controllers and Actions
- Now we will create our controller and action to show all slick slider demo. We will create controller and action here
app/code/Mage2sk/SlickSlider/Controller/Index/Index.php
And content for this file is :
<?php
/**
* Mage2sk Use Slick slider in Magento 2
*
* @package Mage2sk_SlickSlider
* @author Kishan Savaliya
*/
namespace Mage2sk\SlickSlider\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
protected $resultPageFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
){
$this->resultPageFactory = $resultPageFactory;
return parent::__construct($context);
}
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Mage2sk Slick slider demo'));
return $resultPage;
}
}
Step - 11 - Create layout and template files
- Create layout file here..
app/code/Mage2sk/SlickSlider/view/frontend/layout/magehelper_slickslider_index_index.xml
Content for this file is ...
<?xml version="1.0"?>
<!--
/**
* Mage2sk Use Slick slider in Magento 2
*
* @package Mage2sk_SlickSlider
* @author Kishan Savaliya
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block
template="Mage2sk_SlickSlider::slick-slider.phtml"
class="Magento\Framework\View\Element\Template"
name="magento-2-slick-slider-demo"/>
</referenceContainer>
</page>
- Create template file here ...
app/code/Mage2sk/SlickSlider/view/frontend/templates/slick-slider.phtml
Add Content in phtml file..
Step - 12 - Run following commands
- We need to run following commands to check output properly
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:static-content:deploy -f
Hope this article will helpful to you!!
| Module Category | Theme & UI |
|---|---|
| Best For | All Sizes |
Questions before you install?
Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.