Mitosis
const css = `
.toggle-mitosis { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-mitosis__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-mitosis__track {
position: relative;
width: 76px;
height: 32px;
border-radius: 999px;
background: light-dark(#ebedf0, #232529);
box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035);
}
.toggle-mitosis__input:focus-visible + .toggle-mitosis__track { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.toggle-mitosis__defs { position: absolute; width: 0; height: 0; }
/* Blur then threshold the alpha: overlapping blobs fuse, separating ones neck and snap. */
.toggle-mitosis__goo { position: absolute; inset: 0; filter: url(#toggle-mitosis-goo); }
.toggle-mitosis__cell { position: absolute; top: 5px; width: 22px; height: 22px; border-radius: 50%; background: light-dark(#50535b, #c6c8cd); transition: transform 0.45s cubic-bezier(0.5, 0, 0.3, 1), background-color 0.3s; }
.toggle-mitosis__cell--a { left: 5px; transition-delay: 0.3s; }
.toggle-mitosis__cell--b { right: 5px; transform: scale(0); transition-delay: 0s; }
.toggle-mitosis__cell--c { left: 9px; top: 9px; width: 14px; height: 14px; transition: transform 0.6s cubic-bezier(0.6, 0, 0.4, 1) 0.05s, background-color 0.3s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell { background: light-dark(#373a40, #f1f2f3); }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--a { transform: scale(0); transition-delay: 0.15s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--b { transform: scale(1); transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s, background-color 0.3s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--c { transform: translateX(44px); }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--c, .toggle-mitosis__cell--c { transition-duration: 0.75s; }
@media (prefers-reduced-motion: reduce) {
.toggle-mitosis__cell { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
`;
export function MitosisToggle() {
return (
<>
<style>
{css}
</style>
<label className="toggle-mitosis">
<input className="toggle-mitosis__input" type="checkbox" role="switch" />
<span className="toggle-mitosis__track" aria-hidden="true">
<svg className="toggle-mitosis__defs">
<filter id="toggle-mitosis-goo" x="-20%" y="-50%" width="140%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="4" />
<feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8" />
</filter>
</svg>
<span className="toggle-mitosis__goo">
<span className="toggle-mitosis__cell toggle-mitosis__cell--a" />
<span className="toggle-mitosis__cell toggle-mitosis__cell--c" />
<span className="toggle-mitosis__cell toggle-mitosis__cell--b" />
</span>
</span>
Merge
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
<label class="toggle-mitosis"><input class="toggle-mitosis__input" type="checkbox" role="switch"/><span class="toggle-mitosis__track" aria-hidden="true"><svg class="toggle-mitosis__defs"><filter id="toggle-mitosis-goo" x="-20%" y="-50%" width="140%" height="200%"><feGaussianBlur in="SourceGraphic" stdDeviation="4"></feGaussianBlur><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8"></feColorMatrix></filter></svg><span class="toggle-mitosis__goo"><span class="toggle-mitosis__cell toggle-mitosis__cell--a"></span><span class="toggle-mitosis__cell toggle-mitosis__cell--c"></span><span class="toggle-mitosis__cell toggle-mitosis__cell--b"></span></span></span>Merge</label>.toggle-mitosis { position: relative; display: inline-flex; align-items: center; gap: 12px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-mitosis__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-mitosis__track {
position: relative;
width: 76px;
height: 32px;
border-radius: 999px;
background: light-dark(#ebedf0, #232529);
box-shadow: inset 0 0 0 1px light-dark(#dbdde1, #2e3035);
}
.toggle-mitosis__input:focus-visible + .toggle-mitosis__track { outline: 2px solid light-dark(#5f626a, #a7abb2); outline-offset: 3px; }
.toggle-mitosis__defs { position: absolute; width: 0; height: 0; }
/* Blur then threshold the alpha: overlapping blobs fuse, separating ones neck and snap. */
.toggle-mitosis__goo { position: absolute; inset: 0; filter: url(#toggle-mitosis-goo); }
.toggle-mitosis__cell { position: absolute; top: 5px; width: 22px; height: 22px; border-radius: 50%; background: light-dark(#50535b, #c6c8cd); transition: transform 0.45s cubic-bezier(0.5, 0, 0.3, 1), background-color 0.3s; }
.toggle-mitosis__cell--a { left: 5px; transition-delay: 0.3s; }
.toggle-mitosis__cell--b { right: 5px; transform: scale(0); transition-delay: 0s; }
.toggle-mitosis__cell--c { left: 9px; top: 9px; width: 14px; height: 14px; transition: transform 0.6s cubic-bezier(0.6, 0, 0.4, 1) 0.05s, background-color 0.3s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell { background: light-dark(#373a40, #f1f2f3); }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--a { transform: scale(0); transition-delay: 0.15s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--b { transform: scale(1); transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s, background-color 0.3s; }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--c { transform: translateX(44px); }
.toggle-mitosis__input:checked + .toggle-mitosis__track .toggle-mitosis__cell--c, .toggle-mitosis__cell--c { transition-duration: 0.75s; }
@media (prefers-reduced-motion: reduce) {
.toggle-mitosis__cell { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}Goal: Create a "Mitosis" toggle.
Visual behavior: A merge switch made of goo: a cell stretches, necks and splits, and the drop that breaks away re-forms as a full cell at the other end.
Technique:
- A real native checkbox with role="switch" (visually hidden: absolute, 1x1, opacity 0) inside a <label>; every visual is aria-hidden and styled from the input with :checked + sibling selectors.
- Three blobs sit in a layer with an SVG goo filter: a Gaussian blur, then a colour matrix that turns alpha into a hard edge, so blobs close together fuse with a neck.
- Switching moves a small blob across while the source cell shrinks and the target cell swells in, so the goo stretches, snaps and re-forms.
Accessibility: A native checkbox with role="switch" inside a <label>, so Space toggles it and screen readers announce a switch; the visible label names it and :focus-visible on the input outlines the visual. Under prefers-reduced-motion the change is instant.
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 "Mitosis" toggle.
Visual behavior: A merge switch made of goo: a cell stretches, necks and splits, and the drop that breaks away re-forms as a full cell at the other end.
Technique:
- A real native checkbox with role="switch" (visually hidden: absolute, 1x1, opacity 0) inside a <label>; every visual is aria-hidden and styled from the input with :checked + sibling selectors.
- Three blobs sit in a layer with an SVG goo filter: a Gaussian blur, then a colour matrix that turns alpha into a hard edge, so blobs close together fuse with a neck.
- Switching moves a small blob across while the source cell shrinks and the target cell swells in, so the goo stretches, snaps and re-forms.
Accessibility: A native checkbox with role="switch" inside a <label>, so Space toggles it and screen readers announce a switch; the visible label names it and :focus-visible on the input outlines the visual. Under prefers-reduced-motion the change is instant.
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 merge switch made of goo: a cell stretches, necks and splits, and the drop that breaks away re-forms as a full cell at the other end.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- click, state change, morph
- Techniques
- svg filter, filter, css transition
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
A native checkbox with role="switch" inside a <label>, so Space toggles it and screen readers announce a switch; the visible label names it and :focus-visible on the input outlines the visual. Under prefers-reduced-motion the change is instant.