Gears
React + Tailwind
const css = `
.cb-gears { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-gears__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-gears__box { position: relative; width: 48px; height: 38px; border-radius: 6px; }
.cb-gears__input:focus-visible + .cb-gears__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-gears__gear { position: absolute; overflow: visible; transition: transform 0.75s cubic-bezier(0.35, 1.25, 0.5, 1); }
.cb-gears__gear--big { left: 1px; top: 6px; width: 32px; height: 32px; transform: rotate(-144deg); }
.cb-gears__gear--small { left: 25px; top: -1px; width: 20px; height: 20px; transform: rotate(var(--s0)); }
.cb-gears__teeth { fill: light-dark(#cbced3, #393c41); transition: fill 0.4s; }
.cb-gears__gear--small .cb-gears__teeth { fill: light-dark(#dbdde1, #2e3035); }
.cb-gears__hub { fill: light-dark(#ebedf0, #232529); }
.cb-gears__axle { fill: light-dark(#6d7179, #7d8087); }
.cb-gears__tick { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.4s; }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--big { transform: rotate(0deg); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--small { transform: rotate(var(--s1)); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--big .cb-gears__teeth { fill: light-dark(#6d7179, #7d8087); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__tick { stroke: light-dark(#373a40, #f1f2f3); transition-delay: 0.45s; }
@media (prefers-reduced-motion: reduce) {
.cb-gears__box * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
`;
/** A gear outline centred on the origin. Rounded so the server and the browser print the same path. */
function gear(teeth: number, outer: number, inner: number) {
const step = (Math.PI * 2) / teeth;
const pts: string[] = [];
for (let i = 0; i < teeth; i++) {
for (const [f, r] of [[0, inner], [0.18, outer], [0.48, outer], [0.66, inner]]) {
const a = (i + f) * step;
pts.push(`${(Math.cos(a) * r).toFixed(2)} ${(Math.sin(a) * r).toFixed(2)}`);
}
}
return `M${pts.join('L')}Z`;
}
const BIG = gear(10, 15.5, 12.5);
const SMALL = gear(6, 9.5, 6.8);
// The small gear turns the other way, 10/6 as far. Its phase is set so the teeth mesh.
const PHASE = 14;
const SMALL_VARS = { '--s0': `${PHASE + 240}deg`, '--s1': `${PHASE}deg` } as React.CSSProperties;
export function GearsCheckbox() {
return (
<>
<style>
{css}
</style>
<label className="cb-gears">
<input className="cb-gears__input" type="checkbox" />
<span className="cb-gears__box" aria-hidden="true">
<svg className="cb-gears__gear cb-gears__gear--small" viewBox="-10 -10 20 20" style={SMALL_VARS}>
<path className="cb-gears__teeth" d={SMALL} />
<circle className="cb-gears__hub" r="3.4" />
<circle className="cb-gears__axle" r="1.4" />
</svg>
<svg className="cb-gears__gear cb-gears__gear--big" viewBox="-16 -16 32 32">
<path className="cb-gears__teeth" d={BIG} />
<circle className="cb-gears__hub" r="10" />
<path className="cb-gears__tick" d="M-5.5 0.5L-1.8 4.2L5.5 -4" />
</svg>
</span>
Automate this
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
HTML
<label class="cb-gears"><input class="cb-gears__input" type="checkbox"/><span class="cb-gears__box" aria-hidden="true"><svg class="cb-gears__gear cb-gears__gear--small" viewBox="-10 -10 20 20" style="--s0:254deg;--s1:14deg"><path class="cb-gears__teeth" d="M6.80 0.00L9.33 1.78L8.32 4.58L5.24 4.33L3.40 5.89L3.12 8.97L0.20 9.50L-1.13 6.70L-3.40 5.89L-6.21 7.19L-8.13 4.92L-6.37 2.37L-6.80 0.00L-9.33 -1.78L-8.32 -4.58L-5.24 -4.33L-3.40 -5.89L-3.12 -8.97L-0.20 -9.50L1.13 -6.70L3.40 -5.89L6.21 -7.19L8.13 -4.92L6.37 -2.37Z"></path><circle class="cb-gears__hub" r="3.4"></circle><circle class="cb-gears__axle" r="1.4"></circle></svg><svg class="cb-gears__gear cb-gears__gear--big" viewBox="-16 -16 32 32"><path class="cb-gears__teeth" d="M12.50 0.00L15.40 1.75L14.80 4.60L11.44 5.04L10.11 7.35L11.43 10.47L9.27 12.42L6.30 10.80L3.86 11.89L3.10 15.19L0.19 15.50L-1.25 12.44L-3.86 11.89L-6.42 14.11L-8.95 12.65L-8.33 9.32L-10.11 7.35L-13.49 7.64L-14.68 4.97L-12.22 2.65L-12.50 0.00L-15.40 -1.75L-14.80 -4.60L-11.44 -5.04L-10.11 -7.35L-11.43 -10.47L-9.27 -12.42L-6.30 -10.80L-3.86 -11.89L-3.10 -15.19L-0.19 -15.50L1.25 -12.44L3.86 -11.89L6.42 -14.11L8.95 -12.65L8.33 -9.32L10.11 -7.35L13.49 -7.64L14.68 -4.97L12.22 -2.65Z"></path><circle class="cb-gears__hub" r="10"></circle><path class="cb-gears__tick" d="M-5.5 0.5L-1.8 4.2L5.5 -4"></path></svg></span>Automate this</label>CSS
.cb-gears { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.cb-gears__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.cb-gears__box { position: relative; width: 48px; height: 38px; border-radius: 6px; }
.cb-gears__input:focus-visible + .cb-gears__box { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.cb-gears__gear { position: absolute; overflow: visible; transition: transform 0.75s cubic-bezier(0.35, 1.25, 0.5, 1); }
.cb-gears__gear--big { left: 1px; top: 6px; width: 32px; height: 32px; transform: rotate(-144deg); }
.cb-gears__gear--small { left: 25px; top: -1px; width: 20px; height: 20px; transform: rotate(var(--s0)); }
.cb-gears__teeth { fill: light-dark(#cbced3, #393c41); transition: fill 0.4s; }
.cb-gears__gear--small .cb-gears__teeth { fill: light-dark(#dbdde1, #2e3035); }
.cb-gears__hub { fill: light-dark(#ebedf0, #232529); }
.cb-gears__axle { fill: light-dark(#6d7179, #7d8087); }
.cb-gears__tick { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.4s; }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--big { transform: rotate(0deg); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--small { transform: rotate(var(--s1)); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__gear--big .cb-gears__teeth { fill: light-dark(#6d7179, #7d8087); }
.cb-gears__input:checked + .cb-gears__box .cb-gears__tick { stroke: light-dark(#373a40, #f1f2f3); transition-delay: 0.45s; }
@media (prefers-reduced-motion: reduce) {
.cb-gears__box * { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}Goal: Create a "Gears" checkbox.
Visual behavior: A gears checkbox: two meshed gears turn together, the small one the other way and faster, until the tick on the big gear stands upright and lights.
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 gear is an SVG path built from its tooth count and radii (rounded to two decimals so the server and the browser print the same path), turned by CSS.
- The small gear turns 10/6 as far the other way, set with CSS variables, and both share one overshooting curve so they stay meshed through the overshoot. 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 gears 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 "Gears" checkbox.
Visual behavior: A gears checkbox: two meshed gears turn together, the small one the other way and faster, until the tick on the big gear stands upright and lights.
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 gear is an SVG path built from its tooth count and radii (rounded to two decimals so the server and the browser print the same path), turned by CSS.
- The small gear turns 10/6 as far the other way, set with CSS variables, and both share one overshooting curve so they stay meshed through the overshoot. 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 gears 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 gears checkbox: two meshed gears turn together, the small one the other way and faster, until the tick on the big gear stands upright and lights.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- click, state change, spring
- Techniques
- svg, css transition, 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 gears jump to place.