Kinetic Badge
A small tag for status, category or count, in five tones and three styles, with an optional dot and remove button.
- <kt-kinetic-badge>
- Display
- No framework
The code
Copy the Kinetic Badge
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-badge tone="success" variant="soft" dot>Deployed</kt-kinetic-badge>
<kt-kinetic-badge tone="warning" variant="outline" size="sm">Beta</kt-kinetic-badge>
<kt-kinetic-badge tone="accent" variant="solid">New release</kt-kinetic-badge>
<kt-kinetic-badge tone="neutral" variant="soft" dismissible>design-system</kt-kinetic-badge>
<kt-kinetic-badge tone="error" variant="soft" dot dismissible>Build failed</kt-kinetic-badge>
kt-kinetic-badge {
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
kt-kinetic-badge[hidden],
.kt-badge[hidden],
.kt-badge-restore[hidden] {
display: none;
}
.kt-badge-restore {
min-height: 24px;
padding: 0 8px;
border: 1.5px dashed var(--bw-border-strong);
border-radius: var(--kt-radius-tag);
background: transparent;
color: var(--kt-surface-muted);
font-family: var(--font-mono);
font-size: 11px;
font-weight: 600;
cursor: pointer;
}
.kt-badge-restore:hover { color: var(--kt-surface-ink); border-color: var(--kt-surface-ink); }
.kt-badge-restore:focus-visible { outline: 2px solid var(--bw-ink); outline-offset: 2px; }
.kt-badge {
--_c: var(--bw-ink);
--_on: var(--bw-inverse);
--_h: 26px;
--_fs: 12px;
display: inline-flex;
align-items: center;
gap: 6px;
max-width: 100%;
box-sizing: border-box;
min-height: var(--_h);
padding: 0 10px;
border-radius: var(--kt-radius-tag);
border-style: solid;
border-width: var(--kt-border-w);
border-color: transparent;
font-family: var(--font-sans);
font-size: var(--_fs);
font-weight: 600;
line-height: 1;
white-space: nowrap;
user-select: none;
transition: transform 160ms ease, opacity 160ms ease, box-shadow 180ms ease;
}
.kt-badge[data-size="sm"] {
--_h: 22px;
--_fs: 11px;
padding: 0 8px;
gap: 5px;
}
.kt-badge[data-tone="accent"] { --_c: var(--kt-accent); --_on: var(--kt-accent-ink); }
.kt-badge[data-tone="success"] { --_c: #15803d; --_on: #ffffff; }
.kt-badge[data-tone="warning"] { --_c: #f59e0b; --_on: #1c1400; }
.kt-badge[data-tone="error"] { --_c: #dc2626; --_on: #ffffff; }
/* solid */
.kt-badge[data-variant="solid"] {
background: var(--_c);
color: var(--_on);
border-color: var(--_c);
}
/* soft: tinted fill, ink mixed from the tone so it stays readable in light and dark */
.kt-badge[data-variant="soft"] {
background: color-mix(in srgb, var(--_c) 16%, var(--kt-surface-bg));
color: color-mix(in srgb, var(--_c) 55%, var(--kt-surface-ink));
border-color: color-mix(in srgb, var(--_c) 28%, transparent);
}
.kt-badge[data-variant="outline"] {
background: transparent;
color: color-mix(in srgb, var(--_c) 62%, var(--kt-surface-ink));
border-color: var(--kt-comp-border, color-mix(in srgb, var(--_c) 75%, transparent));
}
.kt-badge[data-tone="neutral"][data-variant="soft"] {
background: var(--bw-subtle);
color: var(--kt-surface-ink);
border-color: var(--bw-border);
}
.kt-badge[data-tone="neutral"][data-variant="outline"] {
color: var(--kt-surface-ink);
border-color: var(--bw-border-strong);
}
.kt-badge-dot {
width: 7px;
height: 7px;
flex-shrink: 0;
border-radius: 50%;
background: currentColor;
}
.kt-badge-dot[hidden] { display: none; }
.kt-badge[data-variant="soft"] .kt-badge-dot,
.kt-badge[data-variant="outline"] .kt-badge-dot {
background: var(--_c);
}
.kt-badge[data-tone="neutral"] .kt-badge-dot { background: var(--bw-muted); }
.kt-badge[data-tone="neutral"][data-variant="solid"] .kt-badge-dot { background: var(--_on); }
[data-vfx="neon"] .kt-badge-dot {
box-shadow: 0 0 6px 1px var(--_c);
}
.kt-badge-label {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.kt-badge-close {
display: inline-grid;
place-items: center;
flex-shrink: 0;
width: 18px;
height: 18px;
margin: 0 -5px 0 -1px;
padding: 0;
border: 0;
border-radius: var(--kt-radius-tag);
background: transparent;
color: inherit;
cursor: pointer;
opacity: 0.75;
transition: background-color 140ms ease, opacity 140ms ease, transform 140ms ease;
}
.kt-badge-close[hidden] { display: none; }
/* extend the hit area to the 24px minimum without growing the badge */
.kt-badge-close { position: relative; }
.kt-badge-close::after {
content: "";
position: absolute;
inset: -3px;
}
.kt-badge-close:hover {
opacity: 1;
background: color-mix(in srgb, currentColor 18%, transparent);
}
.kt-badge-close:focus-visible {
outline: 2px solid var(--bw-ink);
outline-offset: 1px;
opacity: 1;
}
[data-vfx="sakuga"] .kt-badge-close:hover,
[data-vfx="elastic"] .kt-badge-close:hover { transform: scale(1.18) rotate(90deg); }
/* pop-out */
.kt-badge.is-leaving {
pointer-events: none;
animation: kt-badge-pop 150ms ease forwards;
}
[data-vfx="sakuga"] .kt-badge.is-leaving { animation: kt-badge-pop-sakuga 240ms var(--ease-overshoot) forwards; }
[data-vfx="elastic"] .kt-badge.is-leaving { animation: kt-badge-pop-elastic 240ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
[data-vfx="glitch"] .kt-badge.is-leaving { animation: kt-badge-pop-glitch 220ms steps(4, end) forwards; }
[data-vfx="neon"] .kt-badge.is-leaving { animation: kt-badge-pop-neon 240ms var(--ease-snap) forwards; }
[data-vfx="ink"] .kt-badge.is-leaving { animation: kt-badge-pop-sakuga 240ms var(--ease-overshoot) forwards; }
@keyframes kt-badge-pop {
to { opacity: 0; transform: scale(0.96); }
}
@keyframes kt-badge-pop-sakuga {
0% { transform: scale(1); opacity: 1; }
30% { transform: scale(1.18, 0.86); opacity: 1; }
100% { transform: scale(0.2); opacity: 0; }
}
@keyframes kt-badge-pop-elastic {
0% { transform: scale(1); opacity: 1; }
35% { transform: scale(0.85, 1.2); opacity: 1; }
100% { transform: scale(0.1, 0.3); opacity: 0; }
}
@keyframes kt-badge-pop-glitch {
0% { transform: translate(0, 0); opacity: 1; }
40% { transform: translate(-4px, 1px) skewX(-12deg); opacity: 0.8; }
70% { transform: translate(5px, -1px) skewX(10deg); opacity: 0.4; }
100% { transform: translate(0, 0); opacity: 0; }
}
@keyframes kt-badge-pop-neon {
0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 var(--_c); }
40% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 16px 3px var(--_c); }
100% { transform: scale(0.4); opacity: 0; box-shadow: 0 0 0 0 var(--_c); }
}
@media (prefers-reduced-motion: reduce) {
.kt-badge.is-leaving { animation: none; opacity: 0; }
}
class KtKineticBadge extends HTMLElement {
static get observedAttributes() {
return ["tone", "variant", "size", "dot", "dismissible"];
}
constructor() {
super();
this._rendered = false;
this._text = "";
this._leaveTimer = null;
}
connectedCallback() {
if (!this._rendered) {
this._text = this.textContent.trim() || "Badge";
this.render();
this._rendered = true;
}
this.syncAttributes();
}
disconnectedCallback() {
clearTimeout(this._leaveTimer);
}
attributeChangedCallback() {
if (this._rendered) this.syncAttributes();
}
get tone() {
const t = (this.getAttribute("tone") || "neutral").toLowerCase();
return ["neutral", "accent", "success", "warning", "error"].includes(t) ? t : "neutral";
}
get variant() {
const v = (this.getAttribute("variant") || "soft").toLowerCase();
return ["solid", "soft", "outline"].includes(v) ? v : "soft";
}
get size() { return this.getAttribute("size") === "sm" ? "sm" : "md"; }
get dot() { return this.hasAttribute("dot") && this.getAttribute("dot") !== "false"; }
get dismissible() { return this.hasAttribute("dismissible") && this.getAttribute("dismissible") !== "false"; }
get text() { return this._text; }
render() {
this.innerHTML = "";
const badge = document.createElement("span");
badge.className = "kt-badge";
badge.innerHTML = `
<span class="kt-badge-dot" aria-hidden="true"></span>
<span class="kt-badge-label"></span>
<button type="button" class="kt-badge-close" hidden>
<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true" focusable="false"><path d="M2.5 2.5l7 7M9.5 2.5l-7 7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
</button>
`;
this._badge = badge;
this._dotEl = badge.querySelector(".kt-badge-dot");
this._labelEl = badge.querySelector(".kt-badge-label");
this._close = badge.querySelector(".kt-badge-close");
this._close.addEventListener("click", (e) => {
e.stopPropagation();
this.dismiss();
});
const restore = document.createElement("button");
restore.type = "button";
restore.className = "kt-badge-restore";
restore.hidden = true;
restore.textContent = "Restore";
restore.addEventListener("click", () => this.restore());
this._restore = restore;
this.append(badge, restore);
}
syncAttributes() {
if (!this._badge) return;
this._badge.setAttribute("data-tone", this.tone);
this._badge.setAttribute("data-variant", this.variant);
this._badge.setAttribute("data-size", this.size);
this._dotEl.hidden = !this.dot;
this._labelEl.textContent = this._text;
this._close.hidden = !this.dismissible;
this._close.setAttribute("aria-label", "Remove " + this._text);
}
dismiss() {
if (this._badge.hidden || this._badge.classList.contains("is-leaving")) return;
const mode = SakugaFX.getMode();
if (mode !== "enterprise") {
const rect = this._badge.getBoundingClientRect();
const color = readAccent(this._badge);
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
if (mode === "glitch") SakugaFX.emitPixels(x, y, color, 8);
else if (mode === "ink") SakugaFX.emitInkSplatter(x, y, color, 7);
else if (mode === "neon") SakugaFX.emitShockwave(x, y, color, 36);
else SakugaFX.emitBurst(x, y, color, { count: 8, speed: 150, shards: false });
}
this._badge.classList.add("is-leaving");
const delay = mode === "enterprise" ? 140 : 240;
this._leaveTimer = setTimeout(() => {
this._badge.classList.remove("is-leaving");
this._badge.hidden = true;
this._restore.hidden = false;
this._restore.setAttribute("aria-label", "Restore " + this._text);
this._restore.focus();
this.dispatchEvent(new CustomEvent("dismiss", { bubbles: true, detail: { text: this._text } }));
}, delay);
}
restore() {
this._badge.hidden = false;
this._restore.hidden = true;
this._close.focus();
this.dispatchEvent(new CustomEvent("restore", { bubbles: true, detail: { text: this._text } }));
}
}
customElements.define("kt-kinetic-badge", KtKineticBadge);
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 |
|---|---|---|
tone | "neutral", "accent", "success", "warning" or "error". | neutral |
variant | "solid", "soft" or "outline". | soft |
size | "sm" or "md". | md |
dot | Show a small status dot before the text. | — |
dismissible | Show a remove button. It plays a pop-out, hides the badge and fires "dismiss". | — |
Keyboard and screen readers
- The badge text is plain text, so it is read in the normal flow.
- The dot is decorative and hidden from screen readers: do not rely on color alone, say the status in the text.
- The remove button is a real button with the label "Remove <text>"; Tab reaches it, Enter or Space activates it.
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 Badge: questions answered
How do I use the Kinetic Badge?
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-badge>.
Which attributes does <kt-kinetic-badge> accept?
tone, variant, size, dot, dismissible. Each one is described in the attributes table on this page.
Is the Kinetic Badge accessible?
The badge text is plain text, so it is read in the normal flow. The dot is decorative and hidden from screen readers: do not rely on color alone, say the status in the text. The remove button is a real button with the label "Remove <text>"; Tab reaches it, Enter or Space activates it.
Can I change the Kinetic Badge 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.