Hover Galleries

The Hover Gallery component displays a container of images where the first image is visible by default. Hovering horizontally over the gallery reveals the other images. DaisyUI supports up to 10 images.

Common use cases include product cards on e-commerce sites, portfolios, and image galleries.

Pass images via the with_image slot. Hover left and right over the gallery to reveal each image.

Preview
Code
= daisy_hover_gallery(css: "max-w-60") do |gallery|
  - gallery.with_image(src: image_path("landscapes/beach.jpg"), alt: "Beach")
  - gallery.with_image(src: image_path("landscapes/desert.jpg"), alt: "Desert")
  - gallery.with_image(src: image_path("landscapes/forest.jpg"), alt: "Forest")

Combine daisy_hover_gallery with daisy_card by placing it inside card.with_top_figure. This replicates the DaisyUI "Hover Gallery in a card" demo.

Preview

Gallery Card

A card with a hover gallery as the figure.

Code
= daisy_card(css: "card-sm bg-base-200 max-w-60 shadow") do |card|
  - card.with_top_figure do
    = daisy_hover_gallery do |gallery|
      - gallery.with_image(src: image_path("landscapes/beach.jpg"), alt: "Beach")
      - gallery.with_image(src: image_path("landscapes/desert.jpg"), alt: "Desert")
      - gallery.with_image(src: image_path("landscapes/forest.jpg"), alt: "Forest")
  - card.with_title { "Gallery Card" }
  %p A card with a hover gallery as the figure.

Use the srcs: convenience parameter to pass an array of image URLs without a block. Useful for quick, uniform galleries.

Preview
Code
- srcs = %w[beach desert forest].map { |s| image_path("landscapes/#{s}.jpg") }
= daisy_hover_gallery(srcs: srcs, css: "max-w-60")

When neither with_image slots nor srcs: are provided, any block content is rendered inside the figure. This allows full control over the inner markup.

Preview
Code
= daisy_hover_gallery(css: "max-w-60") do
  %img{ src: image_path("landscapes/beach.jpg"), alt: "Beach", class: "hover:opacity-100" }
  %img{ src: image_path("landscapes/desert.jpg"), alt: "Desert" }
  %img{ src: image_path("landscapes/forest.jpg"), alt: "Forest" }
Made with by Profoundry .
Copyright © 2023-2026 Profoundry LLC.
All rights reserved.