GALLERIES / FREE HTML + ASTRO

Product image viewer

A large main image with labeled thumbnail controls and a progressive image-link fallback.

Try the design

Open demo ↗

Preview links stay in the example. Copy the source to use your own destinations. Form previews never send information.

Copy the source

<section class="fct-product-image-viewer s-gallery-section s-product" data-snippet="product-image-viewer" aria-labelledby="fct-product-image-viewer-heading"><div class="s-wrap"><p class="s-kicker">A closer look</p><h2 id="fct-product-image-viewer-heading">One subject. Different views.</h2><p class="s-gallery-intro">Licensed illustrative photographs. Replace these with your own images and descriptions.</p><div class="s-product-main"><figure class=""><a href="images/coast.webp" data-gallery-index="0"><img src="images/coast.webp" alt="Rocky coast beside open water" width="800" height="600" loading="eager" decoding="async"></a><figcaption>Rocky coast beside open water</figcaption></figure></div><div class="s-thumbnails" aria-label="Choose image"><button type="button" data-image-choice="0" aria-label="View image 1: Rocky coast beside open water" aria-pressed="true"><img src="images/coast.webp" alt="" width="120" height="90" loading="lazy"></button><button type="button" data-image-choice="1" aria-label="View image 2: Escalator lights inside a station" aria-pressed="false"><img src="images/passage.webp" alt="" width="120" height="90" loading="lazy"></button><button type="button" data-image-choice="2" aria-label="View image 3: Boathouse reflected in still water" aria-pressed="false"><img src="images/boathouse.webp" alt="" width="120" height="90" loading="lazy"></button><button type="button" data-image-choice="3" aria-label="View image 4: Canal and buildings in Venice" aria-pressed="false"><img src="images/venice.webp" alt="" width="120" height="90" loading="lazy"></button><button type="button" data-image-choice="4" aria-label="View image 5: Lake reflected between forest trees" aria-pressed="false"><img src="images/forest.webp" alt="" width="120" height="90" loading="lazy"></button><button type="button" data-image-choice="5" aria-label="View image 6: Lakeside cabin below mountains at dusk" aria-pressed="false"><img src="images/blue-hour.webp" alt="" width="120" height="90" loading="lazy"></button></div><noscript><div class="s-gallery"><figure class=""><a href="images/passage.webp" data-gallery-index="1"><img src="images/passage.webp" alt="Escalator lights inside a station" width="800" height="600" loading="lazy" decoding="async"></a><figcaption>Escalator lights inside a station</figcaption></figure><figure class=""><a href="images/boathouse.webp" data-gallery-index="2"><img src="images/boathouse.webp" alt="Boathouse reflected in still water" width="800" height="600" loading="lazy" decoding="async"></a><figcaption>Boathouse reflected in still water</figcaption></figure><figure class=""><a href="images/venice.webp" data-gallery-index="3"><img src="images/venice.webp" alt="Canal and buildings in Venice" width="800" height="600" loading="lazy" decoding="async"></a><figcaption>Canal and buildings in Venice</figcaption></figure><figure class=""><a href="images/forest.webp" data-gallery-index="4"><img src="images/forest.webp" alt="Lake reflected between forest trees" width="800" height="600" loading="lazy" decoding="async"></a><figcaption>Lake reflected between forest trees</figcaption></figure><figure class=""><a href="images/blue-hour.webp" data-gallery-index="5"><img src="images/blue-hour.webp" alt="Lakeside cabin below mountains at dusk" width="800" height="600" loading="lazy" decoding="async"></a><figcaption>Lakeside cabin below mountains at dusk</figcaption></figure></div></noscript><dialog aria-label="Enlarged image" class="s-lightbox"><button type="button" data-close>Close</button><figure><img alt="" width="800" height="600"><figcaption></figcaption></figure><div class="s-lightbox-controls"><button type="button" data-prev>Previous</button><span role="status" data-image-count></span><button type="button" data-next>Next</button></div></dialog></div></section>

Where this design fits

Thumbnail controls change the main view without navigating away. The included photographs demonstrate the mechanics; replace them with consistent views of the same product.

  • Main-image viewer
  • Thumbnail selection
  • Direct image fallback

What is included

The HTML ZIP includes a standalone demo, reusable markup, scoped CSS, its small JavaScript runtime, a license and setup notes. The Astro ZIP includes Snippet.astro, local sample images and image credits. It can be imported into an existing Astro page or layout.

Replace the sample photographs

Included photographs are licensed illustrative assets. They are not work created by the demonstration business. Update image paths, dimensions, captions and alternative descriptions for your own files. The ZIP includes the original image-source and license notes.

Add it to an HTML website

  1. Copy snippet.html into the relevant page section.
  2. Load snippet.css after your existing site stylesheet. The class prefix identifies this design.
  3. Load snippet.js once with defer. Keep the included keyboard behavior when adapting interactions.
  4. Replace example content and check mobile widths, zoom, links and keyboard focus in your actual website.

Use it in Astro

Copy Snippet.astro into src/components/, import it into your page or shared layout, and insert the component where the section belongs. Copy images into public/snippet-assets/product-image-viewer/images; the component uses that public path. Keep each generated prefix unique if you duplicate a component on one page.

Keep the section maintainable

Start with the variables at the top of the CSS for background, text and accent colors. Preserve semantic labels and focus styles. Existing site selectors can still affect imported markup, so test the combined result. Read the complete setup notes.

GOOD DESIGN, OCCASIONALLY.

Your next idea
could start here.

New templates, useful guides, and updates from us.
A little inspiration for whatever you’re building.