React Slick third party package

 

1. Third-Party Package - 
react-slick

NPM contains a react-slick, a third-party package that provides a React component Slider to add a carousel to your application.

Installation Command:

npm install react-slick

Also, install slick-carousel for CSS and font

npm install slick-carousel

1.1 Advantages

  • Easy to use
  • Highly customizable
  • More performant

2. Slider Props

We can provide different props to the Slider component. Below are the most commonly used props.

PropDescriptionDefault Value
slidesToShowSpecifies the number of slides to show in one frame1
dotsIf set to false, no dots will display under the carouseltrue
slidesToScrollSpecifies the number of slides to scroll at once1
dotsClassCSS class for styling dots"slick-dots"

Example:

File: src/components/ReactSlick/index.js

import Slider from 'react-slick'
import 'slick-carousel/slick/slick.css'
import 'slick-carousel/slick/slick-theme.css'
import './index.css'
const ReactSlick = () => {
const settings = {
dots: true,
slidesToShow: 1,
slidesToScroll: 1,
}
return (
<div className="slider-container">
<Slider {...settings}>
<div>
<h3>1</h3>
</div>
<div>
<h3>2</h3>
</div>
<div>
<h3>3</h3>
</div>
<div>
<h3>4</h3>
</div>
</Slider>
</div>
)
}
export default ReactSlick
JSX
Collapse

File: src/components/ReactSlick/index.css

.slider-container {
background-color: #419be0;
padding: 40px;
}
CSS

File: src/App.js

import ReactSlick from './components/ReactSlick'
const App = () => {
return <ReactSlick />
}
export default App
JSX

react-slick

Reference

To know more about the

react-slick
, you can refer to this.

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form