Sync
import { useState } from 'react';
const css = `
@keyframes cb-sync-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(540deg); } }
@keyframes cb-sync-unspin { 0% { transform: rotate(-180deg); } 100% { transform: rotate(0deg); } }
@keyframes cb-sync-arrows-out { 0%, 55% { opacity: 1; } 75%, 100% { opacity: 0; } }
.cb-sync { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-sync__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-sync__box { position: relative; width: 28px; height: 28px; border-radius: 50%; }
.cb-sync__input:focus-visible + .cb-sync__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-sync__box svg { width: 28px; height: 28px; overflow: visible; }
.cb-sync__arrows { transform-box: view-box; transform-origin: 14px 14px; transition: opacity 0.2s; }
.cb-sync__arrows path { fill: none; stroke: light-dark(#5f626a, #a7abb2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-sync__ring {
fill: none;
stroke: light-dark(#50535b, #c6c8cd);
stroke-width: 2;
stroke-dasharray: 1;
stroke-dashoffset: 1;
transform: rotate(-90deg);
transform-box: view-box;
transform-origin: 14px 14px;
transition: stroke-dashoffset 0.25s ease;
}
.cb-sync__tick { fill: none; stroke: light-dark(#373a40, #f1f2f3); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0.15s ease; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__arrows { opacity: 0; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__ring { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s ease 0.45s; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__tick { stroke-dashoffset: 0; transition: stroke-dashoffset 0.25s ease 0.62s; }
.cb-sync[data-armed] .cb-sync__input:checked + .cb-sync__box .cb-sync__arrows { animation: cb-sync-spin 0.75s cubic-bezier(0.5, 0, 0.3, 1), cb-sync-arrows-out 0.75s linear; }
.cb-sync[data-armed] .cb-sync__input:not(:checked) + .cb-sync__box .cb-sync__arrows { animation: cb-sync-unspin 0.45s cubic-bezier(0.2, 0.8, 0.3, 1); }
@media (prefers-reduced-motion: reduce) {
.cb-sync__box * { animation: none !important; transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
`;
// One arc arrow running clockwise round a circle of radius 9; the second is the same turned half a turn.
const ARC = 'M5.54 10.92A9 9 0 0 1 20.89 8.21M20.59 4.72L20.89 8.21L17.51 7.31';
export function SyncCheckbox() {
const [armed, setArmed] = useState(false);
return (
<>
<style>
{css}
</style>
<label className="cb-sync" data-armed={armed || undefined}>
<input className="cb-sync__input" type="checkbox" onChange={() => setArmed(true)} />
<span className="cb-sync__box" aria-hidden="true">
<svg viewBox="0 0 28 28">
<g className="cb-sync__arrows">
<path d={ARC} />
<path d={ARC} transform="rotate(180 14 14)" />
</g>
<circle className="cb-sync__ring" cx="14" cy="14" r="11.5" pathLength={1} />
<path className="cb-sync__tick" pathLength={1} d="M9.5 14.5L12.8 17.8L18.8 10.8" />
</svg>
</span>
Sync this folder
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet, script before </body>. In Vue, Svelte or Angular, call initCbSync(el) on the mounted element instead.
<label class="cb-sync"><input class="cb-sync__input" type="checkbox"/><span class="cb-sync__box" aria-hidden="true"><svg viewBox="0 0 28 28"><g class="cb-sync__arrows"><path d="M5.54 10.92A9 9 0 0 1 20.89 8.21M20.59 4.72L20.89 8.21L17.51 7.31"></path><path d="M5.54 10.92A9 9 0 0 1 20.89 8.21M20.59 4.72L20.89 8.21L17.51 7.31" transform="rotate(180 14 14)"></path></g><circle class="cb-sync__ring" cx="14" cy="14" r="11.5" pathLength="1"></circle><path class="cb-sync__tick" pathLength="1" d="M9.5 14.5L12.8 17.8L18.8 10.8"></path></svg></span>Sync this folder</label>@keyframes cb-sync-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(540deg); } }
@keyframes cb-sync-unspin { 0% { transform: rotate(-180deg); } 100% { transform: rotate(0deg); } }
@keyframes cb-sync-arrows-out { 0%, 55% { opacity: 1; } 75%, 100% { opacity: 0; } }
.cb-sync { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-sync__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-sync__box { position: relative; width: 28px; height: 28px; border-radius: 50%; }
.cb-sync__input:focus-visible + .cb-sync__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-sync__box svg { width: 28px; height: 28px; overflow: visible; }
.cb-sync__arrows { transform-box: view-box; transform-origin: 14px 14px; transition: opacity 0.2s; }
.cb-sync__arrows path { fill: none; stroke: light-dark(#5f626a, #a7abb2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-sync__ring {
fill: none;
stroke: light-dark(#50535b, #c6c8cd);
stroke-width: 2;
stroke-dasharray: 1;
stroke-dashoffset: 1;
transform: rotate(-90deg);
transform-box: view-box;
transform-origin: 14px 14px;
transition: stroke-dashoffset 0.25s ease;
}
.cb-sync__tick { fill: none; stroke: light-dark(#373a40, #f1f2f3); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 0.15s ease; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__arrows { opacity: 0; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__ring { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s ease 0.45s; }
.cb-sync__input:checked + .cb-sync__box .cb-sync__tick { stroke-dashoffset: 0; transition: stroke-dashoffset 0.25s ease 0.62s; }
.cb-sync[data-armed] .cb-sync__input:checked + .cb-sync__box .cb-sync__arrows { animation: cb-sync-spin 0.75s cubic-bezier(0.5, 0, 0.3, 1), cb-sync-arrows-out 0.75s linear; }
.cb-sync[data-armed] .cb-sync__input:not(:checked) + .cb-sync__box .cb-sync__arrows { animation: cb-sync-unspin 0.45s cubic-bezier(0.2, 0.8, 0.3, 1); }
@media (prefers-reduced-motion: reduce) {
.cb-sync__box * { animation: none !important; transition-duration: 0.01s !important; transition-delay: 0s !important; }
}function initCbSync(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-sync').forEach(initCbSync);Goal: Create a "Sync" checkbox.
Visual behavior: A sync checkbox: ticking spins the two sync arrows round and fades them into a ring that draws closed with a tick inside; unticking brings the arrows back.
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 arrows are one arc with a head, drawn twice half a turn apart; they spin and fade on keyframes.
- The ring and the tick draw with stroke-dashoffset as the arrows go.
- 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 icon swaps instantly.
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 "Sync" checkbox.
Visual behavior: A sync checkbox: ticking spins the two sync arrows round and fades them into a ring that draws closed with a tick inside; unticking brings the arrows back.
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 arrows are one arc with a head, drawn twice half a turn apart; they spin and fade on keyframes.
- The ring and the tick draw with stroke-dashoffset as the arrows go.
- 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 icon swaps instantly.
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 sync checkbox: ticking spins the two sync arrows round and fades them into a ring that draws closed with a tick inside; unticking brings the arrows back.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- click, state change, morph, draw
- Techniques
- svg, stroke dashoffset, keyframes
- 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 icon swaps instantly.