Skip to content
The Chat Archive
deepseek-r1-0528· DeepSeek LMArena Human Preference 140K

Create a gallery component for a cake bakery webpage in astro framework using tailwind…

  1. User

    Create a gallery component for a cake bakery webpage in astro framework using tailwind to style it

  2. Assistant

    Here's a responsive gallery component for a cake bakery using Astro and Tailwind CSS:

    ---
    // src/components/CakeGallery.astro
    
    // Define cake data structure (could be moved to separate file or fetched from CMS)
    const cakes = [
      { id: 1, name: "Chocolate Fudge", category: "chocolate", image: "/images/cake1.jpg" },
      { id: 2, name: "Vanilla Dream", category: "classic", image: "/images/cake2.jpg" },
      { id: 3, name: "Red Velvet", category: "specialty", image: "/images/cake3.jpg" },
      { id: 4, name: "Lemon Drizzle", category: "fruit", image: "/images/cake4.jpg" },
      { id: 5, name: "Carrot Cake", category: "specialty", image: "/images/cake5.jpg" },
      { id: 6, name: "Strawberry Shortcake", category: "fruit", image: "/images/cake6.jpg" },
      { id: 7, name: "Cookies & Cream", category: "chocolate", image: "/images/cake7.jpg" },
      { id: 8, name: "Tiramisu", category: "specialty", image: "/images/cake8.jpg" },
    ];
    ---
    
    <div class="container mx-auto px-4 py-12">
      <h2 class="text-3xl md:text-4xl font-bold text-center mb-2 text-amber-800">Our Sweet Creations</h2>
      <p class="text-center text-gray-600 mb-12 max-w-2xl mx-auto">
        Browse through our delicious selection of handcrafted cakes made with love and premium ingredients
      </p>
    
      <!-- Gallery Grid -->
      <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
        {cakes.map((cake) => (
          <div class="relative group overflow-hidden rounded-xl shadow-lg hover:shadow-xl transition-all duration-300">
            <!-- Cake Image -->
            <img 
              src={cake.image} 
              alt={cake.name}
              width="400"
              height="500"
              class="w-full h-64 object-cover transition-transform duration-500 group-hover:scale-110"
            />
            
            <!-- Overlay -->
            <div class="absolute inset-0 bg-gradient-to-t from-black/70 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300">
              <div class="absolute bottom-0 left-0 p-6 text-white translate-y-4 group-hover:translate-y-0 transition-transform duration-300">
                <h3 class="text-xl font-bold">{cake.name}</h3>
                <p class="text-amber-200 font-medium">${cake.category}</p>
              </div>
            </div>
          </div>
        ))}
      </div>
    
      <!-- View More Button -->
      <div class="text-center mt-12">
        <button class="bg-amber-600 hover:bg-amber-700 text-white font-semibold py-3 px-8 rounded-full transition-colors duration-300">
          View Full Menu
        </button>
      </div>
    </div>
    

    Key features of this implementation:

    1. Responsive Grid Layout:

      • 1 column on mobile
      • 2 columns on small screens
      • 3 columns on large screens
      • 4 columns on extra-large screens
    2. Hover Effects:

      • Smooth image zoom on hover
      • Gradient overlay with text reveal
      • Shadow enhancement
      • Text slide-up animation
    3. Styling:

      • Warm amber color scheme suitable for bakery
      • Rounded corners and soft shadows
      • Proper spacing and typography
      • Responsive text sizing
    4. Accessibility:

      • Semantic HTML structure
      • Proper alt text for images
      • Sufficient color contrast
      • Focus states for interactive elements
    5. Performance:

      • Fixed image dimensions
      • Optimized hover animations
      • Efficient Tailwind classes

    To use this component in your Astro page:

    ---
    // src/pages/index.astro
    import CakeGallery from '../components/CakeGallery.astro';
    ---
    
    <CakeGallery />
    

    Tips for customization:

    1. Replace placeholder images with your actual cake photos
    2. Adjust color scheme by modifying Tailwind classes (amber-* → your preferred colors)
    3. Add actual category filtering functionality using JavaScript if needed
    4. Connect the "View Full Menu" button to your menu page
    5. Add actual pricing information in the overlay
    6. Implement lightbox functionality for image enlargement

    For best results:

    • Use high-quality, consistent aspect ratio images (4:3 or 3:2 recommended)
    • Optimize images for web (compressed JPEGs or WebP format)
    • Ensure proper color calibration of food photography
    • Add subtle animations using Tailwind's animation utilities
    • Include actual nutritional/allergy information if relevant

    This component creates an attractive, modern gallery that showcases your bakery products while maintaining good performance and responsiveness across all devices.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.