# Venus flytrap toggle

> A Venus flytrap in a clay pot: switch it on and its two spiky lobes snap shut on the buzzing fly.

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

## Where to use it

This switch is a small carnivorous plant in a terracotta pot, with a fly buzzing above two open lobes that are red inside and lined with green spines. Turning it on snaps the lobes shut with a quick spring, the spines interlock, the fly disappears inside and the trap gives a short shake. It fits spam filters, blockers and playful garden sites.

The main color is the inside of the trap and the second one is the plant green. A deep wine red with dark green looks more realistic, while brighter pairs suit a cartoon style. Keep the label short and direct.

## Code

### HTML

```html
<label class="uvq03-fly"><input type="checkbox" role="switch"><span class="pl"><i class="st"></i><i class="lf a"></i><i class="lf b"></i><span class="tr"><i class="lb l"></i><i class="lb r"></i></span><span class="fy"><i></i></span><i class="pt"></i></span>Catch the spam</label>
```

### CSS

```css
.uvq03-fly {
  --c1: #e0414f;
  --c2: #62b83a;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq03-fly {
  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-fly input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-fly .pl {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-fly .pl > i,.uvq03-fly .lb {
  position: absolute;
  display: block;
}

.uvq03-fly .st {
  left: calc(50% - .08em);
  top: 2.05em;
  width: .16em;
  height: 1.7em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--c2) 80%,#1d3a10);
}

.uvq03-fly .lf {
  top: 3em;
  width: .9em;
  height: .36em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2));
}

.uvq03-fly .lf.a {
  left: 1.15em;
  transform: rotate(-25deg);
}

.uvq03-fly .lf.b {
  left: 2em;
  transform: rotate(25deg);
}

.uvq03-fly .pt {
  left: 1.15em;
  bottom: 0;
  width: 1.7em;
  height: 1em;
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  background: linear-gradient(90deg,#a9532d,#d9804f 40%,#b9603a);
  box-shadow: inset 0 .22em 0 #e8956a;
}

.uvq03-fly .tr {
  position: absolute;
  left: 50%;
  top: 2.1em;
  width: 0;
  height: 0;
}

.uvq03-fly .lb {
  bottom: 0;
  width: 1.25em;
  height: 1.5em;
  margin-left: -.625em;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  transform-origin: 50% 100%;
  background: radial-gradient(70% 60% at 50% 45%,var(--c1),color-mix(in srgb,var(--c1) 55%,var(--c2)) 70%,var(--c2) 88%);
  box-shadow: inset 0 0 0 .08em color-mix(in srgb,var(--c2) 70%,#1d3a10);
  transition: transform calc(0.18s / var(--k)) cubic-bezier(.5,1.6,.6,1);
}

.uvq03-fly .lb::before {
  content: "";
  position: absolute;
  top: .1em;
  bottom: .4em;
  width: .42em;
  background: repeating-linear-gradient(180deg,color-mix(in srgb,var(--c2) 75%,#fff) 0 .05em,transparent .05em .18em);
}

.uvq03-fly .lb.l {
  margin-left: -1.05em;
  transform: rotate(-30deg);
}

.uvq03-fly .lb.l::before {
  right: -.34em;
}

.uvq03-fly .lb.r {
  margin-left: -.2em;
  transform: rotate(30deg);
}

.uvq03-fly .lb.r::before {
  left: -.34em;
}

.uvq03-fly .fy {
  position: absolute;
  left: calc(50% - .2em);
  top: .05em;
  width: .4em;
  height: .3em;
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-fly .fy i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 80%,#333);
  animation: uvq03-fly calc(1.6s / var(--k)) ease-in-out infinite;
}

.uvq03-fly .fy i::before,.uvq03-fly .fy i::after {
  content: "";
  position: absolute;
  top: -.2em;
  width: .26em;
  height: .22em;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 25%,transparent);
  animation: uvq03-fly-w calc(0.08s / var(--k)) linear infinite alternate;
}

.uvq03-fly .fy i::before {
  left: -.08em;
}

.uvq03-fly .fy i::after {
  right: -.08em;
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.l {
  transform: rotate(-22deg);
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.r {
  transform: rotate(22deg);
}

.uvq03-fly:active .pl {
  scale: .97;
}

.uvq03-fly input:checked + .pl .fy {
  opacity: 0;
  transform: translateY(1.1em) scale(.4);
}

.uvq03-fly input:checked + .pl .lb.l {
  transform: translateX(.38em) rotate(-3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .lb.r {
  transform: translateX(-.38em) rotate(3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .tr {
  animation: uvq03-fly-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.3s / var(--k));
}

@keyframes uvq03-fly {
  0%,100% {
    transform: translate(0,0);
  }
  25% {
    transform: translate(.35em,.15em);
  }
  50% {
    transform: translate(-.1em,.3em);
  }
  75% {
    transform: translate(-.35em,.05em);
  }
}

@keyframes uvq03-fly-w {
  to {
    transform: scaleY(.4);
  }
}

@keyframes uvq03-fly-s {
  30% {
    transform: rotate(4deg);
  }
  60% {
    transform: rotate(-3deg);
  }
}

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

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

### React

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

const css = `
.uvq03-fly {
  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-fly input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-fly .pl {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-fly .pl > i,.uvq03-fly .lb {
  position: absolute;
  display: block;
}

.uvq03-fly .st {
  left: calc(50% - .08em);
  top: 2.05em;
  width: .16em;
  height: 1.7em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--c2) 80%,#1d3a10);
}

.uvq03-fly .lf {
  top: 3em;
  width: .9em;
  height: .36em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2));
}

