StealThis .dev

Cookbook — Recipe rating + reviews block

A warm, editorial recipe rating and reviews block with an aggregate star score, a five-to-one star distribution chart, an accessible interactive star input that optimistically updates the aggregate, and a sortable list of reader reviews complete with avatar initials, made-it badges, dates, and toggleable helpful counts. Built with semantic HTML, a cookbook palette, and dependency-free vanilla JavaScript.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Recipe rating + reviews block

A self-contained social-proof block for a recipe page. The header pairs a CSS-gradient “food photo” with an editorial serif title, then leads into a large aggregate score (4.7 ★), a partial-fill star bar, the total rating count, and a five-to-one star distribution chart whose bars are sized from the live data.

The “Made this? Rate it” control is a real accessible radio group of five stars. Hovering or focusing fills the stars, and choosing a rating optimistically folds your vote into the aggregate average and the distribution bars, announces the result via an aria-live region, and confirms with a toast. Changing your mind reassigns the vote instead of double-counting it.

Below, reviews render from a small data set with avatar initials, names, partial-fill stars, a ”🍳 Made it” badge, a formatted date, the review text, and a helpful button that toggles its pressed state and count. A sort menu switches between most helpful, newest, and highest rated, and re-sorts live when helpful votes change. Everything is keyboard-usable, WCAG-AA contrasted, and collapses to a single column around 720px.

Illustrative UI only — recipes & nutrition data are fictional, not dietary advice.