Skip to content

Product Grid with Quick Add on Hover

Tailwind CSS product grid where a quick add bar slides up over each photo on hover or focus, with a live bag counter and wishlist toggle.

Also known as: quick add to bag grid, product grid hover add to cart, shop product grid, new arrivals grid, ecommerce product listing

Product Grid with Quick Add on Hover live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A responsive product grid built with Tailwind CSS where a dark quick add bar slides up over the product photo when a shopper hovers or tabs into a card. It suits shop home pages, "new arrivals" rows and category pages where customers should add an item to the bag without opening the product page.

How it works

The root is section.tqa-grid. A header holds the title and a "Bag" link with the .tqa-count badge. Below it, a ul grid with two columns on phones and four from the lg breakpoint lists eight li.tqa-card items. Each card has a square photo with object-cover, an optional badge such as "New" or "-20%", the category, the product name and the price. The product name link uses an after:absolute after:inset-0 overlay, so the whole card is clickable.

Inside the photo sits .tqa-bar with two buttons: .tqa-add ("Quick add") and the heart .tqa-save. style.css keeps the bar below the photo with opacity: 0 and a translateY offset, and reveals it on .tqa-card:hover, :focus-within and .is-active. The first card carries is-active so the effect is visible on load; the script removes it on the first pointerenter or focusin. On touch screens, @media (hover: none) keeps every bar visible.

The script initializes each .tqa-grid on DOMContentLoaded. A click on .tqa-add increases the bag count, plays the tqa-bump animation on the badge and switches the label to "Added" with a check icon for ADDED_MS milliseconds. .tqa-save toggles aria-pressed, which fills the heart through CSS.

Customization

  • ADDED_MS in script.js: change how long the "Added" confirmation stays on the button (1600 ms by default).
  • The .tqa-add click handler in script.js: replace the comment with a fetch() call to your cart API and update the count from its response.
  • lg:grid-cols-4 on the ul: use lg:grid-cols-3 for larger photos or xl:grid-cols-5 for dense catalogs.
  • aspect-square on the photo wrapper: switch to aspect-[4/5] for fashion photography.
  • bg-zinc-950/85 on .tqa-bar: use bg-white/90 with dark text for a light bar.
  • transform: translateY(calc(100% + 0.75rem)) in .tqa-bar: set it to none to keep only the fade.
  • Remove is-active from the first .tqa-card if no bar should be shown before the user interacts.
  • orange-500 and orange-600 on the count badge and the "-20%" badge: swap for your brand color.

Use cases

  • Shop home pages: a quick add bar slides up over each photo on hover or keyboard focus
  • New arrivals rows: badges such as New or -20% mark products
  • Category pages: customers add items to the bag without opening the product page
  • Fashion stores: the header shows a live bag counter that bumps on each add
  • Wishlist features: a heart button toggles a saved state on each card

Accessibility

The list uses role="list", and every quick add button is linked to its product name through aria-describedby. The heart buttons have an aria-label with the product name and an aria-pressed state. Keyboard users reveal the bar through :focus-within, and every control shows a visible focus ring. A role="status" region announces additions and wishlist changes, and the count badge includes a visually hidden .tqa-unit text, so it reads as "2 items". Old prices include a visually hidden "was". Motion is reduced under prefers-reduced-motion.

Usage notes

The photos come from Unsplash; replace them with your own product images and keep the width, height and alt attributes.

Product Grid with Quick Add on Hover 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 Grids
License
Free for personal and commercial use

Questions about this template

Can I use the Product Grid with Quick Add on Hover 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.

Product Grid with Quick Add on Hover – Tailwind CSS product grids component screenshot
Product Grid with Quick Add on Hover · Tailwind CSS Product Grids

More Product Grids

Product Grid with Filters – Tailwind CSS product grids preview

Product Grid with Filters

Tailwind CSS category page with a collapsible filter sidebar, live result count, empty state and a product grid sortable by price, rating or date.

Product Listing Grid – Bootstrap 5 product grids preview

Product Listing Grid

Responsive Bootstrap 5 product grid with sale, new, bestseller and sold-out badges, color swatches, wishlist buttons, sorting and client-side pagination.