Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Ratings and Reviews styles

Customize the review list and page controls with CSS in your Product Reviews block. The drop-in uses design tokens, shared CSS variables such as --spacing-medium and --color-neutral-700. Changes to these variables carry through to the drop-in’s styles. For tokens, breakpoints, and general guidance, see CSS customization.

The Product Reviews block from the quick start uses this stylesheet to control section spacing and hidden states:

blocks/product-reviews/product-reviews.css
/* Separates the reviews section from the content above it. */
.product-reviews {
margin-block-start: var(--spacing-xxbig);
}
/* Keeps the block hidden while reviews are turned off or loading has not started. */
.product-reviews[hidden] {
display: none;
}
.product-reviews .product-reviews__pagination {
min-width: 0;
margin-block: var(--spacing-medium);
}
/* Removes the pagination spacing when there is only one page. */
.product-reviews .product-reviews__pagination:has(.ratingsreviews-pagination[hidden]) {
display: none;
}
  • .product-reviews: The block wrapper. The block sets its hidden attribute until reviews can load.
  • .product-reviews__list: The element that holds the Review container.
  • .product-reviews__pagination: The element that holds the Pagination container. The CSS hides this element when the container is hidden.

Class names start with ratingsreviews-. A double underscore (__) separates a component name from the name of an element inside it.

ClassElement
.ratingsreviews-reviewReview wrapper. Its data-state attribute is loading, ready, empty, unavailable, or error.
.ratingsreviews-review__statusStatus message. Visually hidden in the loading state.
.ratingsreviews-review__skeletonPlaceholder shown while reviews load.
.ratingsreviews-review__listThe list of review rows.
.ratingsreviews-review-itemOne review row.
.ratingsreviews-review-item__authorReviewer name.
.ratingsreviews-review-item__contentRating, date, title, and text.
.ratingsreviews-review-item__metaRating and date row.
.ratingsreviews-review-item__summaryReview title.
.ratingsreviews-review-item__textReview text. Preserves the shopper’s line breaks.
.ratingsreviews-star-ratingStars and value in a review row.
.ratingsreviews-star-rating__starOne star.
.ratingsreviews-star-rating__fillThe filled part of one star.
.ratingsreviews-star-rating__valueThe numeric rating, for example, 4.0.
.ratingsreviews-paginationPagination wrapper.
.ratingsreviews-pagination__controlsPage controls. Disabled and dimmed while a page loads.

The WriteReview form uses these classes for its product summary, rating inputs, and messages:

ClassElement
.ratingsreviews-write-reviewWriteReview wrapper. Its data-state attribute is ready, error, success, or signIn.
.ratingsreviews-write-review__formThe form. The submit button fills its width.
.ratingsreviews-write-review__topProduct summary and rating rows, above a divider.
.ratingsreviews-write-review__productProduct image and name.
.ratingsreviews-write-review__imageProduct image, 80 pixels wide.
.ratingsreviews-write-review__nameProduct name.
.ratingsreviews-write-review__ratingsAll rating rows.
.ratingsreviews-write-review__ratingOne rating row with its label and error message.
.ratingsreviews-write-review__labelRating category name or Give your rating.
.ratingsreviews-write-review__errorSelect a rating. message.
.ratingsreviews-write-review__load-errorMessage when the rating categories cannot load.
.ratingsreviews-star-rating-inputRating input with one radio button for each star.
.ratingsreviews-star-rating-input__starOne selectable star. Also has .ratingsreviews-star-rating-input__star--filled when it is at or below the selected rating.

Review rows respond to the width of the Review container, not the browser window. The wrapper defines a CSS container named ratingsreviews-review. Container queries apply layout rules based on that width:

  • At least 900 pixels: Each row places the author in a narrow column beside the review content.
  • Below 900 pixels: The author appears above the content. This layout also applies in narrow containers, such as a sidebar or modal.

Add these rules to blocks/product-reviews/product-reviews.css.

blocks/product-reviews/product-reviews.css
/* Shows the error state in a highlighted panel. */
.product-reviews .ratingsreviews-review[data-state='error'] .ratingsreviews-review__status {
padding: var(--spacing-small);
border-radius: var(--shape-border-radius-1);
background-color: var(--color-alert-200);
}
/* Changes the filled star color. The star fill uses the text color (currentcolor). */
.product-reviews .ratingsreviews-star-rating__fill {
color: var(--color-brand-500);
}
/* Uses the side-by-side row layout on narrower containers. */
@container ratingsreviews-review (width >= 600px) {
.product-reviews .ratingsreviews-review-item {
grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
}
}
  • Error state: The data-state='error' selector adds padding and a highlighted background to the status message.
  • Star color: The fill uses currentcolor, which takes its value from the CSS color property. Changing that property changes the filled star color.
  • Row layout: The container query starts the side-by-side layout at a container width of 600 pixels instead of the default 900 pixels.

Use your browser’s developer tools to inspect the SDK header, divider, and page controls that the containers render.