I have a swiper slider in my angular project. its has 4 items in desktop view. I want 1 item in the mobile view. check this link
https://stackblitz.com/edit/ngx-swiper-wrapper-demo-h9egdh?file=app/app.component.ts
Demo .ts code here
public slides = [
'First slide',
'Second slide',
'Third slide',
'Fourth slide',
'Fifth slide',
'Sixth slide'
];
public type: string = 'component';
public disabled: boolean = false;
public config: SwiperConfigInterface = {
direction: 'horizontal',
slidesPerView: 4,
keyboard: true,
mousewheel: true,
scrollbar: false,
navigation: true,
pagination: false
};
css"; import "swiper/css"; import "swiper/css/navigation"; import "swiper/css/pagination"; import "swiper/css/scrollbar"; const MainSlider = () => { return ( <Swiper // install Swiper modules breakpoints={{ 576: { width: 576, slidesPerView: 2, }, 768: { width: 768, slidesPerView: 1, }, }} modules={[Navigation, ...
Swiper is a JavaScript library that creates modern touch sliders with hardware-accelerated transitions (utilizing GPU to offload graphic-intensive transitions and create smoother visuals) and excellent native behavior. Swiper is available for vanilla JavaScript, Angular, React, Vue. js, and Svelte.
you can add a breakpoints attribute to the config JSON as:
public config: SwiperConfigInterface = {
direction: 'horizontal',
slidesPerView: 4,
keyboard: true,
mousewheel: true,
scrollbar: false,
navigation: true,
pagination: false,
breakpoints:{
640:{
slidesPerView: 1,
}
}
};
the breakpoints can be any size you require, for more info you can check: https://github.com/nolimits4web/Swiper/blob/master/demos/380-responsive-breakpoints.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With