StealThis .dev

Rating Stars

Interactive star rating component — hover preview, click to set, half-star display support, readonly mode.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Rating Stars

Star rating widget with hover preview and click-to-set interaction. Supports half-star display in readonly mode. Keyboard accessible via arrow keys.

Variants

VariantDescription
Interactive 5-starClick or hover to set rating
Readonly 4.5 starsHalf-star support via CSS clip-path
Readonly 3 starsStatic display

Implementation

Stars are rendered as SVG paths. Interactive mode uses mouseover / click events. The half-star in readonly mode is achieved by overlaying a filled star clipped to 50% width over an empty star.