Kinetic Rating

A star rating you can click or drive with the keyboard. The chosen star pops, and a read-only mode shows a score without editing.

  • <kt-kinetic-rating>
  • Selection
  • No framework

Kinetic Rating

The code

Copy the Kinetic Rating

Fastest: press Copy on the card above for one complete file. To build it into your own project, use the files below: the markup, the styles, this component’s script and the shared effects script (effects.js) that every component uses.

<kt-kinetic-rating label="Rate this release" value="4" max="5"></kt-kinetic-rating>

<kt-kinetic-rating label="Support experience" max="5"></kt-kinetic-rating>

<kt-kinetic-rating label="Average review" value="3" max="5" readonly></kt-kinetic-rating>

Attributes

NameWhat it doesDefault
maxNumber of stars, 1 to 10.5
valueChosen number of stars; 0 means no rating yet.0
labelText above the stars and the name of the group.Rating
readonlyPresent to show the score without letting people change it.—
disabledPresent when the rating cannot be used.—
sfxSound-effect text when a star is chosen.キラッ!

Keyboard and screen readers

  • A radiogroup of radios named "1 star", "2 stars" and so on; only the chosen star (or the first) is in the Tab order.
  • ArrowRight and ArrowUp choose the next star; ArrowLeft and ArrowDown the previous; Home and End choose the first and last.
  • Space or Enter chooses the focused star; 0 or Delete clears the rating.
  • Readonly sets aria-readonly and ignores input. Hover previews the rating for pointer users only.
  • Fires change with { value, max }.

Styling variables

Every look is a CSS variable: --kt-accent, --kt-accent-ink, --kt-radius-btn, --kt-surface-radius, --kt-surface-bg, --kt-border-w, --kt-comp-shadow and --font-sans. The copied file sets them all from your choices.

FAQ

Kinetic Rating: questions answered

How do I use the Kinetic Rating?

Press Copy on the card to get a complete HTML file, or copy the HTML, CSS and JavaScript tabs into your own page. In your markup the element is written as <kt-kinetic-rating>.

Which attributes does <kt-kinetic-rating> accept?

max, value, label, readonly, disabled, sfx. Each one is described in the attributes table on this page.

Is the Kinetic Rating accessible?

A radiogroup of radios named "1 star", "2 stars" and so on; only the chosen star (or the first) is in the Tab order. ArrowRight and ArrowUp choose the next star; ArrowLeft and ArrowDown the previous; Home and End choose the first and last. Space or Enter chooses the focused star; 0 or Delete clears the rating. Readonly sets aria-readonly and ignores input. Hover previews the rating for pointer users only. Fires change with { value, max }.

Can I change the Kinetic Rating colors, corners and font?

Yes. Use the options on this page: accent color, border radius, background, border, shadow and Google font. The copied code already contains your choices, and every one of them is a CSS variable you can edit later.