Carousel Slider 구성 요소
다크 모드를 지원하는 전자 상거래를 위한 반응형 Carousel Slider 구성 요소입니다. 제품 이미지, 이름, 가격 및 장바구니에 담기 버튼이 있습니다. 이 디자인은 다크 모드에 적합한 보색 구성표를 사용하여 시각적 편안함과 제품 프레젠테이션을 향상시킵니다.
HTML 코드
<div class="dark:bg-gray-900 bg-white py-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-3xl font-extrabold dark:text-white text-gray-900 mb-6">Featured Products</h2>
<div class="relative">
<div class="carousel-container relative overflow-hidden">
<div class="carousel-track flex transition-transform duration-500 ease-in-out">
<!-- Product Card 1 -->
<div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 px-4">
<div class="bg-gray-100 dark:bg-gray-800 rounded-lg shadow-lg overflow-hidden">
<img class="w-full h-48 object-cover" src="https://picsum.photos/seed/product1/600/400" alt="Product Image">
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Stylish Headphones</h3>
<p class="text-gray-700 dark:text-gray-300 text-sm mb-4">Experience immersive sound with these premium headphones.</p>
<div class="flex items-center justify-between">
<span class="text-xl font-bold text-gray-900 dark:text-white">$120.00</span>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-full transition duration-300">
Add to Cart
</button>
</div>
</div>
</div>
</div>
<!-- Product Card 2 -->
<div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 px-4">
<div class="bg-gray-100 dark:bg-gray-800 rounded-lg shadow-lg overflow-hidden">
<img class="w-full h-48 object-cover" src="https://picsum.photos/seed/product2/600/400" alt="Product Image">
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Smartwatch Pro</h3>
<p class="text-gray-700 dark:text-gray-300 text-sm mb-4">Stay connected and track your fitness with this advanced smartwatch.</p>
<div class="flex items-center justify-between">
<span class="text-xl font-bold text-gray-900 dark:text-white">$199.00</span>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-full transition duration-300">
Add to Cart
</button>
</div>
</div>
</div>
</div>
<!-- Product Card 3 -->
<div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 px-4">
<div class="bg-gray-100 dark:bg-gray-800 rounded-lg shadow-lg overflow-hidden">
<img class="w-full h-48 object-cover" src="https://picsum.photos/seed/product3/600/400" alt="Product Image">
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Portable Bluetooth Speaker</h3>
<p class="text-gray-700 dark:text-gray-300 text-sm mb-4">Enjoy your music anywhere with this powerful and compact speaker.</p>
<div class="flex items-center justify-between">
<span class="text-xl font-bold text-gray-900 dark:text-white">$75.00</span>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-full transition duration-300">
Add to Cart
</button>
</div>
</div>
</div>
</div>
<!-- Product Card 4 -->
<div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 px-4">
<div class="bg-gray-100 dark:bg-gray-800 rounded-lg shadow-lg overflow-hidden">
<img class="w-full h-48 object-cover" src="https://picsum.photos/seed/product4/600/400" alt="Product Image">
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Ergonomic Office Chair</h3>
<p class="text-gray-700 dark:text-gray-300 text-sm mb-4">Work in comfort and style with this adjustable office chair.</p>
<div class="flex items-center justify-between">
<span class="text-xl font-bold text-gray-900 dark:text-white">$250.00</span>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-full transition duration-300">
Add to Cart
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Navigation Buttons (Optional - can be styled with Tailwind) -->
<button class="carousel-prev absolute top-1/2 left-0 transform -translate-y-1/2 bg-gray-700 dark:bg-gray-800 text-white p-2 rounded-full shadow-lg z-10">
❮
</button>
<button class="carousel-next absolute top-1/2 right-0 transform -translate-y-1/2 bg-gray-700 dark:bg-gray-800 text-white p-2 rounded-full shadow-lg z-10">
❯
</button>
</div>
</div>
</div>
<style>
.carousel-track {
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch; /* For smoother scrolling on iOS */
}
.carousel-item {
scroll-snap-align: start;
}
.carousel-container {
overflow-x: scroll;
scrollbar-width: none; /* Hide scrollbar for Firefox */
-ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
}
.carousel-container::-webkit-scrollbar {
display: none; /* Hide scrollbar for Chrome, Safari and Opera */
}
</style>
관련 구성 요소
Carousel Slider 구성 요소
다크 모드를 지원하는 반응형 캐러셀 슬라이더 구성 요소입니다. 이 구성 요소는 JavaScript 없이 HTML 및 Tailwind CSS만 사용합니다. 활성 슬라이드를 위한 생생한 색상의 간단한 레이아웃이 특징이며 블로그 또는 콘텐츠 소비에 적합합니다.
Carousel Slider 구성 요소
Tailwind CSS를 사용하여 "포트폴리오 - 작업 또는 제품 전시"를 위해 "보색 - 색상환에서 서로 반대편에 있는 색상" 및 복잡성 수준 "복잡함 - 여러 대화형 요소가 있는 풍부한 인터페이스"를 사용하여 디자인 스타일 "Neumorphism - 미묘한 그림자를 사용하여 배경에서 돌출되는 것처럼 보이는 요소를 만드는 소프트 UI 스타일"로 웹 구성 요소 Carousel Slider Component를 구현합니다. 어두운 테마를 지원하는 반응형 디자인을 만들 수 있습니다. JavaScript 코드가 필요하지 않으며 Tailwind 클래스가 있는 HTML만 필요합니다. 다크 모드의 경우 스타일링을 위해 Tailwind의 dark: 접두사를 사용합니다. 이미지가 필요한 경우 이미지에는 picsum.photos를 사용하고 아바타에는 randomuser.me 를 사용합니다.