Vanilla UI Kit Rating v1.0.0 · tabs →

Star ratings, one file.

Zero-dependency rating input and display that follows your page's theme on its own. Hover, click, or Tab in and use the arrow keys — every card is live.

Basic, half steps

Hover the left half of a star for .5. One tab stop, arrow keys step by 0.5.

value: 3.5
new Rating('#basic', {
  value: 3.5,
  onChange: v => console.log(v)
})

Hearts

Built-in heart icon, same gold fill — or pass your own { empty, full } SVG pair.

new Rating('#hearts', {
  icon: 'heart', value: 2
})

Read-only average

Fractions render exactly — the fill is a clipped overlay, so a 4.3 average shows a 30% fifth star. No focus, no interaction.

4.3 · 1,284 reviews
new Rating('#avg', {
  value: 4.3, readOnly: true, size: 18
})

Max 10 + value text

showValue prints the live number after the stars; keys 1–9 jump straight to a value.

new Rating('#ten', {
  max: 10, value: 7, half: false,
  size: 18, showValue: true
})

In a real form

Enhancing an <input> hides and syncs it — it still submits, still fires change, and destroy() restores it.

<input id="score" name="score" value="3">
new Rating('#score')   // submits score=3.5

Clearable

Clicking the value that's already committed clears back to 0 (default). Set clearable: false to keep ratings sticky — try both below.

clearable — click ★3 twice
clearable: false
new Rating(el, { clearable: false })