Star Rating
Five stars that follow the pointer and stay set on click, built on plain radio buttons so arrow keys work too. For a quick review after an appointment or order.
How to use it
- Paste the HTML where the forms & inputs should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Star Rating · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<form class="str" novalidate>
<fieldset class="str__veld">
<legend class="str__vraag">Hoe was uw afspraak bij Kapsalon Mira?</legend>
<div class="str__rij">
<input class="str__keuze" type="radio" name="str-cijfer" id="str-c1" value="1"><label class="str__ster" for="str-c1"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.1 14.59 9.04 21.99 9.36 16.18 13.96 18.17 21.09 12 17 5.83 21.09 7.82 13.96 2.01 9.36 9.41 9.04Z"/></svg><span class="str__verborgen">1 van 5, slecht</span></label>
<input class="str__keuze" type="radio" name="str-cijfer" id="str-c2" value="2"><label class="str__ster" for="str-c2"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.1 14.59 9.04 21.99 9.36 16.18 13.96 18.17 21.09 12 17 5.83 21.09 7.82 13.96 2.01 9.36 9.41 9.04Z"/></svg><span class="str__verborgen">2 van 5, matig</span></label>
<input class="str__keuze" type="radio" name="str-cijfer" id="str-c3" value="3"><label class="str__ster" for="str-c3"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.1 14.59 9.04 21.99 9.36 16.18 13.96 18.17 21.09 12 17 5.83 21.09 7.82 13.96 2.01 9.36 9.41 9.04Z"/></svg><span class="str__verborgen">3 van 5, redelijk</span></label>
<input class="str__keuze" type="radio" name="str-cijfer" id="str-c4" value="4"><label class="str__ster" for="str-c4"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.1 14.59 9.04 21.99 9.36 16.18 13.96 18.17 21.09 12 17 5.83 21.09 7.82 13.96 2.01 9.36 9.41 9.04Z"/></svg><span class="str__verborgen">4 van 5, goed</span></label>
<input class="str__keuze" type="radio" name="str-cijfer" id="str-c5" value="5"><label class="str__ster" for="str-c5"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.1 14.59 9.04 21.99 9.36 16.18 13.96 18.17 21.09 12 17 5.83 21.09 7.82 13.96 2.01 9.36 9.41 9.04Z"/></svg><span class="str__verborgen">5 van 5, uitstekend</span></label>
</div>
</fieldset>
<p class="str__status" aria-live="polite">Nog geen keuze gemaakt</p>
<button class="str__knop" type="submit" disabled>Versturen</button>
</form>
</div>/* Star Rating · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.str{margin:0;padding:24px;font-family:Switzer,sans-serif;text-align:center;width:100%;max-width:380px;box-sizing:border-box}
.str__veld{border:0;margin:0;padding:0;min-width:0}
.str__vraag{padding:0;margin:0 auto 14px;font-size:18px;font-weight:600;color:#0a0a0a;line-height:1.3}
.str__rij{display:flex;justify-content:center;gap:4px}
.str__keuze{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none}
.str__ster{display:block;width:40px;height:40px;padding:2px;cursor:pointer;border-radius:4px;transition:transform .18s ease}
.str__ster svg{display:block;width:100%;height:100%}
.str__ster path{fill:#dedbd5;stroke:#dedbd5;stroke-width:1.4;stroke-linejoin:round;transition:fill .15s ease,stroke .15s ease}
.str__ster.is-aan path{fill:#F5480F;stroke:#F5480F}
.str__ster.is-voorproef path{fill:#f8875f;stroke:#f8875f}
.str__ster.is-tik{animation:str-tik .32s ease}
@keyframes str-tik{40%{transform:scale(1.22)}100%{transform:scale(1)}}
.str__keuze:focus-visible+.str__ster{outline:2px solid #0a0a0a;outline-offset:2px}
.str__verborgen{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.str__status{margin:12px 0 16px;font-size:15px;color:#55524d;min-height:22px}
.str__knop{font:inherit;font-size:15px;font-weight:500;padding:10px 22px;border:0;border-radius:4px;background:#0a0a0a;color:#fff;cursor:pointer;transition:background-color .15s ease}
.str__knop:hover:not(:disabled){background:#F5480F}
.str__knop:disabled{background:#c9c6c0;cursor:not-allowed}
.str__knop:focus-visible{outline:2px solid #F5480F;outline-offset:2px}
@media (max-width:480px){.str{padding:16px}.str__vraag{font-size:16px}.str__ster{width:36px;height:36px}}
@media (prefers-reduced-motion:reduce){.str__ster.is-tik{animation:none}}// Star Rating · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
var f=root.querySelector('.str'); if(!f) return;
var sterren=[].slice.call(f.querySelectorAll('.str__ster')), keuzes=[].slice.call(f.querySelectorAll('.str__keuze'));
var status=f.querySelector('.str__status'), knop=f.querySelector('.str__knop');
var WOORD=['Slecht','Matig','Redelijk','Goed','Uitstekend'], gekozen=0;
function toon(n,voorproef){
sterren.forEach(function(s,i){ s.classList.toggle('is-aan',!voorproef&&i<n); s.classList.toggle('is-voorproef',!!voorproef&&i<n); });
if(n) status.textContent=n+' van 5 · '+WOORD[n-1]; else status.textContent='Nog geen keuze gemaakt';
}
sterren.forEach(function(s,i){
s.addEventListener('pointerenter',function(e){ if(e.pointerType==='mouse') toon(i+1,true); });
});
f.querySelector('.str__rij').addEventListener('pointerleave',function(){ toon(gekozen,false); });
keuzes.forEach(function(k,i){ k.addEventListener('change',function(){
gekozen=i+1; toon(gekozen,false); knop.disabled=false;
var s=sterren[i]; s.classList.remove('is-tik'); void s.offsetWidth; s.classList.add('is-tik');
}); });
f.addEventListener('submit',function(e){ e.preventDefault(); if(!gekozen) return; status.textContent='Bedankt, we hebben '+gekozen+' van 5 genoteerd.'; knop.disabled=true; });
}
init(document.querySelector('.jouw-container'));
More forms & inputs
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →