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
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>
kt-kinetic-rating {
display: block;
width: 100%;
max-width: 340px;
}
.kt-rating {
--_color: var(--kt-accent);
--_ink: var(--kt-accent-ink);
padding: 12px 14px 13px;
border-radius: var(--kt-surface-radius);
border-style: solid;
border-width: var(--kt-card-border-w);
border-color: var(--kt-comp-border, var(--kt-surface-border));
background: var(--kt-surface-bg);
color: var(--kt-surface-ink);
box-shadow: var(--kt-comp-shadow);
transition: border-color 160ms ease, box-shadow 180ms ease, border-width 150ms ease;
}
.kt-rating.is-disabled {
opacity: 0.55;
}
.kt-rating-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 8px;
}
.kt-rating-label {
font-family: var(--font-mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--kt-surface-muted);
}
.kt-rating-readout {
min-width: 36px;
padding: 4px 7px;
border-radius: var(--kt-radius-tag);
background: color-mix(in srgb, var(--_color) 14%, transparent);
font-family: var(--font-mono);
font-size: 11px;
font-weight: 700;
line-height: 1;
text-align: center;
color: var(--kt-surface-ink);
font-variant-numeric: tabular-nums;
}
.kt-rating-stars {
display: flex;
flex-wrap: wrap;
gap: 2px;
}
.kt-rating-star {
display: grid;
place-items: center;
width: 36px;
height: 36px;
flex: 0 0 auto;
border-radius: var(--kt-radius-tag);
color: var(--kt-surface-muted);
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
transition: color 140ms ease, transform 160ms var(--ease-snap);
}
.kt-rating-star svg {
width: 26px;
height: 26px;
fill: transparent;
stroke: currentColor;
stroke-width: 1.7;
transition: fill 150ms ease;
}
.kt-rating-star.is-on {
color: var(--_color);
}
.kt-rating-star.is-on svg {
fill: currentColor;
}
.kt-rating-star.is-preview {
color: color-mix(in srgb, var(--_color) 70%, var(--kt-surface-ink));
}
.kt-rating-star.is-preview svg {
fill: color-mix(in srgb, currentColor 45%, transparent);
}
.kt-rating-star:hover {
transform: scale(1.1);
}
.kt-rating-star:focus-visible {
outline: 2px solid var(--kt-surface-ink);
outline-offset: 1px;
}
.kt-rating.is-readonly .kt-rating-star,
.kt-rating.is-disabled .kt-rating-star {
cursor: default;
}
.kt-rating.is-readonly .kt-rating-star:hover,
.kt-rating.is-disabled .kt-rating-star:hover {
transform: none;
}
.kt-rating.is-disabled .kt-rating-star {
cursor: not-allowed;
}
@media (max-width: 360px) {
.kt-rating-star { width: 32px; height: 32px; }
.kt-rating-star svg { width: 24px; height: 24px; }
}
/* VFX pop on the chosen star */
[data-vfx="sakuga"] .kt-rating-star.is-popping svg { animation: kt-rating-pop 380ms var(--ease-overshoot); }
[data-vfx="elastic"] .kt-rating-star.is-popping svg { animation: kt-rating-jelly 520ms cubic-bezier(0.34, 1.56, 0.64, 1); }
[data-vfx="glitch"] .kt-rating-star.is-popping svg { animation: kt-rating-glitch 220ms steps(4, end); }
[data-vfx="neon"] .kt-rating-star.is-popping svg {
filter: drop-shadow(0 0 6px var(--_color));
animation: kt-rating-pop 340ms var(--ease-snap);
}
[data-vfx="ink"] .kt-rating-star.is-popping svg { animation: kt-rating-ink 380ms var(--ease-overshoot); }
[data-vfx="neon"] .kt-rating-star.is-on svg {
filter: drop-shadow(0 0 4px color-mix(in srgb, var(--_color) 70%, transparent));
}
@keyframes kt-rating-pop {
0% { transform: scale(0.6) rotate(-14deg); }
50% { transform: scale(1.35) rotate(6deg); }
100% { transform: scale(1) rotate(0); }
}
@keyframes kt-rating-jelly {
0% { transform: scale(0.6, 1.3); }
35% { transform: scale(1.35, 0.8); }
68% { transform: scale(0.92, 1.08); }
100% { transform: scale(1, 1); }
}
@keyframes kt-rating-glitch {
0% { transform: translate(-3px, 1px) skewX(-14deg); }
50% { transform: translate(3px, -1px) skewX(10deg); }
100% { transform: translate(0, 0) skewX(0); }
}
@keyframes kt-rating-ink {
0% { transform: scale(1.3, 0.7) rotate(-10deg); }
55% { transform: scale(0.9, 1.15) rotate(4deg); }
100% { transform: scale(1, 1) rotate(0); }
}
class KtKineticRating extends HTMLElement {
static get observedAttributes() {
return ["max", "value", "label", "readonly", "disabled", "sfx"];
}
constructor() {
super();
this._rendered = false;
this._stars = [];
this._popTimer = null;
this._hover = 0;
this._uid = `kt-rating-${Math.random().toString(36).slice(2, 8)}`;
}
connectedCallback() {
if (!this._rendered) {
this.render();
this._rendered = true;
}
this.syncAttributes();
}
disconnectedCallback() {
clearTimeout(this._popTimer);
}
attributeChangedCallback(name) {
if (!this._rendered) return;
if (name === "max") this.render();
this.syncAttributes();
}
get max() {
const n = parseInt(this.getAttribute("max") || "5", 10);
return Number.isFinite(n) ? Math.min(Math.max(n, 1), 10) : 5;
}
get value() {
const n = parseInt(this.getAttribute("value") || "0", 10);
return Number.isFinite(n) ? Math.min(Math.max(n, 0), this.max) : 0;
}
set value(val) { this.setAttribute("value", String(val)); }
get label() { return this.getAttribute("label") || "Rating"; }
get readOnly() { return this.hasAttribute("readonly"); }
get disabled() { return this.hasAttribute("disabled"); }
get sfx() { return this.getAttribute("sfx") ?? "キラッ!"; }
render() {
this.innerHTML = "";
const wrap = document.createElement("div");
wrap.className = "kt-rating";
wrap.innerHTML = `
<div class="kt-rating-head">
<span class="kt-rating-label" id="${this._uid}-label"></span>
<span class="kt-rating-readout" aria-hidden="true"></span>
</div>
<div class="kt-rating-stars" role="radiogroup"></div>
`;
this._wrap = wrap;
this._labelEl = wrap.querySelector(".kt-rating-label");
this._readout = wrap.querySelector(".kt-rating-readout");
this._group = wrap.querySelector(".kt-rating-stars");
this._group.setAttribute("aria-labelledby", this._labelEl.id);
this._stars = [];
for (let i = 1; i <= this.max; i++) {
const star = document.createElement("span");
star.className = "kt-rating-star";
star.setAttribute("role", "radio");
star.setAttribute("aria-label", `${i} ${i === 1 ? "star" : "stars"}`);
star.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2.6l2.9 6.1 6.7.8-4.9 4.6 1.3 6.6L12 17.4 5.9 20.7l1.3-6.6L2.3 9.5l6.7-.8L12 2.6z" stroke-linejoin="round"/></svg>`;
star.addEventListener("click", () => this.choose(i));
star.addEventListener("keydown", (e) => this.onKeydown(e, i));
star.addEventListener("pointerenter", (e) => {
if (e.pointerType === "touch" || this.readOnly || this.disabled) return;
this._hover = i;
this.paint();
});
this._group.appendChild(star);
this._stars.push(star);
}
this._group.addEventListener("pointerleave", () => {
this._hover = 0;
this.paint();
});
this.appendChild(wrap);
}
syncAttributes() {
if (!this._group) return;
const v = this.value;
this._labelEl.textContent = this.label;
this._group.toggleAttribute("aria-readonly", this.readOnly);
this._group.setAttribute("aria-disabled", String(this.disabled));
const focusable = v > 0 ? v : 1;
this._stars.forEach((star, idx) => {
const n = idx + 1;
star.setAttribute("aria-checked", String(n === v));
star.tabIndex = this.disabled ? -1 : n === focusable ? 0 : -1;
});
this._wrap.classList.toggle("is-readonly", this.readOnly);
this._wrap.classList.toggle("is-disabled", this.disabled);
this._readout.textContent = `${v} / ${this.max}`;
this.paint();
}
paint() {
const v = this.value;
const shown = this._hover || v;
this._stars.forEach((star, idx) => {
star.classList.toggle("is-on", idx < shown);
star.classList.toggle("is-preview", this._hover > 0 && idx < this._hover && idx >= v);
});
}
onKeydown(e, i) {
if (this.readOnly || this.disabled) return;
let next = null;
if (e.key === "ArrowRight" || e.key === "ArrowUp") next = Math.min(this.max, i + 1);
else if (e.key === "ArrowLeft" || e.key === "ArrowDown") next = Math.max(1, i - 1);
else if (e.key === "Home") next = 1;
else if (e.key === "End") next = this.max;
else if (e.key === " " || e.key === "Enter") next = i;
else if (e.key === "0" || e.key === "Delete" || e.key === "Backspace") {
e.preventDefault();
this.choose(0);
return;
}
if (next === null) return;
e.preventDefault();
this.choose(next);
this._stars[next - 1]?.focus({ preventScroll: true });
}
choose(n) {
if (this.readOnly || this.disabled) return;
const prev = this.value;
if (n === prev) return;
this.value = n;
this._hover = 0;
this.syncAttributes();
this.dispatchEvent(new CustomEvent("change", { bubbles: true, detail: { value: n, max: this.max } }));
if (n > 0) this.celebrate(n);
}
celebrate(n) {
if (SakugaFX.getMode() === "enterprise") return;
const star = this._stars[n - 1];
if (!star) return;
this._stars.forEach((s) => s.classList.remove("is-popping"));
void star.offsetWidth;
star.classList.add("is-popping");
clearTimeout(this._popTimer);
this._popTimer = setTimeout(() => star.classList.remove("is-popping"), 560);
const rect = star.getBoundingClientRect();
SakugaFX.emitImpact(rect.left + rect.width / 2, rect.top + rect.height / 2, readAccent(this._wrap), {
sfx: this.sfx,
scale: 0.75,
sfxY: rect.top - 4
});
}
}
customElements.define("kt-kinetic-rating", KtKineticRating);
function contrastInk(hex) {
const clean = hex.replace("#", "");
if (clean.length !== 6) return "#ffffff";
const r = parseInt(clean.slice(0, 2), 16);
const g = parseInt(clean.slice(2, 4), 16);
const b = parseInt(clean.slice(4, 6), 16);
const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
return lum > 0.6 ? "#09090b" : "#ffffff";
}
function readAccent(el) {
const val = getComputedStyle(el).getPropertyValue("--kt-accent").trim();
return val || "#09090b";
}
class SakugaVFXEngine {
constructor(canvas) {
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.items = [];
this.rafId = null;
this.lastTime = 0;
this.textEnabled = false;
this.textOverride = "";
this.vfxTextColor = "auto";
this.resize();
window.addEventListener("resize", () => this.resize());
}
attach(canvas) {
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.items = [];
this.resize();
}
resize() {
const dpr = Math.min(window.devicePixelRatio || 1, 2);
this.canvas.width = Math.floor(window.innerWidth * dpr);
this.canvas.height = Math.floor(window.innerHeight * dpr);
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
}
getMode() {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return "enterprise";
return document.documentElement.getAttribute("data-vfx") || "enterprise";
}
wake() {
if (this.rafId !== null) return;
this.lastTime = performance.now();
const tick = (now) => {
const dt = Math.min((now - this.lastTime) / 1000, 0.05);
this.lastTime = now;
this.render(dt);
if (this.items.length > 0) {
this.rafId = requestAnimationFrame(tick);
} else {
this.rafId = null;
this.ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
}
};
this.rafId = requestAnimationFrame(tick);
}
emitBurst(x, y, color, { count = 14, speed = 240, spread = Math.PI * 2, baseAngle = 0, shards = true } = {}) {
if (this.getMode() === "enterprise") return;
for (let i = 0; i < count; i++) {
const angle = baseAngle + (Math.random() - 0.5) * spread;
const vel = speed * (0.45 + Math.random() * 0.75);
this.items.push({
kind: shards && i % 3 === 0 ? "shard" : "spark",
x, y,
vx: Math.cos(angle) * vel,
vy: Math.sin(angle) * vel - (spread > 4 ? 35 : 0),
gravity: 400,
drag: 0.94,
size: 3 + Math.random() * 4,
rot: Math.random() * Math.PI * 2,
vrot: (Math.random() - 0.5) * 14,
life: 0,
maxLife: 0.32 + Math.random() * 0.22,
color
});
}
this.wake();
}
emitShockwave(x, y, color, maxRadius = 64) {
if (this.getMode() === "enterprise") return;
this.items.push({ kind: "ring", x, y, radius: 8, maxRadius, life: 0, maxLife: 0.32, color });
this.wake();
}
emitSlash(x, y, color, angle = -0.3) {
if (this.getMode() === "enterprise") return;
this.items.push({ kind: "slash", x, y, angle, length: 96, life: 0, maxLife: 0.2, color });
this.wake();
}
emitSmoke(x, y, color, dirX = 0) {
if (this.getMode() === "enterprise") return;
for (let i = 0; i < 4; i++) {
this.items.push({
kind: "smoke",
x: x + (Math.random() - 0.5) * 8,
y: y + (Math.random() - 0.5) * 8,
vx: dirX * (50 + Math.random() * 70) + (Math.random() - 0.5) * 35,
vy: -20 - Math.random() * 50,
size: 5 + Math.random() * 5,
life: 0,
maxLife: 0.34 + Math.random() * 0.16,
color
});
}
this.wake();
}
emitPixels(x, y, color, count = 14) {
if (this.getMode() !== "glitch") return;
for (let i = 0; i < count; i++) {
const angle = Math.floor(Math.random() * 8) * (Math.PI / 4);
const vel = 120 + Math.random() * 200;
this.items.push({
kind: "pixel",
x: x + (Math.random() - 0.5) * 18,
y: y + (Math.random() - 0.5) * 12,
vx: Math.cos(angle) * vel,
vy: Math.sin(angle) * vel,
size: 4 + Math.floor(Math.random() * 5),
life: 0,
maxLife: 0.24 + Math.random() * 0.14,
color
});
}
this.wake();
}
emitScanline(x, y, color, width = 120) {
if (this.getMode() !== "glitch") return;
for (let i = -1; i <= 1; i += 2) {
this.items.push({
kind: "scanline",
x,
y: y + i * (5 + Math.random() * 6),
width,
life: 0,
maxLife: 0.18,
color
});
}
this.wake();
}
emitRays(x, y, color, count = 10, maxRadius = 72) {
if (this.getMode() !== "neon") return;
for (let i = 0; i < count; i++) {
const angle = (Math.PI * 2 * i) / count + (Math.random() - 0.5) * 0.18;
this.items.push({
kind: "ray",
x,
y,
angle,
maxRadius: maxRadius * (0.75 + Math.random() * 0.45),
life: 0,
maxLife: 0.34,
color
});
}
this.wake();
}
emitInkSplatter(x, y, color, count = 14) {
if (this.getMode() !== "ink") return;
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI * 2;
const vel = 110 + Math.random() * 230;
this.items.push({
kind: "inkblot",
x,
y,
vx: Math.cos(angle) * vel,
vy: Math.sin(angle) * vel - 30,
gravity: 480,
drag: 0.91,
size: 2.5 + Math.random() * 5.5,
life: 0,
maxLife: 0.38 + Math.random() * 0.22,
color
});
}
// Brush arc sweep
this.items.push({
kind: "brusharc",
x,
y,
radius: 24 + Math.random() * 14,
startAngle: -Math.PI * 0.75,
endAngle: Math.PI * 0.35,
life: 0,
maxLife: 0.26,
color
});
this.wake();
}
emitMangaSFX(x, y, text, color) {
const mode = this.getMode();
const finalText = this.textOverride || text;
if (mode === "enterprise" || !this.textEnabled || !finalText || finalText === "none") return;
const fillColor = this.vfxTextColor !== "auto" ? this.vfxTextColor : color;
const outline = this.vfxTextColor !== "auto"
? contrastInk(this.vfxTextColor)
: (document.documentElement.getAttribute("data-bw") === "dark" ? "#09090b" : "#ffffff");
this.items.push({
kind: "sfx",
x: x + (Math.random() - 0.5) * 14,
y: y - 16,
vy: -48,
tilt: (Math.random() - 0.5) * 0.26,
text: finalText,
life: 0,
maxLife: 0.6,
color: fillColor,
outline
});
this.wake();
}
emitImpact(x, y, color, { sfx = "", scale = 1, dirX = 0, sfxY = y - 4 } = {}) {
const mode = this.getMode();
if (mode === "enterprise") return;
if (mode === "elastic") {
this.emitShockwave(x, y, color, Math.round(52 * scale));
this.emitSmoke(x, y, color, dirX);
} else if (mode === "glitch") {
this.emitPixels(x, y, color, Math.round(12 * scale));
this.emitScanline(x, y, color, Math.round(96 * scale));
} else if (mode === "neon") {
this.emitShockwave(x, y, color, Math.round(58 * scale));
this.emitRays(x, y, color, Math.round(9 * scale), Math.round(52 * scale));
} else if (mode === "ink") {
this.emitInkSplatter(x, y, color, Math.round(13 * scale));
} else {
this.emitShockwave(x, y, color, Math.round(50 * scale));
this.emitBurst(x, y, color, {
count: Math.round(12 * scale),
speed: Math.round(210 * scale),
spread: dirX ? 1.8 : Math.PI * 2,
baseAngle: dirX < 0 ? Math.PI : 0
});
this.emitSlash(x, y, color, -0.28);
}
this.emitMangaSFX(x, sfxY, sfx, color);
}
render(dt) {
const ctx = this.ctx;
ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
const next = [];
for (const p of this.items) {
p.life += dt;
if (p.life >= p.maxLife) continue;
const t = p.life / p.maxLife;
const easeOut = 1 - Math.pow(1 - t, 3);
const alpha = Math.max(0, 1 - Math.pow(t, 2));
ctx.save();
ctx.globalAlpha = alpha;
if (p.kind === "spark" || p.kind === "shard") {
p.vx *= Math.pow(p.drag, dt * 60);
p.vy = p.vy * Math.pow(p.drag, dt * 60) + p.gravity * dt;
p.x += p.vx * dt;
p.y += p.vy * dt;
p.rot += p.vrot * dt;
ctx.translate(p.x, p.y);
ctx.rotate(p.rot);
ctx.fillStyle = p.color;
if (p.kind === "shard") {
const s = p.size * (1 - t * 0.4);
ctx.beginPath();
ctx.moveTo(0, -s);
ctx.lineTo(s * 0.72, 0);
ctx.lineTo(0, s);
ctx.lineTo(-s * 0.72, 0);
ctx.closePath();
ctx.fill();
} else {
ctx.beginPath();
ctx.arc(0, 0, p.size * 0.5 * (1 - t * 0.5), 0, Math.PI * 2);
ctx.fill();
}
} else if (p.kind === "ring") {
const r = p.radius + (p.maxRadius - p.radius) * easeOut;
ctx.strokeStyle = p.color;
ctx.lineWidth = Math.max(1, 3 * (1 - t));
ctx.beginPath();
ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
ctx.stroke();
} else if (p.kind === "slash") {
ctx.translate(p.x, p.y);
ctx.rotate(p.angle);
const len = p.length * easeOut;
const th = 4.5 * (1 - t);
ctx.fillStyle = p.color;
ctx.beginPath();
ctx.moveTo(-len, 0);
ctx.quadraticCurveTo(0, -th, len, 0);
ctx.quadraticCurveTo(0, th, -len, 0);
ctx.fill();
} else if (p.kind === "smoke") {
p.x += p.vx * dt;
p.y += p.vy * dt;
const r = p.size * (0.8 + easeOut * 1.25);
ctx.fillStyle = p.color;
ctx.globalAlpha = 0.24 * (1 - t);
ctx.beginPath();
ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
ctx.fill();
} else if (p.kind === "pixel") {
p.x += p.vx * dt;
p.y += p.vy * dt;
ctx.fillStyle = p.color;
const s = p.size * (1 - t * 0.35);
ctx.fillRect(Math.round(p.x - s / 2), Math.round(p.y - s / 2), s, s);
} else if (p.kind === "scanline") {
const w = p.width * (0.4 + easeOut * 0.8);
ctx.fillStyle = p.color;
ctx.fillRect(p.x - w / 2, p.y, w, 2);
} else if (p.kind === "ray") {
const inner = 12 + easeOut * 16;
const outer = inner + p.maxRadius * (1 - t * 0.35);
ctx.strokeStyle = p.color;
ctx.shadowColor = p.color;
ctx.shadowBlur = 10;
ctx.lineWidth = Math.max(1, 2.8 * (1 - t));
ctx.beginPath();
ctx.moveTo(p.x + Math.cos(p.angle) * inner, p.y + Math.sin(p.angle) * inner);
ctx.lineTo(p.x + Math.cos(p.angle) * outer, p.y + Math.sin(p.angle) * outer);
ctx.stroke();
} else if (p.kind === "inkblot") {
p.vx *= Math.pow(p.drag, dt * 60);
p.vy = p.vy * Math.pow(p.drag, dt * 60) + p.gravity * dt;
p.x += p.vx * dt;
p.y += p.vy * dt;
ctx.fillStyle = p.color;
ctx.beginPath();
ctx.arc(p.x, p.y, p.size * (1 - t * 0.45), 0, Math.PI * 2);
ctx.fill();
} else if (p.kind === "brusharc") {
const sweep = p.startAngle + (p.endAngle - p.startAngle) * easeOut;
ctx.strokeStyle = p.color;
ctx.lineCap = "round";
ctx.lineWidth = Math.max(1.5, 6 * (1 - t));
ctx.beginPath();
ctx.arc(p.x, p.y, p.radius * (0.85 + easeOut * 0.4), p.startAngle, sweep);
ctx.stroke();
} else if (p.kind === "sfx") {
p.y += p.vy * dt * (1 - t * 0.6);
const s = t < 0.18 ? 0.55 + (t / 0.18) * 0.65 : 1.2 - (t - 0.18) * 0.25;
ctx.translate(p.x, p.y);
ctx.rotate(p.tilt);
ctx.scale(s, s);
ctx.font = '900 19px "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif';
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.lineJoin = "round";
ctx.lineWidth = 4.5;
ctx.strokeStyle = p.outline;
ctx.strokeText(p.text, 0, 0);
ctx.fillStyle = p.color;
ctx.fillText(p.text, 0, 0);
}
ctx.restore();
next.push(p);
}
this.items = next;
}
}
const SakugaFX = new SakugaVFXEngine(document.getElementById("sakuga-vfx-canvas"));
window.SakugaFX = SakugaFX;
window.readAccent = readAccent;
window.contrastInk = contrastInk;
Attributes
| Name | What it does | Default |
|---|---|---|
max | Number of stars, 1 to 10. | 5 |
value | Chosen number of stars; 0 means no rating yet. | 0 |
label | Text above the stars and the name of the group. | Rating |
readonly | Present to show the score without letting people change it. | — |
disabled | Present when the rating cannot be used. | — |
sfx | Sound-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.