Skip to content

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.

Also known as: product card hover, ecommerce product card, add to cart card, quick view modal

Product Card with Quick Actions live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A responsive grid of e-commerce product cards built with pure CSS and vanilla JavaScript. Hovering a card reveals a wishlist heart and an action bar with Quick view and Add to cart, while a native dialog shows product details without leaving the page. Use it for shop category pages, featured product rows and "new arrivals" sections.

How it works

The root section.pqa-root contains a header with a .pqa-cart-count badge, a .pqa-grid of article.pqa-card elements, a hidden .pqa-status live region and one shared dialog.pqa-dialog. Each card has a .pqa-media area (badge, image, .pqa-wish button and the .pqa-actions bar) and a .pqa-body with category, title, a star rating and the price.

The actions start with opacity: 0 and a small offset. On devices with a mouse, :hover on .pqa-card lifts the card, zooms .pqa-img and slides the actions in. :focus-within does the same for keyboard users, and on touch screens (hover: none) the actions are always visible. Stars are plain spans: .pqa-star uses a CSS mask with a star shape, and .is-on or .is-half color them.

The script listens for clicks on three buttons. .pqa-wish toggles aria-pressed and fills the heart. .pqa-cart increases the counter, switches the label to "Added" with .is-added for ADDED_MS milliseconds and announces the change. .pqa-quick copies the image, category, title, price and the card's data-desc into the dialog and opens it with showModal().

Customization

  • --pqa-accent on .pqa-root: the color of badges, the cart counter, the active heart and the dialog price.
  • --pqa-bg, --pqa-card and --pqa-text: page background, card surface and text color for a different palette.
  • --pqa-star and --pqa-star-off: filled and empty star colors in .pqa-rating.
  • --pqa-speed: how fast the actions slide in and the card lifts.
  • data-desc on each .pqa-card: the longer text shown in the quick view dialog.
  • ADDED_MS in script.js: how long the "Added" feedback stays on the button.
  • grid-template-columns in .pqa-grid: one column on phones, two from 600px and three from 900px.

Use cases

  • Shop category pages: product cards with quick view and add to cart on hover
  • Featured product rows: a grid for new arrivals or bestsellers
  • Wishlists: a heart button on every product

Accessibility

All actions are real button elements with a visible :focus-visible outline. The wishlist button has an aria-label with the product name and reports its state with aria-pressed. Quick view and Add to cart include the product name in a visually hidden .pqa-sr span. The rating uses role="img" with a readable label, and old prices include a hidden "Was" prefix. Cart and wishlist changes are announced through the role="status" region. The dialog is modal, closes with Escape, the close button or a backdrop click, and returns focus to the button that opened it. Under prefers-reduced-motion: reduce the lift, zoom, slide and pop animations are turned off.

Usage notes

addToCart() only updates the counter; replace it with a fetch() call to your cart endpoint. Several .pqa-root sections can share a page, each with its own dialog and counter.

Product Card with Quick Actions at a glance

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

Questions about this template

Can I use the Product Card with Quick Actions 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?

There is nothing to install. 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

No dependencies. Pure HTML, CSS and JavaScript.

Product Card with Quick Actions – free Pure CSS product card template
Product Card with Quick Actions · free Pure 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 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.