← catalogo / components/category-previews
TW-CO-CP-05
Tailwind Plus
tailwind/ecommerce/components/category-previews/05-with-scrolling-cards
html: questa e' vue, sotto c'e' il sorgente.
<template>
<div class="bg-white">
<div class="py-16 sm:py-24 xl:mx-auto xl:max-w-7xl xl:px-8">
<div class="px-4 sm:flex sm:items-center sm:justify-between sm:px-6 lg:px-8 xl:px-0">
<h2 class="text-2xl font-bold tracking-tight text-gray-900">Shop by Category</h2>
<a href="#" class="hidden text-sm font-semibold text-indigo-600 hover:text-indigo-500 sm:block">
Browse all categories
<span aria-hidden="true"> →</span>
</a>
</div>
<div class="mt-4 flow-root">
<div class="-my-2">
<div class="relative box-content h-80 overflow-x-auto py-2 xl:overflow-visible">
<div class="absolute flex space-x-8 px-4 sm:px-6 lg:px-8 xl:relative xl:grid xl:grid-cols-5 xl:gap-x-8 xl:space-x-0 xl:px-0">
<a v-for="category in categories" :key="category.name" :href="category.href" class="relative flex h-80 w-56 flex-col overflow-hidden rounded-lg p-6 hover:opacity-75 xl:w-auto">
<span aria-hidden="true" class="absolute inset-0">
<img :src="category.imageSrc" alt="" class="size-full object-cover" />
</span>
<span aria-hidden="true" class="absolute inset-x-0 bottom-0 h-2/3 bg-linear-to-t from-gray-800 opacity-50"></span>
<span class="relative mt-auto text-center text-xl font-bold text-white">{{ category.name }}</span>
</a>
</div>
</div>
</div>
</div>
<div class="mt-6 px-4 sm:hidden">
<a href="#" class="block text-sm font-semibold text-indigo-600 hover:text-indigo-500">
Browse all categories
<span aria-hidden="true"> →</span>
</a>
</div>
</div>
</div>
</template>
<script setup>
const categories = [
{
name: 'New Arrivals',
href: '#',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/home-page-01-category-01.jpg',
},
{
name: 'Productivity',
href: '#',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/home-page-01-category-02.jpg',
},
{
name: 'Workspace',
href: '#',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/home-page-01-category-04.jpg',
},
{
name: 'Accessories',
href: '#',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/home-page-01-category-05.jpg',
},
{
name: 'Sale',
href: '#',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/home-page-01-category-03.jpg',
},
]
</script>