# Ladybug takeoff toggle

> On a leaf, the ladybug opens its red shell, unfolds its wings and hovers in the air.

- Category: [Toggles](https://library.aimran.es/components/toggles)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tg-ladybug
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This switch is a ladybug resting on a green leaf, seen from above with a black head, white eye dots and a spotted red shell. Turning it on splits the shell into two halves that swing open, thin transparent wings unfold and flutter, and the bug lifts off the leaf and hovers while its shadow shrinks below. It suits pest control and garden apps, nature lessons and gentle success states.

The main color is the shell and the second one is the leaf. A yellow shell gives a different species, and an autumn orange leaf changes the season. The hover bob follows the speed control.

## Code

### HTML

```html
<label class="uvq03-lby"><input type="checkbox" role="switch"><span class="lf"><i class="sh"></i><span class="bg"><i class="wg l"></i><i class="wg r"></i><i class="bd"></i><i class="hd"></i><i class="el l"></i><i class="el r"></i></span></span>Pest control</label>
```

### CSS

```css
.uvq03-lby {
  --c1: #e8322e;
  --c2: #5cb85c;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq03-lby {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

.uvq03-lby input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-lby .lf {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4em;
  border-radius: 50% 4% 50% 4%;
  background: linear-gradient(135deg,transparent calc(50% - .04em),color-mix(in srgb,#fff 45%,transparent) calc(50% - .04em) calc(50% + .04em),transparent calc(50% + .04em)),linear-gradient(135deg,color-mix(in srgb,var(--c2) 70%,#fff),var(--c2) 55%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: 0 .5em 1em -.5em rgba(0,0,0,.45);
}

.uvq03-lby .sh {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.6em;
  margin: -.7em 0 0 -.75em;
  border-radius: 50%;
  background: rgba(0,0,0,.28);
  filter: blur(.08em);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .bg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.6em;
  height: 2em;
  margin: -1.05em 0 0 -.8em;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-lby .bg i {
  position: absolute;
  display: block;
}

.uvq03-lby .bd {
  left: .08em;
  right: .08em;
  top: .35em;
  bottom: 0;
  border-radius: 50%;
  background: #1b1b1d;
}

.uvq03-lby .hd {
  left: 50%;
  top: 0;
  width: .8em;
  height: .6em;
  margin-left: -.4em;
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(circle at 30% 55%,#fff 0 .07em,transparent .08em),radial-gradient(circle at 70% 55%,#fff 0 .07em,transparent .08em),#1b1b1d;
}

.uvq03-lby .el {
  top: .4em;
  width: 50%;
  height: 1.6em;
  background: radial-gradient(circle at 50% 30%,#1b1b1d 0 .13em,transparent .14em),radial-gradient(circle at 40% 72%,#1b1b1d 0 .11em,transparent .12em),radial-gradient(circle at 75% 55%,#1b1b1d 0 .08em,transparent .09em),radial-gradient(circle at 30% 30%,color-mix(in srgb,var(--c1) 55%,#fff),var(--c1) 55%,color-mix(in srgb,var(--c1) 70%,#000));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-lby .el.l {
  left: 0;
  border-radius: 100% 0 0 100% / 50% 0 0 50%;
  transform-origin: 100% 0;
}

.uvq03-lby .el.r {
  right: 0;
  border-radius: 0 100% 100% 0 / 0 50% 50% 0;
  transform-origin: 0 0;
}

.uvq03-lby .wg {
  top: .55em;
  width: .85em;
  height: 2em;
  border-radius: 50%;
  background: linear-gradient(180deg,rgba(235,244,255,.9),rgba(205,225,245,.55));
  box-shadow: inset 0 0 0 .04em rgba(70,80,100,.55);
  transform: scale(0);
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .wg.l {
  left: .05em;
  transform-origin: 100% 0;
}

.uvq03-lby .wg.r {
  right: .05em;
  transform-origin: 0 0;
}

.uvq03-lby:hover input:not(:checked) + .lf .bg {
  transform: rotate(6deg);
}

.uvq03-lby:active .lf {
  scale: .97;
}

.uvq03-lby input:checked + .lf .el.l {
  transform: rotate(32deg);
}

.uvq03-lby input:checked + .lf .el.r {
  transform: rotate(-32deg);
}

.uvq03-lby input:checked + .lf .wg.l {
  transform: rotate(40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg.r {
  transform: rotate(-40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg {
  animation: uvq03-lby-f calc(0.09s / var(--k)) linear calc(0.55s / var(--k)) infinite alternate;
}

.uvq03-lby input:checked + .lf .bg {
  transform: translate(.2em,-.55em) scale(1.12);
  transition-delay: calc(0.3s / var(--k));
  animation: uvq03-lby calc(1.6s / var(--k)) ease-in-out calc(0.9s / var(--k)) infinite;
}

.uvq03-lby input:checked + .lf .sh {
  transform: scale(.7);
  opacity: .5;
  transition-delay: calc(0.3s / var(--k));
}

@keyframes uvq03-lby {
  50% {
    translate: 0 -.15em;
  }
}

@keyframes uvq03-lby-f {
  to {
    opacity: .55;
  }
}

.uvq03-lby input:focus-visible + .lf {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq03-lby,.uvq03-lby *,.uvq03-lby *::before,.uvq03-lby *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### React

```tsx
import type { CSSProperties } from "react";

const css = `
.uvq03-lby {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

.uvq03-lby input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-lby .lf {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4em;
  border-radius: 50% 4% 50% 4%;
  background: linear-gradient(135deg,transparent calc(50% - .04em),color-mix(in srgb,#fff 45%,transparent) calc(50% - .04em) calc(50% + .04em),transparent calc(50% + .04em)),linear-gradient(135deg,color-mix(in srgb,var(--c2) 70%,#fff),var(--c2) 55%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: 0 .5em 1em -.5em rgba(0,0,0,.45);
}

.uvq03-lby .sh {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.6em;
  margin: -.7em 0 0 -.75em;
  border-radius: 50%;
  background: rgba(0,0,0,.28);
  filter: blur(.08em);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .bg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.6em;
  height: 2em;
  margin: -1.05em 0 0 -.8em;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-lby .bg i {
  position: absolute;
  display: block;
}

.uvq03-lby .bd {
  left: .08em;
  right: .08em;
  top: .35em;
  bottom: 0;
  border-radius: 50%;
  background: #1b1b1d;
}

.uvq03-lby .hd {
  left: 50%;
  top: 0;
  width: .8em;
  height: .6em;
  margin-left: -.4em;
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(circle at 30% 55%,#fff 0 .07em,transparent .08em),radial-gradient(circle at 70% 55%,#fff 0 .07em,transparent .08em),#1b1b1d;
}

.uvq03-lby .el {
  top: .4em;
  width: 50%;
  height: 1.6em;
  background: radial-gradient(circle at 50% 30%,#1b1b1d 0 .13em,transparent .14em),radial-gradient(circle at 40% 72%,#1b1b1d 0 .11em,transparent .12em),radial-gradient(circle at 75% 55%,#1b1b1d 0 .08em,transparent .09em),radial-gradient(circle at 30% 30%,color-mix(in srgb,var(--c1) 55%,#fff),var(--c1) 55%,color-mix(in srgb,var(--c1) 70%,#000));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-lby .el.l {
  left: 0;
  border-radius: 100% 0 0 100% / 50% 0 0 50%;
  transform-origin: 100% 0;
}

.uvq03-lby .el.r {
  right: 0;
  border-radius: 0 100% 100% 0 / 0 50% 50% 0;
  transform-origin: 0 0;
}

.uvq03-lby .wg {
  top: .55em;
  width: .85em;
  height: 2em;
  border-radius: 50%;
  background: linear-gradient(180deg,rgba(235,244,255,.9),rgba(205,225,245,.55));
  box-shadow: inset 0 0 0 .04em rgba(70,80,100,.55);
  transform: scale(0);
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .wg.l {
  left: .05em;
  transform-origin: 100% 0;
}

.uvq03-lby .wg.r {
  right: .05em;
  transform-origin: 0 0;
}

.uvq03-lby:hover input:not(:checked) + .lf .bg {
  transform: rotate(6deg);
}

.uvq03-lby:active .lf {
  scale: .97;
}

.uvq03-lby input:checked + .lf .el.l {
  transform: rotate(32deg);
}

.uvq03-lby input:checked + .lf .el.r {
  transform: rotate(-32deg);
}

.uvq03-lby input:checked + .lf .wg.l {
  transform: rotate(40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg.r {
  transform: rotate(-40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg {
  animation: uvq03-lby-f calc(0.09s / var(--k)) linear calc(0.55s / var(--k)) infinite alternate;
}

.uvq03-lby input:checked + .lf .bg {
  transform: translate(.2em,-.55em) scale(1.12);
  transition-delay: calc(0.3s / var(--k));
  animation: uvq03-lby calc(1.6s / var(--k)) ease-in-out calc(0.9s / var(--k)) infinite;
}

.uvq03-lby input:checked + .lf .sh {
  transform: scale(.7);
  opacity: .5;
  transition-delay: calc(0.3s / var(--k));
}

@keyframes uvq03-lby {
  50% {
    translate: 0 -.15em;
  }
}

@keyframes uvq03-lby-f {
  to {
    opacity: .55;
  }
}

.uvq03-lby input:focus-visible + .lf {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq03-lby,.uvq03-lby *,.uvq03-lby *::before,.uvq03-lby *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function TgLadybug() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e8322e",
          "--c2": "#5cb85c",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-lby"><input type="checkbox" role="switch" /><span className="lf"><i className="sh"></i><span className="bg"><i className="wg l"></i><i className="wg r"></i><i className="bd"></i><i className="hd"></i><i className="el l"></i><i className="el r"></i></span></span>Pest control</label>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Ladybug takeoff toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
On a leaf, the ladybug opens its red shell, unfolds its wings and hovers in the air.

## Chosen settings
- Main color: #e8322e
- Secondary color: #5cb85c
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Control de plagas"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import type { CSSProperties } from "react";

const css = `
.uvq03-lby {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .8em;
  cursor: pointer;
  user-select: none;
  font-weight: 550;
}

.uvq03-lby input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-lby .lf {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4em;
  border-radius: 50% 4% 50% 4%;
  background: linear-gradient(135deg,transparent calc(50% - .04em),color-mix(in srgb,#fff 45%,transparent) calc(50% - .04em) calc(50% + .04em),transparent calc(50% + .04em)),linear-gradient(135deg,color-mix(in srgb,var(--c2) 70%,#fff),var(--c2) 55%,color-mix(in srgb,var(--c2) 70%,#000));
  box-shadow: 0 .5em 1em -.5em rgba(0,0,0,.45);
}

.uvq03-lby .sh {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5em;
  height: 1.6em;
  margin: -.7em 0 0 -.75em;
  border-radius: 50%;
  background: rgba(0,0,0,.28);
  filter: blur(.08em);
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.6s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .bg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.6em;
  height: 2em;
  margin: -1.05em 0 0 -.8em;
  transition: transform calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq03-lby .bg i {
  position: absolute;
  display: block;
}

.uvq03-lby .bd {
  left: .08em;
  right: .08em;
  top: .35em;
  bottom: 0;
  border-radius: 50%;
  background: #1b1b1d;
}

.uvq03-lby .hd {
  left: 50%;
  top: 0;
  width: .8em;
  height: .6em;
  margin-left: -.4em;
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(circle at 30% 55%,#fff 0 .07em,transparent .08em),radial-gradient(circle at 70% 55%,#fff 0 .07em,transparent .08em),#1b1b1d;
}

.uvq03-lby .el {
  top: .4em;
  width: 50%;
  height: 1.6em;
  background: radial-gradient(circle at 50% 30%,#1b1b1d 0 .13em,transparent .14em),radial-gradient(circle at 40% 72%,#1b1b1d 0 .11em,transparent .12em),radial-gradient(circle at 75% 55%,#1b1b1d 0 .08em,transparent .09em),radial-gradient(circle at 30% 30%,color-mix(in srgb,var(--c1) 55%,#fff),var(--c1) 55%,color-mix(in srgb,var(--c1) 70%,#000));
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq03-lby .el.l {
  left: 0;
  border-radius: 100% 0 0 100% / 50% 0 0 50%;
  transform-origin: 100% 0;
}

.uvq03-lby .el.r {
  right: 0;
  border-radius: 0 100% 100% 0 / 0 50% 50% 0;
  transform-origin: 0 0;
}

.uvq03-lby .wg {
  top: .55em;
  width: .85em;
  height: 2em;
  border-radius: 50%;
  background: linear-gradient(180deg,rgba(235,244,255,.9),rgba(205,225,245,.55));
  box-shadow: inset 0 0 0 .04em rgba(70,80,100,.55);
  transform: scale(0);
  transition: transform calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-lby .wg.l {
  left: .05em;
  transform-origin: 100% 0;
}

.uvq03-lby .wg.r {
  right: .05em;
  transform-origin: 0 0;
}

.uvq03-lby:hover input:not(:checked) + .lf .bg {
  transform: rotate(6deg);
}

.uvq03-lby:active .lf {
  scale: .97;
}

.uvq03-lby input:checked + .lf .el.l {
  transform: rotate(32deg);
}

.uvq03-lby input:checked + .lf .el.r {
  transform: rotate(-32deg);
}

.uvq03-lby input:checked + .lf .wg.l {
  transform: rotate(40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg.r {
  transform: rotate(-40deg) scale(1);
  transition-delay: calc(0.2s / var(--k));
}

.uvq03-lby input:checked + .lf .wg {
  animation: uvq03-lby-f calc(0.09s / var(--k)) linear calc(0.55s / var(--k)) infinite alternate;
}

.uvq03-lby input:checked + .lf .bg {
  transform: translate(.2em,-.55em) scale(1.12);
  transition-delay: calc(0.3s / var(--k));
  animation: uvq03-lby calc(1.6s / var(--k)) ease-in-out calc(0.9s / var(--k)) infinite;
}

.uvq03-lby input:checked + .lf .sh {
  transform: scale(.7);
  opacity: .5;
  transition-delay: calc(0.3s / var(--k));
}

@keyframes uvq03-lby {
  50% {
    translate: 0 -.15em;
  }
}

@keyframes uvq03-lby-f {
  to {
    opacity: .55;
  }
}

.uvq03-lby input:focus-visible + .lf {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

@media (prefers-reduced-motion:reduce) {
  .uvq03-lby,.uvq03-lby *,.uvq03-lby *::before,.uvq03-lby *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

export default function TgLadybug() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e8322e",
          "--c2": "#5cb85c",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-lby"><input type="checkbox" role="switch" /><span className="lf"><i className="sh"></i><span className="bg"><i className="wg l"></i><i className="wg r"></i><i className="bd"></i><i className="hd"></i><i className="el l"></i><i className="el r"></i></span></span>Pest control</label>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
