--- title: Hover gallery summary: A set of images that shows one at a time and switches as the pointer moves across it. description: Show several photos in the space of one with the hover gallery component - a good fit for product cards, portfolios and listings. related: [/ui/components/carousel, /ui/components/card] source: core/scss/ui/_hover-gallery.scss css-vars: hover-gallery classnames: component: - class: hover-gallery desc: Container element with a fixed aspect ratio part: - class: hover-gallery-item desc: Wraps one image and makes one hover column modifier: - class: hover-gallery-indicators desc: Adds a bar for each item at the bottom edge and lights the one on display --- import Example from '@components/Example.astro'; ## Overview A hover gallery holds several images in one box. The first image shows by default. Each item is an invisible column, and the image of the column under the pointer covers the whole gallery. It works without JavaScript. ## Basic example Wrap each image in a `.hover-gallery-item` and put the items in a `.hover-gallery`. Use as many items as you need. ## Indicators Add `.hover-gallery-indicators` to show a bar for each image. The bar of the image on display is lit. The bars are white and sit on a soft dark gradient, so they stay visible on light and dark photos. Set `--tblr-hover-gallery-indicator-scrim-bg` to `none` to remove the gradient, and `--tblr-hover-gallery-indicator-color` to change the bars. ## Aspect ratio The gallery is a square by default and the images are cropped to fill it. Set `--tblr-hover-gallery-aspect-ratio` to change the shape. ## In a card Add `.card-img-top` to use the gallery in place of the card image.

Steel watch

$249
## Touch devices On devices without hover, the gallery becomes a horizontal strip. Users swipe to see the next image, and each image snaps into place. The indicators are hidden there. ## Accessibility - Give every image an `alt` text that says what this photo shows, not only the product name. - Keyboard users see only the first image. Do not put information in the other images that is missing elsewhere on the page. - When the gallery sits inside a link, the whole gallery leads to one place. Do not link single images to different pages.