Sticker
import { useId, useState } from 'react';
const STAR = 'M15 2.5l3.6 7.4 8.1 1.1-5.9 5.7 1.4 8.1L15 21l-7.2 3.8 1.4-8.1-5.9-5.7 8.1-1.1Z';
const css = `
/* Slapped down at an angle, it flattens out and settles. */
@keyframes cb-sticker-slap { 0% { transform: rotate(-38deg) scale(1.6); opacity: 0; } 45% { transform: rotate(6deg) scale(0.92); opacity: 1; } 70% { transform: rotate(-3deg) scale(1.04); } 100% { transform: rotate(-8deg) scale(1); opacity: 1; } }
@keyframes cb-sticker-sheen { from { transform: translateX(-24px) skewX(-20deg); } to { transform: translateX(34px) skewX(-20deg); } }
.cb-sticker { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-sticker__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-sticker__box { position: relative; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px light-dark(#cbced3, #393c41); }
.cb-sticker__input:focus-visible + .cb-sticker__box { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 3px; }
.cb-sticker__star { position: absolute; inset: -5px; width: 40px; height: 40px; overflow: visible; opacity: 0; transform: rotate(-8deg); filter: drop-shadow(0 2px 2px light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.4))); }
.cb-sticker__face { fill: light-dark(#373a40, #f1f2f3); stroke: light-dark(#fbfcfd, #121417); stroke-width: 2.4; stroke-linejoin: round; paint-order: stroke; }
.cb-sticker__shine { fill: color-mix(in oklab, light-dark(#fbfcfd, #121417) 65%, transparent); transform: translateX(-24px); }
.cb-sticker__input:checked + .cb-sticker__box .cb-sticker__star { opacity: 1; }
.cb-sticker[data-armed] .cb-sticker__input:checked + .cb-sticker__box .cb-sticker__star { animation: cb-sticker-slap 0.5s cubic-bezier(0.3, 0.9, 0.4, 1) both; }
.cb-sticker[data-armed] .cb-sticker__input:checked + .cb-sticker__box .cb-sticker__shine { animation: cb-sticker-sheen 0.6s ease-in-out 0.45s both; }
.cb-sticker[data-armed] .cb-sticker__input:not(:checked) + .cb-sticker__box .cb-sticker__star { transition: opacity 0.2s, transform 0.25s; transform: rotate(-20deg) scale(0.6); }
@media (prefers-reduced-motion: reduce) {
.cb-sticker * { animation: none !important; transition: none !important; }
}
`;
export function StickerCheckbox() {
const [armed, setArmed] = useState(false);
const clip = `cb-sticker-${useId().replace(/[^a-zA-Z0-9]/g, '')}`;
return (
<>
<style>
{css}
</style>
<label className="cb-sticker" data-armed={armed || undefined}>
<input className="cb-sticker__input" type="checkbox" onChange={() => setArmed(true)} />
<span className="cb-sticker__box" aria-hidden="true">
<svg className="cb-sticker__star" viewBox="-5 -5 40 40">
<defs>
<clipPath id={clip}>
<path d={STAR} />
</clipPath>
</defs>
<path className="cb-sticker__face" d={STAR} />
{/* The sheen: a pale band clipped to the star, swept across once it lands. */}
<g clipPath={`url(#${clip})`}>
<rect className="cb-sticker__shine" x="0" y="-2" width="9" height="34" />
</g>
</svg>
</span>
Favourite
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initCbSticker(el) on the mounted element instead.
<label class="cb-sticker"><input class="cb-sticker__input" type="checkbox"/><span class="cb-sticker__box" aria-hidden="true"><svg class="cb-sticker__star" viewBox="-5 -5 40 40"><defs><clipPath id="cb-sticker-def"><path d="M15 2.5l3.6 7.4 8.1 1.1-5.9 5.7 1.4 8.1L15 21l-7.2 3.8 1.4-8.1-5.9-5.7 8.1-1.1Z"></path></clipPath></defs><path class="cb-sticker__face" d="M15 2.5l3.6 7.4 8.1 1.1-5.9 5.7 1.4 8.1L15 21l-7.2 3.8 1.4-8.1-5.9-5.7 8.1-1.1Z"></path><g clip-path="url(#cb-sticker-def)"><rect class="cb-sticker__shine" x="0" y="-2" width="9" height="34"></rect></g></svg></span>Favourite</label>/* Slapped down at an angle, it flattens out and settles. */
@keyframes cb-sticker-slap { 0% { transform: rotate(-38deg) scale(1.6); opacity: 0; } 45% { transform: rotate(6deg) scale(0.92); opacity: 1; } 70% { transform: rotate(-3deg) scale(1.04); } 100% { transform: rotate(-8deg) scale(1); opacity: 1; } }
@keyframes cb-sticker-sheen { from { transform: translateX(-24px) skewX(-20deg); } to { transform: translateX(34px) skewX(-20deg); } }
.cb-sticker { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-sticker__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-sticker__box { position: relative; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px light-dark(#cbced3, #393c41); }
.cb-sticker__input:focus-visible + .cb-sticker__box { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 3px; }
.cb-sticker__star { position: absolute; inset: -5px; width: 40px; height: 40px; overflow: visible; opacity: 0; transform: rotate(-8deg); filter: drop-shadow(0 2px 2px light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.4))); }
.cb-sticker__face { fill: light-dark(#373a40, #f1f2f3); stroke: light-dark(#fbfcfd, #121417); stroke-width: 2.4; stroke-linejoin: round; paint-order: stroke; }
.cb-sticker__shine { fill: color-mix(in oklab, light-dark(#fbfcfd, #121417) 65%, transparent); transform: translateX(-24px); }
.cb-sticker__input:checked + .cb-sticker__box .cb-sticker__star { opacity: 1; }
.cb-sticker[data-armed] .cb-sticker__input:checked + .cb-sticker__box .cb-sticker__star { animation: cb-sticker-slap 0.5s cubic-bezier(0.3, 0.9, 0.4, 1) both; }
.cb-sticker[data-armed] .cb-sticker__input:checked + .cb-sticker__box .cb-sticker__shine { animation: cb-sticker-sheen 0.6s ease-in-out 0.45s both; }
.cb-sticker[data-armed] .cb-sticker__input:not(:checked) + .cb-sticker__box .cb-sticker__star { transition: opacity 0.2s, transform 0.25s; transform: rotate(-20deg) scale(0.6); }
@media (prefers-reduced-motion: reduce) {
.cb-sticker * { animation: none !important; transition: none !important; }
}function initCbSticker(root) {
var input = root.querySelector('input');
if (!input) return;
// Animate only after the first change, so nothing plays on page load.
function arm() { root.setAttribute('data-armed', ''); }
input.addEventListener('change', arm);
return function () { input.removeEventListener('change', arm); };
}
document.querySelectorAll('.cb-sticker').forEach(initCbSticker);Goal: Create a "Sticker" checkbox.
Visual behavior: A favourite checkbox: ticking it slaps a star sticker down at an angle, it flattens out and settles, and a sheen sweeps across it.
Technique:
- A real native checkbox (visually hidden: absolute, 1x1, opacity 0) inside a <label>; every visual is aria-hidden and styled from the input with :checked + sibling selectors.
- The star lands with a keyframe from rotate(-38deg) scale(1.6) through an overshoot to rest at -8deg, with a drop shadow under it.
- A pale band clipped to the star with an SVG clipPath slides across once it has landed, as the sheen.
- The keyframes only apply once a data-armed flag is set on the first change, so nothing plays on page load; ticking and unticking use differently named keyframes, so each change restarts the right one.
Accessibility: A native checkbox inside a <label>, so Space toggles it and the visible label names it; :focus-visible on the input outlines the visual. Under prefers-reduced-motion the sticker simply appears and disappears.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: neutral only. Black, white and grays, no hues. Use the color values above as written, or my project's closest neutral tokens.
Return a single self-contained component. No dependencies.Goal: Create a "Sticker" checkbox.
Visual behavior: A favourite checkbox: ticking it slaps a star sticker down at an angle, it flattens out and settles, and a sheen sweeps across it.
Technique:
- A real native checkbox (visually hidden: absolute, 1x1, opacity 0) inside a <label>; every visual is aria-hidden and styled from the input with :checked + sibling selectors.
- The star lands with a keyframe from rotate(-38deg) scale(1.6) through an overshoot to rest at -8deg, with a drop shadow under it.
- A pale band clipped to the star with an SVG clipPath slides across once it has landed, as the sheen.
- The keyframes only apply once a data-armed flag is set on the first change, so nothing plays on page load; ticking and unticking use differently named keyframes, so each change restarts the right one.
Accessibility: A native checkbox inside a <label>, so Space toggles it and the visible label names it; :focus-visible on the input outlines the visual. Under prefers-reduced-motion the sticker simply appears and disappears.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: use my project's existing color tokens. The color values above are grayscale placeholders. Map each one by its role (surface, text, border, accent, glow) to my theme, and keep their relative lightness so contrast and the effect still read.
Return a single self-contained component. No dependencies.Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Free to use in any project, commercial included. MIT-0, no attribution required. Licence
About this component
A favourite checkbox: ticking it slaps a star sticker down at an angle, it flattens out and settles, and a sheen sweeps across it.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- click, state change, spring
- Techniques
- keyframes, svg, clip path, filter
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
A native checkbox inside a <label>, so Space toggles it and the visible label names it; :focus-visible on the input outlines the visual. Under prefers-reduced-motion the sticker simply appears and disappears.