Review Card with Star Rating

Display customer feedback and product ratings with this clean and accessible user review card.

This is an indispensable component for any e-commerce site, booking platform, or listing service to build social proof and help users make informed decisions.

Screenshot of three user review cards with different star ratings and content.

Get Source Code Preview

About this Component

This card is structured to present all the essential elements of a user review. In particular it includes a star rating, a title, the review text, and author information. The CSS-driven star rating system is both easy to implement and accessible.

Features

Code Breakdown

HTML Structure

The star rating (.review-card-stars) contains two important parts for accessibility. First, a span with a .visually-hidden class explicitly states the rating (e.g., "Rating: 4 out of 5 stars"). Second, the visual star svg elements are marked with aria-hidden="true" so that screen readers ignore them and read the text description instead. To show a specific rating, you apply the .star-filled class to the appropriate number of stars.

CSS Styling

The stars are colored using a simple CSS class system. The default color of the star container is a light gray for "empty" stars. The .star-filled class then overrides this with a prominent gold color. A helper class, .visually-hidden, is used to hide the accessibility text from sighted users by moving it off-screen without removing it from the document flow. The card's vertical structure is managed with display: flex and flex-grow: 1 on the main body, ensuring the footer aligns nicely.

Code

Here's the complete, self-contained code. To set a rating, simply add the .star-filled class to the desired number of stars, and update the text in the visually-hidden span accordingly.

View Output