Umbrella
const DROPS = [{ x: 8, d: 0 }, { x: 22, d: -0.4 }, { x: 36, d: -0.15 }, { x: 50, d: -0.6 }, { x: 62, d: -0.3 }];
const css = `
.toggle-umbrella { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-umbrella__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-umbrella__scene { position: relative; flex: none; }
.toggle-umbrella__input:focus-visible + .toggle-umbrella__scene { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 4px; border-radius: 8px; }
@keyframes toggle-umbrella-rain { from { transform: translateY(-14px); opacity: 0; } 20% { opacity: 0.8; } to { transform: translateY(var(--to)); opacity: 0; } }
.toggle-umbrella__scene { width: 70px; height: 62px; }
.toggle-umbrella__drop { position: absolute; top: 0; width: 1.5px; height: 8px; border-radius: 1px; background: light-dark(#5f626a, #a7abb2); --to: 58px; animation: toggle-umbrella-rain 0.8s linear infinite var(--d); }
/* Open, the drops stop at the canopy instead of falling through. */
.toggle-umbrella__input:checked + .toggle-umbrella__scene .toggle-umbrella__drop { --to: 8px; }
.toggle-umbrella__canopy { position: absolute; left: 5px; top: 14px; width: 60px; height: 26px; overflow: visible; transform-origin: 30px 2px; transform: scale(0.16, 1.15); transition: transform 0.55s cubic-bezier(0.3, 1.5, 0.5, 1); }
.toggle-umbrella__canopy path { fill: light-dark(#50535b, #c6c8cd); }
.toggle-umbrella__canopy .toggle-umbrella__rib { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 1; }
.toggle-umbrella__input:checked + .toggle-umbrella__scene .toggle-umbrella__canopy { transform: none; }
.toggle-umbrella__shaft { position: absolute; left: 34px; top: 10px; width: 2px; height: 42px; background: light-dark(#42454c, #e5e6e9); }
.toggle-umbrella__handle { position: absolute; left: 34px; top: 46px; width: 10px; height: 10px; border: 2px solid light-dark(#42454c, #e5e6e9); border-top: 0; border-radius: 0 0 6px 6px; }
.toggle-umbrella__tip { position: absolute; left: 33px; top: 7px; width: 4px; height: 5px; border-radius: 2px; background: light-dark(#42454c, #e5e6e9); }
@media (prefers-reduced-motion: reduce) {
.toggle-umbrella__drop { animation: none; opacity: 0; }
.toggle-umbrella__canopy { transition: none; }
}
`;
export function UmbrellaToggle() {
return (
<>
<style>
{css}
</style>
<label className="toggle-umbrella">
<input className="toggle-umbrella__input" type="checkbox" role="switch" />
<span className="toggle-umbrella__scene" aria-hidden="true">
{DROPS.map((d) => (
<span key={d.x} className="toggle-umbrella__drop" style={{ left: d.x, '--d': `${d.d}s` } as React.CSSProperties} />
))}
<span className="toggle-umbrella__tip" />
<span className="toggle-umbrella__shaft" />
<span className="toggle-umbrella__handle" />
<svg className="toggle-umbrella__canopy" viewBox="0 0 60 26">
<path d="M0 24C2 10 15 2 30 2S58 10 60 24C56 21 50 21 45 24C40 21 35 21 30 24C25 21 20 21 15 24C10 21 4 21 0 24Z" />
<path className="toggle-umbrella__rib" d="M30 2L15 24M30 2L45 24M30 2V24" />
</svg>
</span>
Rain cover
</label>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
<label class="toggle-umbrella"><input class="toggle-umbrella__input" type="checkbox" role="switch"/><span class="toggle-umbrella__scene" aria-hidden="true"><span class="toggle-umbrella__drop" style="left:8px;--d:0s"></span><span class="toggle-umbrella__drop" style="left:22px;--d:-0.4s"></span><span class="toggle-umbrella__drop" style="left:36px;--d:-0.15s"></span><span class="toggle-umbrella__drop" style="left:50px;--d:-0.6s"></span><span class="toggle-umbrella__drop" style="left:62px;--d:-0.3s"></span><span class="toggle-umbrella__tip"></span><span class="toggle-umbrella__shaft"></span><span class="toggle-umbrella__handle"></span><svg class="toggle-umbrella__canopy" viewBox="0 0 60 26"><path d="M0 24C2 10 15 2 30 2S58 10 60 24C56 21 50 21 45 24C40 21 35 21 30 24C25 21 20 21 15 24C10 21 4 21 0 24Z"></path><path class="toggle-umbrella__rib" d="M30 2L15 24M30 2L45 24M30 2V24"></path></svg></span>Rain cover</label>.toggle-umbrella { position: relative; display: inline-flex; align-items: center; gap: 14px; color: light-dark(#42454c, #e5e6e9); font-size: 14px; cursor: pointer; user-select: none; }
.toggle-umbrella__input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.toggle-umbrella__scene { position: relative; flex: none; }
.toggle-umbrella__input:focus-visible + .toggle-umbrella__scene { outline: 2px solid light-dark(#50535b, #c6c8cd); outline-offset: 4px; border-radius: 8px; }
@keyframes toggle-umbrella-rain { from { transform: translateY(-14px); opacity: 0; } 20% { opacity: 0.8; } to { transform: translateY(var(--to)); opacity: 0; } }
.toggle-umbrella__scene { width: 70px; height: 62px; }
.toggle-umbrella__drop { position: absolute; top: 0; width: 1.5px; height: 8px; border-radius: 1px; background: light-dark(#5f626a, #a7abb2); --to: 58px; animation: toggle-umbrella-rain 0.8s linear infinite var(--d); }
/* Open, the drops stop at the canopy instead of falling through. */
.toggle-umbrella__input:checked + .toggle-umbrella__scene .toggle-umbrella__drop { --to: 8px; }
.toggle-umbrella__canopy { position: absolute; left: 5px; top: 14px; width: 60px; height: 26px; overflow: visible; transform-origin: 30px 2px; transform: scale(0.16, 1.15); transition: transform 0.55s cubic-bezier(0.3, 1.5, 0.5, 1); }
.toggle-umbrella__canopy path { fill: light-dark(#50535b, #c6c8cd); }
.toggle-umbrella__canopy .toggle-umbrella__rib { fill: none; stroke: light-dark(#6d7179, #7d8087); stroke-width: 1; }
.toggle-umbrella__input:checked + .toggle-umbrella__scene .toggle-umbrella__canopy { transform: none; }
.toggle-umbrella__shaft { position: absolute; left: 34px; top: 10px; width: 2px; height: 42px; background: light-dark(#42454c, #e5e6e9); }
.toggle-umbrella__handle { position: absolute; left: 34px; top: 46px; width: 10px; height: 10px; border: 2px solid light-dark(#42454c, #e5e6e9); border-top: 0; border-radius: 0 0 6px 6px; }
.toggle-umbrella__tip { position: absolute; left: 33px; top: 7px; width: 4px; height: 5px; border-radius: 2px; background: light-dark(#42454c, #e5e6e9); }
@media (prefers-reduced-motion: reduce) {
.toggle-umbrella__drop { animation: none; opacity: 0; }
.toggle-umbrella__canopy { transition: none; }
}Goal: Create a "Umbrella" toggle.
Visual behavior: A rain cover switch: the umbrella snaps open with a springy flare, and the falling rain stops on the canopy instead of running through.
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 canopy is an SVG scaled to a narrow furled shape (scale(0.16, 1.15)) and springs open to scale 1 on an overshooting curve.
- Five drops share one falling keyframe whose end point is a --to custom property; checking the input shortens --to so the drops stop at the canopy.
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 canopy opens instantly and the rain is hidden.
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 "Umbrella" toggle.
Visual behavior: A rain cover switch: the umbrella snaps open with a springy flare, and the falling rain stops on the canopy instead of running through.
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 canopy is an SVG scaled to a narrow furled shape (scale(0.16, 1.15)) and springs open to scale 1 on an overshooting curve.
- Five drops share one falling keyframe whose end point is a --to custom property; checking the input shortens --to so the drops stop at the canopy.
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 canopy opens instantly and the rain is hidden.
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 rain cover switch: the umbrella snaps open with a springy flare, and the falling rain stops on the canopy instead of running through.
- Dependencies
- None
- Difficulty
- Beginner
- Triggers
- click, state change, spring, continuous
- Techniques
- css transition, keyframes, css variables, svg
- 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 canopy opens instantly and the rain is hidden.