Skip to content

Fashion Product Card with Hover Second Image

Tailwind CSS fashion product cards that cross-fade to a second photo on hover, with a touch-friendly swap button, sale badge and quick add bar.

Also known as: product card hover image, fashion product card, second image on hover, clothing store product card, ecommerce card with quick add

Fashion Product Card with Hover Second Image live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A fashion product card built with Tailwind CSS that cross-fades from the product shot to a second photo, such as the item worn by a model or the back print, when the shopper hovers the image. The grid of three T-shirt cards includes a sale badge, struck-through old price, color dots and a quick add bar for clothing stores and lookbooks.

How it works

The root is section.fhc-root, holding a responsive grid of article.fhc-card elements. Each card stacks two images in a fixed aspect-[4/5] frame: .fhc-img-front and .fhc-img-back, both absolutely positioned with object-cover. The card is a Tailwind group, so group-hover:opacity-0 fades the front photo out while group-hover:opacity-100 and a slight scale change bring the second photo in. The same swap is driven by the data-fhc-alt attribute through group-data-[fhc-alt=true]: utilities, which is how touch and keyboard users reach it.

The round [data-fhc-swap] button toggles data-fhc-alt and its own aria-pressed state. The product name link uses an after:absolute after:inset-0 overlay so the whole card is clickable while the buttons stay on top. In style.css the .fhc-quick bar is hidden on devices with a mouse and revealed on hover or focus, but always visible on touch screens.

On load, the card marked data-fhc-demo shows its second photo so the effect is visible right away; the script resets it on the first mouse pointerenter. Clicking [data-fhc-add] changes the label to "Added to bag" for two seconds and updates a status message.

Customization

  • Replace the two src URLs in each card with your product and alternate photos. The photos come from Unsplash; swap them for your own images in the same 4:5 ratio, or change aspect-[4/5] to aspect-square.
  • duration-500 on .fhc-img-front and .fhc-img-back: make the cross-fade faster or slower; remove group-hover:scale-105 for a pure fade without zoom.
  • bg-[#f4f1ec] on the root and bg-[#b4532a] on the sale badge and Quick add hover: change the page tone and accent color.
  • font-serif on the heading and product names: switch to font-sans for a more technical store look.
  • Remove data-fhc-demo from the second card if you do not want any card to start on its second photo.
  • sm:grid-cols-2 lg:grid-cols-3 on the list: use lg:grid-cols-4 for a denser category page.
  • The [data-fhc-add] click handler in script.js: call your cart API there instead of the label change.

Use cases

  • Fashion stores: cards cross-fade to a second photo on hover to show another angle
  • Clothing catalogs: sale badges mark discounted items at a glance
  • Mobile shops: a touch-friendly swap button replaces hover on phones
  • Ecommerce grids: a quick add bar lets shoppers add items without leaving the listing

Accessibility

Each card is an article labelled by its product name, and both images have descriptive alt text. The swap button exposes aria-pressed and an aria-label such as "Show back view", so keyboard and screen reader users get the second photo without hovering. Prices use sr-only "Was" and "Now" prefixes, color dots have hidden text names, and a role="status" region announces added items. All controls have visible focus rings, and transitions and zoom are disabled under prefers-reduced-motion.

Usage notes

Images use loading="lazy"; keep width and height to avoid layout shift. Several grids can share a page because the script scopes everything to each .fhc-root.

Fashion Product Card with Hover Second Image at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Product Cards
License
Free for personal and commercial use

Questions about this template

Can I use the Fashion Product Card with Hover Second Image code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Fashion Product Card with Hover Second Image – free Tailwind CSS product card template
Fashion Product Card with Hover Second Image · free Tailwind CSS product card template

More Product Cards

Product Card with Image Zoom – free Pure CSS product card template

Product Card with Image Zoom

Pure CSS product card whose photo zooms smoothly on hover or focus, following the pointer, with rating, color swatches and price.

Product Card with Quick Actions – free Pure CSS product card template

Product Card with Quick Actions

Responsive product card grid where hover or focus reveals wishlist, quick view and add-to-cart actions, with star ratings and a native quick view dialog.

Product Card with Sale Badge and Photo – free Bootstrap 5 product card template

Product Card with Sale Badge and Photo

Bootstrap 5 horizontal product card with a corner sale ribbon, discount sticker, old and new prices, size options that recalculate savings and stock bar.

Product Card with Color Options – free Tailwind CSS product card template

Product Card with Color Options

Tailwind CSS product card with live-recoloring color swatches, a size selector with sold-out state, wishlist toggle and add to bag button.