Tiles
React + Tailwind
const css = `
.cb-tiles { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-tiles__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-tiles__box { position: relative; width: 30px; height: 30px; border-radius: 7px; }
.cb-tiles__input:focus-visible + .cb-tiles__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-tiles__tile {
position: absolute;
width: 14.5px;
height: 14.5px;
overflow: hidden;
background: light-dark(#ebedf0, #232529);
box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035);
transform: rotate(var(--r));
/* Scrambling, the tiles turn away in reverse order. */
transition: transform 0.35s cubic-bezier(0.5, 0, 0.5, 1) calc((3 - var(--i)) * 0.05s), background-color 0.3s;
}
.cb-tiles__tile svg { position: absolute; width: 30px; height: 30px; }
.cb-tiles__tile path { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.3s; }
.cb-tiles__input:checked + .cb-tiles__box .cb-tiles__tile {
transform: rotate(0deg);
background: light-dark(#cbced3, #393c41);
box-shadow: inset 0 0 0 1px light-dark(#6d7179, #7d8087);
transition: transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) calc(var(--i) * 0.09s), background-color 0.3s ease 0.4s;
}
.cb-tiles__input:checked + .cb-tiles__box .cb-tiles__tile path { stroke: light-dark(#373a40, #f1f2f3); transition-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
.cb-tiles__box * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
`;
// Each tile shows its quarter of one tick; scrambled, each sits turned by its own angle.
const TILES = [
{ x: 0, y: 0, r: 90, radius: '7px 0 0 0' },
{ x: 15.5, y: 0, r: 180, radius: '0 7px 0 0' },
{ x: 15.5, y: 15.5, r: 270, radius: '0 0 7px 0' },
{ x: 0, y: 15.5, r: 90, radius: '0 0 0 7px' },
];
export function TilesCheckbox() {
return (
<>
<style>
{css}
</style>
<label className="cb-tiles">
<input className="cb-tiles__input" type="checkbox" />
<span className="cb-tiles__box" aria-hidden="true">
{TILES.map((t, i) => (
<span
key={i}
className="cb-tiles__tile"
style={{ left: t.x, top: t.y, borderRadius: t.radius, '--r': `${t.r}deg`, '--i': i } as React.CSSProperties}
>
<svg viewBox="0 0 30 30" style={{ left: -t.x, top: -t.y }}>
<path d="M7.5 15.5L12.5 20.5L22.5 9" />
</svg>
</span>
))}
</span>
Everything fits
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
HTML
<label class="cb-tiles"><input class="cb-tiles__input" type="checkbox"/><span class="cb-tiles__box" aria-hidden="true"><span class="cb-tiles__tile" style="left:0;top:0;border-radius:7px 0 0 0;--r:90deg;--i:0"><svg viewBox="0 0 30 30" style="left:0;top:0"><path d="M7.5 15.5L12.5 20.5L22.5 9"></path></svg></span><span class="cb-tiles__tile" style="left:15.5px;top:0;border-radius:0 7px 0 0;--r:180deg;--i:1"><svg viewBox="0 0 30 30" style="left:-15.5px;top:0"><path d="M7.5 15.5L12.5 20.5L22.5 9"></path></svg></span><span class="cb-tiles__tile" style="left:15.5px;top:15.5px;border-radius:0 0 7px 0;--r:270deg;--i:2"><svg viewBox="0 0 30 30" style="left:-15.5px;top:-15.5px"><path d="M7.5 15.5L12.5 20.5L22.5 9"></path></svg></span><span class="cb-tiles__tile" style="left:0;top:15.5px;border-radius:0 0 0 7px;--r:90deg;--i:3"><svg viewBox="0 0 30 30" style="left:0;top:-15.5px"><path d="M7.5 15.5L12.5 20.5L22.5 9"></path></svg></span></span>Everything fits</label>CSS
.cb-tiles { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-tiles__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-tiles__box { position: relative; width: 30px; height: 30px; border-radius: 7px; }
.cb-tiles__input:focus-visible + .cb-tiles__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-tiles__tile {
position: absolute;
width: 14.5px;
height: 14.5px;
overflow: hidden;
background: light-dark(#ebedf0, #232529);
box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035);
transform: rotate(var(--r));
/* Scrambling, the tiles turn away in reverse order. */
transition: transform 0.35s cubic-bezier(0.5, 0, 0.5, 1) calc((3 - var(--i)) * 0.05s), background-color 0.3s;
}
.cb-tiles__tile svg { position: absolute; width: 30px; height: 30px; }
.cb-tiles__tile path { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.3s; }
.cb-tiles__input:checked + .cb-tiles__box .cb-tiles__tile {
transform: rotate(0deg);
background: light-dark(#cbced3, #393c41);
box-shadow: inset 0 0 0 1px light-dark(#6d7179, #7d8087);
transition: transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) calc(var(--i) * 0.09s), background-color 0.3s ease 0.4s;
}
.cb-tiles__input:checked + .cb-tiles__box .cb-tiles__tile path { stroke: light-dark(#373a40, #f1f2f3); transition-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
.cb-tiles__box * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}Goal: Create a "Tiles" checkbox.
Visual behavior: A puzzle checkbox: four scrambled tiles each turned a different way rotate back into place one after another, and the tick they make lights up.
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.
- Each tile clips its quarter of one tick (the SVG is offset by the tile position) and carries a scrambled angle and an index in CSS variables.
- Ticking turns them to 0 with staggered, overshooting transitions; unticking scrambles them again in reverse order. Pure CSS, no script.
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 tiles jump to place.
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 "Tiles" checkbox.
Visual behavior: A puzzle checkbox: four scrambled tiles each turned a different way rotate back into place one after another, and the tick they make lights up.
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.
- Each tile clips its quarter of one tick (the SVG is offset by the tile position) and carries a scrambled angle and an index in CSS variables.
- Ticking turns them to 0 with staggered, overshooting transitions; unticking scrambles them again in reverse order. Pure CSS, no script.
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 tiles jump to place.
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 puzzle checkbox: four scrambled tiles each turned a different way rotate back into place one after another, and the tick they make lights up.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- click, state change, delay stagger, spring
- Techniques
- css transition, transition delay stagger, css variables
- 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 tiles jump to place.