Skip to content

Instantly share code, notes, and snippets.

@Mif2006
Created October 6, 2023 21:29
Show Gist options
  • Save Mif2006/b6963b16274c973b7ddfacf3106bb114 to your computer and use it in GitHub Desktop.
Save Mif2006/b6963b16274c973b7ddfacf3106bb114 to your computer and use it in GitHub Desktop.
import { Swiper, SwiperSlide } from "swiper/react";
import "swiper/css";
import "swiper/css/pagination";
import "swiper/css/free-mode";
import { FreeMode, Pagination } from "swiper/modules";
import { RxArrowTopRight } from "react-icons/rx";
import { ServiceData } from "../constants";
const ActiveSlider = () => {
return (
<div className="flex items-center justify-center flex-col h-[900px] bg-[#6c34af]">
<Swiper
breakpoints={{
340: {
slidesPerView: 2,
spaceBetween: 15,
},
700: {
slidesPerView: 3,
spaceBetween: 15,
},
}}
freeMode={true}
pagination={{
clickable: true,
}}
modules={[FreeMode, Pagination]}
className="max-w-[90%] lg:max-w-[80%]"
>
{ServiceData.map((item) => (
<SwiperSlide key={item.title}>
<div className="flex flex-col gap-6 mb-20 group relative shadow-lg text-white rounded-xl px-6 py-8 h-[250px] w-[215px] lg:h-[400px] lg:w-[350px] overflow-hidden cursor-pointer">
<div
className="absolute inset-0 bg-cover bg-center"
style={{ backgroundImage: `url(${item.backgroundImage})` }}
/>
<div className="absolute inset-0 bg-black opacity-10 group-hover:opacity-50" />
<div className="relative flex flex-col gap-3">
<item.icon className="text-blue-600 group-hover:text-blue-400 w-[32px] h-[32px]" />
<h1 className="text-xl lg:text-2xl">{item.title} </h1>
<p className="lg:text-[18px]">{item.content} </p>
</div>
<RxArrowTopRight className="absolute bottom-5 left-5 w-[35px] h-[35px] text-white group-hover:text-blue-500 group-hover:rotate-45 duration-100" />
</div>
</SwiperSlide>
))}
</Swiper>
</div>
);
};
export default ActiveSlider;
@muhamedsahin
Copy link

thank you

@hadelli
Copy link

hadelli commented Mar 31, 2025

Hi its me from the youtube comments! I have invited you as a collaborator on my project. Will you please check it? I made the edits you suggested but the pagination disappears entirely for all screen sizes. Along with not being able to see the dots at the bottom, I am also trying to incorporate swiping through for the when window <1024px, while being able to see the second screen peeking. Ill add images of what i have so far as well. Although they show perfect amount of spacing at a certain window size, theyre all overlapping at a lesser screen width :'(( .. again. either you dont see the second screen at all or they overlap when you can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment