An 8-bit checkbox drawn on a 13 by 13 SVG grid with crisp edges and a drop shadow. Checking hops the box, fills it in stepped frames and reveals the pixel tick column by column with steps().
Also known as: 8-bit checkbox css, retro checkbox, pixel checkbox.
<label class="chk-pixel-checkbox">
<input type="checkbox">
<svg class="chk-pixel-checkbox-icon" viewBox="0 0 13 13" aria-hidden="true">
<path class="chk-pixel-checkbox-shadow" d="M2 12h10v1H2zM12 2h1v10h-1z"/>
<path class="chk-pixel-checkbox-fill" d="M1 1h10v10H1z"/>
<path class="chk-pixel-checkbox-frame" d="M1 0h10v1H1zM1 11h10v1H1zM0 1h1v10H0zM11 1h1v10h-1z"/>
<path class="chk-pixel-checkbox-tick" d="M2 5h1v2H2zM3 6h1v2H3zM4 7h1v2H4zM5 6h1v2H5zM6 5h1v2H6zM7 4h1v2H7zM8 3h1v2H8zM9 2h1v2H9z"/>
</svg>
<span class="chk-pixel-checkbox-text">Player two</span>
</label>.chk-pixel-checkbox {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
display: inline-flex;
align-items: center;
gap: 0.6em;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.3;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
gap: 0.7em;}
.chk-pixel-checkbox input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-pixel-checkbox-icon {
display: block;
flex: none;
width: 1.625em;
height: 1.625em;
shape-rendering: crispEdges;
}
.chk-pixel-checkbox-shadow {
fill: color-mix(in srgb, currentColor 30%, transparent);
}
.chk-pixel-checkbox-frame {
fill: currentColor;
}
.chk-pixel-checkbox-fill {
fill: var(--c);
opacity: 0;
transition: opacity 0.2s steps(2, jump-none);
}
.chk-pixel-checkbox-tick {
fill: #fff;
clip-path: inset(0 100% 0 0);
transition: clip-path 0.16s steps(4, end);
}
.chk-pixel-checkbox-text {
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
font-size: 0.875em;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.chk-pixel-checkbox input:checked + .chk-pixel-checkbox-icon {
animation: chk-pixel-checkbox-hop 0.24s steps(1, end);
}
.chk-pixel-checkbox input:checked + .chk-pixel-checkbox-icon .chk-pixel-checkbox-fill {
opacity: 1;
transition: opacity 0.24s steps(3, jump-none);
}
.chk-pixel-checkbox input:checked + .chk-pixel-checkbox-icon .chk-pixel-checkbox-tick {
clip-path: inset(0 0 0 0);
transition: clip-path 0.4s steps(8, end) 0.2s;
}
.chk-pixel-checkbox input:focus-visible + .chk-pixel-checkbox-icon {
outline: 0.125em dashed var(--c);
outline-offset: 0.15em;
}
@keyframes chk-pixel-checkbox-hop {
0% { transform: translateY(-0.125em); }
50% { transform: translateY(0.0625em); }
100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
.chk-pixel-checkbox, .chk-pixel-checkbox *, .chk-pixel-checkbox::before, .chk-pixel-checkbox::after, .chk-pixel-checkbox *::before, .chk-pixel-checkbox *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--chk-color on the element or a parent.
Currently previewing #3b82f6.--chk-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 24px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.