Gradient Sweep Checkbox
A rainbow gradient sweeps across the box using background-position animation on check.
Gradient Sweep Checkbox the 10th of 23 designs in the 23 CSS Checkboxes collection. The design is implemented in pure CSS — no JavaScript required. Copy the HTML and CSS panels below into your project. Because the demo is pure CSS, it works in any framework or templating engine you happen to use. The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.
Live preview
The code
<label class="cb-sweep">
<input class="cb-sweep__input" type="checkbox" checked />
<span class="cb-sweep__box">
<svg width="12" height="9" viewBox="0 0 14 11" fill="none">
<polyline
points="1,5.5 5,9.5 13,1"
stroke="white"
stroke-width="2.2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</span>
<span>Gradient sweep checkbox</span>
</label> .cb-sweep {
display: inline-flex; align-items: center;
gap: 10px; cursor: pointer; user-select: none;
}
.cb-sweep__input { display: none; }
.cb-sweep__box {
width: 24px; height: 24px; border-radius: 7px;
border: 2px solid rgba(255,255,255,.15);
background: rgba(255,255,255,.06);
display: flex; align-items: center;
justify-content: center; color: transparent;
transition: border-color .4s, color .4s;
}
.cb-sweep__input:checked + .cb-sweep__box {
border-color: transparent; color: #fff;
background: linear-gradient(90deg,
#7c6cff, #ff6c8a, #3de8f5, #7c6cff);
background-size: 200% 100%;
animation: grad-sweep .6s ease forwards;
}
@keyframes grad-sweep {
from { background-position: 100% 0; }
to { background-position: 0% 0; }
}
@media (prefers-reduced-motion: reduce) {
.cb-sweep,
.cb-sweep * {
animation: none !important;
}
}