A Bootstrap 5 customer reviews section where buyers can show their own photos: a rating summary with distribution bars and a photo strip, a sortable list of reviews with photo thumbnails, helpful votes and a lightbox for the full-size images. Ideal for product pages of home decor, fashion or furniture shops.
How it works
The root section.rcp-reviews is split into two Bootstrap columns. The left .rcp-summary card shows the average score, the .rcp-bars distribution (Bootstrap progress bars sized with classes such as .rcp-w-78), the .rcp-gallery with every customer photo and a "Write a review" button. From the lg breakpoint the card is sticky. The right column holds the .rcp-toolbar with a sort select and the .rcp-list of article.rcp-review elements. From md up each review becomes a CSS grid with named areas, so the photos sit to the right of the text.
Every photo is a button.rcp-thumb with data-rcp-group, data-rcp-full (the large image URL) and data-rcp-author. On click the script collects all thumbnails of the same group, fills the .rcp-modal lightbox with the large image, caption and a counter, and opens it with bootstrap.Modal. The previous and next buttons and the arrow keys move through the group. The summary strip uses the group all, so it browses every photo.
Each .rcp-vote group has two .rcp-vote__btn buttons. Pressing one toggles aria-pressed, updates .rcp-vote__count and releases the opposite vote. Changing .rcp-sort reorders the reviews by helpful votes, data-rcp-date or data-rcp-rating.
Customization
--rcp-accent,--rcp-bgand--rcp-staron.rcp-reviewsinstyle.css: change the terracotta accent, the section background and the star color.--rcp-thumbon.rcp-reviews: make the review photo thumbnails larger or smaller.--rcp-radiuson.rcp-reviews: round or square the cards, thumbnails and lightbox.data-rcp-dateanddata-rcp-ratingon each.rcp-review: fill them from your data so the Newest and Highest rating sort options work.data-rcp-groupon.rcp-thumb: thumbnails with the same value are browsed together in the lightbox..rcp-w-78and the other width classes: replace them with your real distribution, or set the width from your template.- The comment in the vote click handler in
script.js: add afetch()call there to store votes on your server.
Use cases
- Product detail pages: a rating summary and customer photo gallery build buyer trust
- Online stores: a lightbox lets shoppers view review photos at full size
- Marketplaces: helpful votes help surface the most useful customer reviews for other shoppers
- Review sections: sorting helps visitors find recent or top-rated opinions
Accessibility
The section is labelled by its heading and every review is an article labelled by its title. Star ratings are single role="img" elements with text such as "4 out of 5 stars", and the distribution bars have aria-label and aria-valuenow. The script gives every thumbnail an aria-label starting with "Enlarge photo" and aria-haspopup="dialog". The lightbox is a Bootstrap modal with focus trapping; its counter is a polite live region and focus returns to the thumbnail when it closes. Vote buttons use aria-pressed. Focus outlines are visible; hover zoom stops with prefers-reduced-motion.
Usage notes
Requires Bootstrap 5 and Bootstrap Icons. The photos come from Unsplash; replace them with your customers' uploads. Several sections can share a page; the script adds suffixes to the ids of every extra instance.