Block 34 of 297
Rating Summary
Overall star rating with a text equivalent, per-star distribution bars, review count, source and highlighted reviews.
- Puck key
- RatingSummaryBlock
- Export
- ratingSummaryBlock
- React component
- <RatingSummary />
- Path
- components/puck/rating-summary-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
An overall score panel with partial-fill stars, a review count, a bar for each star level and a source line, beside up to six highlighted reviews. The score can be typed in or calculated from the star counts. On desktop the panel sits in a narrow left column; on phones it comes before the reviews.
- Camp, class or program satisfaction survey results
- Visitor ratings for a park, museum or facility
- Event feedback summaries on a recap page
Writing the content
- Enter whole numbers in the 5-star to 1-star reviews fields; bar lengths and the review total come from them.
- Leave Overall rating blank to calculate it from the counts. If you type one, make sure it matches them.
- Always fill in Source with where and when the ratings were collected; the default text is labeled sample data.
- Include at least one mixed review among the Highlighted reviews; a range reads as more credible.
Accessibility
- Stars are aria-hidden and the score is given in text as "4.8 out of 5 stars", with "Rated 4 out of 5" for each review, so ratings don't depend on the graphic (WCAG 1.1.1).
- The breakdown is a list labeled "Rating breakdown", and each bar has its percentage plus a hidden review count in text.
- Review headlines are headings one level below the section heading, inside article elements.
Customizing the code
- Filled stars and bars use text-indigo-600 and bg-indigo-600; the star shape is the STAR path constant.
- The panel and reviews split is lg:col-span-5 xl:col-span-4 against lg:col-span-7 xl:col-span-8.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Headingtext
- Heading levelselect
- Introtextarea
- Overall ratingtext
- 5-star reviewstext
- 4-star reviewstext
- 3-star reviewstext
- 2-star reviewstext
- 1-star reviewstext
- Sourcetext
- Highlighted reviewsarray