About this set
Star ratings that use newer CSS for things that used to need tricks or JavaScript. :has() input, no reversed markup rates a barista with radios inside their labels in plain 1 to 5 order. A star is filled when its own radio is checked or when a later label holds the checked radio, and hover previews the same way, so there is no reversed markup and no hidden zero radio; a reset button clears the choice and the chosen value appears as text. @property animated fill shows three cafe scores where a registered number property animates from zero to the score on load, driving both the star fill and a ring around the number. Container queries places one rating widget in a 200 pixel slot, a 340 pixel slot and a full-width slot: the narrow one shows a single star and the count, the middle one five stars and the word reviews, and the wide one adds distribution bars, all decided by the width of the slot rather than the window.
What’s included
- :has() star input in natural order with hover preview
- Reset button clears the rating without JavaScript
- @property animates the fill and a conic ring
- Container queries switch the widget layout by slot width
- Animation stops under prefers-reduced-motion
Accessibility
The input is a fieldset with a legend and radios named 1 star to 5 stars, with a 3px outline on the focused star and a bar under the chosen one. Animated scores are real text, such as Rated 4.6 out of 5, and only the graphics animate; under prefers-reduced-motion they show the final value at once. The container query widget keeps the rating text in every layout, and the reviews count is never read twice.
Customise it
Change --mc-on, --mc-off, --mc-edge, --mc-accent and --mc-focus on .mc. Set --to on each tile for its score, and adjust the 300px and 560px container breakpoints. In Tailwind edit the mc colours in @theme and the @min-[300px]: and @min-[560px]: classes.