.uvq03-fly .lf.a {
  left: 1.15em;
  transform: rotate(-25deg);
}

.uvq03-fly .lf.b {
  left: 2em;
  transform: rotate(25deg);
}

.uvq03-fly .pt {
  left: 1.15em;
  bottom: 0;
  width: 1.7em;
  height: 1em;
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  background: linear-gradient(90deg,#a9532d,#d9804f 40%,#b9603a);
  box-shadow: inset 0 .22em 0 #e8956a;
}

.uvq03-fly .tr {
  position: absolute;
  left: 50%;
  top: 2.1em;
  width: 0;
  height: 0;
}

.uvq03-fly .lb {
  bottom: 0;
  width: 1.25em;
  height: 1.5em;
  margin-left: -.625em;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  transform-origin: 50% 100%;
  background: radial-gradient(70% 60% at 50% 45%,var(--c1),color-mix(in srgb,var(--c1) 55%,var(--c2)) 70%,var(--c2) 88%);
  box-shadow: inset 0 0 0 .08em color-mix(in srgb,var(--c2) 70%,#1d3a10);
  transition: transform calc(0.18s / var(--k)) cubic-bezier(.5,1.6,.6,1);
}

.uvq03-fly .lb::before {
  content: "";
  position: absolute;
  top: .1em;
  bottom: .4em;
  width: .42em;
  background: repeating-linear-gradient(180deg,color-mix(in srgb,var(--c2) 75%,#fff) 0 .05em,transparent .05em .18em);
}

.uvq03-fly .lb.l {
  margin-left: -1.05em;
  transform: rotate(-30deg);
}

.uvq03-fly .lb.l::before {
  right: -.34em;
}

.uvq03-fly .lb.r {
  margin-left: -.2em;
  transform: rotate(30deg);
}

.uvq03-fly .lb.r::before {
  left: -.34em;
}

.uvq03-fly .fy {
  position: absolute;
  left: calc(50% - .2em);
  top: .05em;
  width: .4em;
  height: .3em;
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-fly .fy i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 80%,#333);
  animation: uvq03-fly calc(1.6s / var(--k)) ease-in-out infinite;
}

.uvq03-fly .fy i::before,.uvq03-fly .fy i::after {
  content: "";
  position: absolute;
  top: -.2em;
  width: .26em;
  height: .22em;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 25%,transparent);
  animation: uvq03-fly-w calc(0.08s / var(--k)) linear infinite alternate;
}

.uvq03-fly .fy i::before {
  left: -.08em;
}

.uvq03-fly .fy i::after {
  right: -.08em;
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.l {
  transform: rotate(-22deg);
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.r {
  transform: rotate(22deg);
}

.uvq03-fly:active .pl {
  scale: .97;
}

.uvq03-fly input:checked + .pl .fy {
  opacity: 0;
  transform: translateY(1.1em) scale(.4);
}

.uvq03-fly input:checked + .pl .lb.l {
  transform: translateX(.38em) rotate(-3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .lb.r {
  transform: translateX(-.38em) rotate(3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .tr {
  animation: uvq03-fly-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.3s / var(--k));
}

@keyframes uvq03-fly {
  0%,100% {
    transform: translate(0,0);
  }
  25% {
    transform: translate(.35em,.15em);
  }
  50% {
    transform: translate(-.1em,.3em);
  }
  75% {
    transform: translate(-.35em,.05em);
  }
}

@keyframes uvq03-fly-w {
  to {
    transform: scaleY(.4);
  }
}

@keyframes uvq03-fly-s {
  30% {
    transform: rotate(4deg);
  }
  60% {
    transform: rotate(-3deg);
  }
}

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

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

export default function TgFlytrap() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e0414f",
          "--c2": "#62b83a",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-fly"><input type="checkbox" role="switch" /><span className="pl"><i className="st"></i><i className="lf a"></i><i className="lf b"></i><span className="tr"><i className="lb l"></i><i className="lb r"></i></span><span className="fy"><i></i></span><i className="pt"></i></span>Catch the spam</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 “Venus flytrap toggle” block (Toggles) from AIMRAN Library to my project.

## What it is
A Venus flytrap in a clay pot: switch it on and its two spiky lobes snap shut on the buzzing fly.

## Chosen settings
- Main color: #e0414f
- Secondary color: #62b83a
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Atrapar el spam"

## 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-fly {
  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-fly input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.uvq03-fly .pl {
  position: relative;
  display: block;
  flex: none;
  width: 4em;
  height: 4.6em;
  border-radius: .5em;
}

.uvq03-fly .pl > i,.uvq03-fly .lb {
  position: absolute;
  display: block;
}

.uvq03-fly .st {
  left: calc(50% - .08em);
  top: 2.05em;
  width: .16em;
  height: 1.7em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--c2) 80%,#1d3a10);
}

.uvq03-fly .lf {
  top: 3em;
  width: .9em;
  height: .36em;
  border-radius: 50%;
  background: linear-gradient(180deg,color-mix(in srgb,var(--c2) 80%,#fff),var(--c2));
}

.uvq03-fly .lf.a {
  left: 1.15em;
  transform: rotate(-25deg);
}

.uvq03-fly .lf.b {
  left: 2em;
  transform: rotate(25deg);
}

.uvq03-fly .pt {
  left: 1.15em;
  bottom: 0;
  width: 1.7em;
  height: 1em;
  clip-path: polygon(0 0,100% 0,88% 100%,12% 100%);
  background: linear-gradient(90deg,#a9532d,#d9804f 40%,#b9603a);
  box-shadow: inset 0 .22em 0 #e8956a;
}

.uvq03-fly .tr {
  position: absolute;
  left: 50%;
  top: 2.1em;
  width: 0;
  height: 0;
}

.uvq03-fly .lb {
  bottom: 0;
  width: 1.25em;
  height: 1.5em;
  margin-left: -.625em;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  transform-origin: 50% 100%;
  background: radial-gradient(70% 60% at 50% 45%,var(--c1),color-mix(in srgb,var(--c1) 55%,var(--c2)) 70%,var(--c2) 88%);
  box-shadow: inset 0 0 0 .08em color-mix(in srgb,var(--c2) 70%,#1d3a10);
  transition: transform calc(0.18s / var(--k)) cubic-bezier(.5,1.6,.6,1);
}

.uvq03-fly .lb::before {
  content: "";
  position: absolute;
  top: .1em;
  bottom: .4em;
  width: .42em;
  background: repeating-linear-gradient(180deg,color-mix(in srgb,var(--c2) 75%,#fff) 0 .05em,transparent .05em .18em);
}

.uvq03-fly .lb.l {
  margin-left: -1.05em;
  transform: rotate(-30deg);
}

.uvq03-fly .lb.l::before {
  right: -.34em;
}

.uvq03-fly .lb.r {
  margin-left: -.2em;
  transform: rotate(30deg);
}

.uvq03-fly .lb.r::before {
  left: -.34em;
}

.uvq03-fly .fy {
  position: absolute;
  left: calc(50% - .2em);
  top: .05em;
  width: .4em;
  height: .3em;
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq03-fly .fy i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 80%,#333);
  animation: uvq03-fly calc(1.6s / var(--k)) ease-in-out infinite;
}

.uvq03-fly .fy i::before,.uvq03-fly .fy i::after {
  content: "";
  position: absolute;
  top: -.2em;
  width: .26em;
  height: .22em;
  border-radius: 50%;
  background: color-mix(in srgb,var(--fg) 25%,transparent);
  animation: uvq03-fly-w calc(0.08s / var(--k)) linear infinite alternate;
}

.uvq03-fly .fy i::before {
  left: -.08em;
}

.uvq03-fly .fy i::after {
  right: -.08em;
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.l {
  transform: rotate(-22deg);
}

.uvq03-fly:hover input:not(:checked) + .pl .lb.r {
  transform: rotate(22deg);
}

.uvq03-fly:active .pl {
  scale: .97;
}

.uvq03-fly input:checked + .pl .fy {
  opacity: 0;
  transform: translateY(1.1em) scale(.4);
}

.uvq03-fly input:checked + .pl .lb.l {
  transform: translateX(.38em) rotate(-3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .lb.r {
  transform: translateX(-.38em) rotate(3deg);
  transition-delay: calc(0.12s / var(--k));
}

.uvq03-fly input:checked + .pl .tr {
  animation: uvq03-fly-s calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.3s / var(--k));
}

@keyframes uvq03-fly {
  0%,100% {
    transform: translate(0,0);
  }
  25% {
    transform: translate(.35em,.15em);
  }
  50% {
    transform: translate(-.1em,.3em);
  }
  75% {
    transform: translate(-.35em,.05em);
  }
}

@keyframes uvq03-fly-w {
  to {
    transform: scaleY(.4);
  }
}

@keyframes uvq03-fly-s {
  30% {
    transform: rotate(4deg);
  }
  60% {
    transform: rotate(-3deg);
  }
}

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

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

export default function TgFlytrap() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#e0414f",
          "--c2": "#62b83a",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uvq03-fly"><input type="checkbox" role="switch" /><span className="pl"><i className="st"></i><i className="lf a"></i><i className="lf b"></i><span className="tr"><i className="lb l"></i><i className="lb r"></i></span><span className="fy"><i></i></span><i className="pt"></i></span>Catch the spam</label>
      </div>
    </>
  );
}
```

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