Earbuds
const css = `
.toggle-earbuds { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-earbuds__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-earbuds__scene { position: relative; flex: none; }
.toggle-earbuds__input:focus-visible + .toggle-earbuds__scene { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 4px; border-radius: 8px; }
.toggle-earbuds__scene { width: 64px; height: 60px; perspective: 260px; }
.toggle-earbuds__case { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 30px; border-radius: 6px 6px 16px 16px; background: linear-gradient(light-dark(#50535b, #c6c8cd), light-dark(#6d7179, #7d8087)); box-shadow: 0 6px 12px -6px light-dark(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.6)); }
.toggle-earbuds__case::after { content: ''; position: absolute; left: 50%; top: 10px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: light-dark(#dbdde1, #2e3035); transition: background-color 0.2s 0.5s, box-shadow 0.2s 0.5s; }
/* The lid is hinged at the back: it flips up and the buds rise out on their stems. */
.toggle-earbuds__lid { position: absolute; left: 4px; right: 4px; bottom: 32px; height: 16px; border-radius: 16px 16px 4px 4px; background: linear-gradient(light-dark(#42454c, #e5e6e9), light-dark(#5f626a, #a7abb2)); transform-origin: 50% 100%; transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.5, 1); }
.toggle-earbuds__bud { position: absolute; bottom: 20px; width: 12px; height: 22px; transform: translateY(10px); opacity: 0; transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s; }
.toggle-earbuds__bud::before { content: ''; position: absolute; left: 0; top: 0; width: 12px; height: 12px; border-radius: 50%; background: light-dark(#373a40, #f1f2f3); }
.toggle-earbuds__bud::after { content: ''; position: absolute; left: 4px; top: 8px; width: 4px; height: 14px; border-radius: 2px; background: light-dark(#373a40, #f1f2f3); }
.toggle-earbuds__bud--l { left: 16px; }
.toggle-earbuds__bud--r { right: 16px; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__lid { transform: rotateX(-110deg); }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__bud { transform: none; opacity: 1; transition-delay: 0.3s; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__bud--r { transition-delay: 0.38s; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__case::after { background: light-dark(#fbfcfd, #121417); box-shadow: 0 0 6px light-dark(#fbfcfd, #121417); }
@media (prefers-reduced-motion: reduce) {
.toggle-earbuds * { transition: none !important; }
}
`;
export function EarbudsToggle() {
return (
<>
<style>
{css}
</style>
<label className="toggle-earbuds">
<input className="toggle-earbuds__input" type="checkbox" role="switch" />
<span className="toggle-earbuds__scene" aria-hidden="true">
<span className="toggle-earbuds__bud toggle-earbuds__bud--l" />
<span className="toggle-earbuds__bud toggle-earbuds__bud--r" />
<span className="toggle-earbuds__case" />
<span className="toggle-earbuds__lid" />
</span>
Connect
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
<label class="toggle-earbuds"><input class="toggle-earbuds__input" type="checkbox" role="switch"/><span class="toggle-earbuds__scene" aria-hidden="true"><span class="toggle-earbuds__bud toggle-earbuds__bud--l"></span><span class="toggle-earbuds__bud toggle-earbuds__bud--r"></span><span class="toggle-earbuds__case"></span><span class="toggle-earbuds__lid"></span></span>Connect</label>.toggle-earbuds { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-earbuds__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-earbuds__scene { position: relative; flex: none; }
.toggle-earbuds__input:focus-visible + .toggle-earbuds__scene { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 4px; border-radius: 8px; }
.toggle-earbuds__scene { width: 64px; height: 60px; perspective: 260px; }
.toggle-earbuds__case { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 30px; border-radius: 6px 6px 16px 16px; background: linear-gradient(light-dark(#50535b, #c6c8cd), light-dark(#6d7179, #7d8087)); box-shadow: 0 6px 12px -6px light-dark(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.6)); }
.toggle-earbuds__case::after { content: ''; position: absolute; left: 50%; top: 10px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: light-dark(#dbdde1, #2e3035); transition: background-color 0.2s 0.5s, box-shadow 0.2s 0.5s; }
/* The lid is hinged at the back: it flips up and the buds rise out on their stems. */
.toggle-earbuds__lid { position: absolute; left: 4px; right: 4px; bottom: 32px; height: 16px; border-radius: 16px 16px 4px 4px; background: linear-gradient(light-dark(#42454c, #e5e6e9), light-dark(#5f626a, #a7abb2)); transform-origin: 50% 100%; transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.5, 1); }
.toggle-earbuds__bud { position: absolute; bottom: 20px; width: 12px; height: 22px; transform: translateY(10px); opacity: 0; transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s; }
.toggle-earbuds__bud::before { content: ''; position: absolute; left: 0; top: 0; width: 12px; height: 12px; border-radius: 50%; background: light-dark(#373a40, #f1f2f3); }
.toggle-earbuds__bud::after { content: ''; position: absolute; left: 4px; top: 8px; width: 4px; height: 14px; border-radius: 2px; background: light-dark(#373a40, #f1f2f3); }
.toggle-earbuds__bud--l { left: 16px; }
.toggle-earbuds__bud--r { right: 16px; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__lid { transform: rotateX(-110deg); }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__bud { transform: none; opacity: 1; transition-delay: 0.3s; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__bud--r { transition-delay: 0.38s; }
.toggle-earbuds__input:checked + .toggle-earbuds__scene .toggle-earbuds__case::after { background: light-dark(#fbfcfd, #121417); box-shadow: 0 0 6px light-dark(#fbfcfd, #121417); }
@media (prefers-reduced-motion: reduce) {
.toggle-earbuds * { transition: none !important; }
}Goal: Create a "Earbuds" toggle.
Visual behavior: A connect switch drawn as an earbuds case: the lid flips open on its hinge, both buds rise out one after the other and the status light comes on.
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.
- The lid is hinged at its back edge and flips with rotateX(-110deg) inside a perspective, on an overshooting curve.
- The buds rise and fade in with staggered transition delays once the lid is open; the light on the case glows after them.
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 case opens 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 "Earbuds" toggle.
Visual behavior: A connect switch drawn as an earbuds case: the lid flips open on its hinge, both buds rise out one after the other and the status light comes on.
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.
- The lid is hinged at its back edge and flips with rotateX(-110deg) inside a perspective, on an overshooting curve.
- The buds rise and fade in with staggered transition delays once the lid is open; the light on the case glows after them.
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 case opens 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 connect switch drawn as an earbuds case: the lid flips open on its hinge, both buds rise out one after the other and the status light comes on.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- click, state change, 3d, delay stagger
- Techniques
- 3d transform, perspective, css transition, transition delay stagger
- 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 case opens instantly.