Star rating
Five star rating with hover preview, built from radio buttons.
Corners
Shadow
Motion
<style>
.ux-stars{display:inline-flex;flex-direction:row-reverse;gap:4px}
.ux-stars input{position:absolute;opacity:0;pointer-events:none}
.ux-stars label{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;font-size:32px;line-height:1;color:var(--line,#cfd2da);cursor:pointer;border-radius:calc(4px * var(--r,1));transition:color var(--dur,.15s) var(--ease,ease),transform var(--dur,.15s) var(--ease,ease)}
.ux-stars input:checked~label,.ux-stars label:hover,.ux-stars label:hover~label{color:var(--accent,#cc4a26)}
.ux-stars label:active{transform:scale(.92)}
.ux-stars input:focus-visible+label{outline:2px solid var(--accent,#cc4a26);outline-offset:2px}
</style>
<div class="ux-stars" role="radiogroup" aria-label="Rating"><input type="radio" name="ux-star" id="ux-st5"><label for="ux-st5" title="5 stars">★</label><input type="radio" name="ux-star" id="ux-st4" checked><label for="ux-st4" title="4 stars">★</label><input type="radio" name="ux-star" id="ux-st3"><label for="ux-st3" title="3 stars">★</label><input type="radio" name="ux-star" id="ux-st2"><label for="ux-st2" title="2 stars">★</label><input type="radio" name="ux-star" id="ux-st1"><label for="ux-st1" title="1 star">★</label></div>When to use it
Reach for this when someone has to pick from a small, visible set of options rather than typing free text. It works best when every choice fits on screen at once.
Accessibility
It is fully keyboard operable: tab to it and use the keys you would expect (space, enter or the arrow keys) to change its value, with a visible focus ring so sighted keyboard users can always see where they are. It has no JavaScript dependency, so it keeps working if a script fails to load, and it is built on native form controls or semantics rather than divs pretending to be one. Colors are read from CSS custom properties, so they follow your light or dark theme and you can raise contrast globally without touching this component.