Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bootstrap Product Grid with Color Swatch Image Switcher

A responsive product showcase page built with Bootstrap v5 and vanilla JavaScript. It is designed for product listings that need a clean card layout and a simple image-switching interaction based on color swatches.

This demo focuses on a practical UI pattern:

  • 3 columns per row on desktop
  • 1 column per row on mobile
  • Click color swatches to switch the main product image
  • No third-party slider library required

Tech Stack

  • HTML5
  • CSS3
  • Bootstrap v5
  • Vanilla JavaScript

Why this stack?

This project keeps the implementation lightweight and easy to maintain:

  • Bootstrap handles the responsive grid system and spacing.
  • Vanilla JavaScript is used for image switching, avoiding unnecessary dependencies.
  • The code is simple enough to adapt into static websites, landing pages, CMS templates, and WordPress page modules.

Use Cases

This layout is suitable for many product presentation scenarios, such as:

  • Aluminum railings and fencing products
  • Building materials and home improvement catalogs
  • Outdoor furniture or garden product listings
  • Product landing pages with multiple color or finish options
  • Small business websites that need a lightweight product showcase section

It is especially useful when each product has:

  • A main visual image
  • Several color or finish options
  • A short list of selling points
  • A responsive layout requirement for both desktop and mobile devices

Highlights

1. Responsive Bootstrap Grid

The layout uses Bootstrap 5 responsive columns to achieve:

  • Desktop: 3 product cards per row
  • Tablet: adaptive multi-column layout
  • Mobile: 1 product card per row

2. Pure JavaScript Image Switching

Each product card contains its own independent image-switching logic. When a user clicks a swatch:

  • the main image updates instantly
  • the active swatch state changes
  • the selected color label is updated

3. No Swiper or Carousel Dependency

This project intentionally avoids slider libraries for a simpler use case. If the requirement is only click-to-switch image behavior, native JavaScript is often a better choice than a full carousel solution.

4. Reusable Card Structure

The HTML structure is easy to duplicate and customize for more products. Each card can be extended with:

  • custom pricing
  • product descriptions
  • CTA buttons
  • badges
  • links to product detail pages

5. Easy GitHub and Deployment Friendly

Because the project is based on standard front-end technologies, it can be:

  • uploaded directly to GitHub
  • deployed on GitHub Pages
  • integrated into WordPress templates
  • embedded into existing Bootstrap-based websites

Project Structure

.
├── index.html
├── css/
├── images/
├── js/
├── README.md
└── screenshots/
    └── desktop-preview.png

You can rename files based on your own repository structure.


Screenshots

Add your screenshots to the screenshots folder and update the file names if needed.

Desktop Preview

Desktop Preview


How It Works

The interaction is based on simple data attributes. Each swatch button stores:

  • the target image URL
  • the target color name

When clicked, JavaScript updates the corresponding elements inside the same product card. This makes the component modular and easy to scale across multiple product blocks.


Future Improvements

Here are some possible directions for future enhancement:

1. Dynamic Data Rendering

Load product content from:

  • JSON
  • CMS fields
  • WordPress custom fields
  • API responses

This would make the page easier to manage for larger catalogs.

2. Product Detail Modal or Dedicated Page Links

Add:

  • “View Details” buttons
  • modal popups
  • product detail page links

This can improve navigation and conversion flow.

3. Accessibility Enhancements

Further improve accessibility by adding:

  • stronger keyboard navigation support
  • ARIA state feedback
  • better screen-reader labels
  • focus-visible interaction styles

4. Image Optimization

Improve performance by using:

  • WebP or AVIF images
  • responsive image sizes
  • lazy loading
  • optimized asset delivery

5. Animation and Transition Refinement

Add subtle fade transitions when switching images to create a more polished UI experience.

6. CMS / WordPress Integration

Convert the component into:

  • a WordPress page template
  • a Gutenberg block
  • a reusable shortcode module
  • a custom plugin-based product showcase section

Getting Started

  1. Clone or download this repository.
  2. Open index.html in your browser.
  3. Replace the demo content and image URLs with your own product data.
  4. Add your screenshots to the screenshots folder.
  5. Update the README paths if your screenshot names are different.

License

This project is licensed under the MIT License.

About

A responsive Bootstrap 5 product grid with vanilla JavaScript color swatch image switching for desktop and mobile.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages