# Retry by plugging in the cable

> The plug hangs loose; retry or drag it and it springs into the socket, a spark flies and the light turns on.

- Category: [Microinteractions](https://library.aimran.es/components/microinteractions)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-mi27-plug-retry
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Offline states usually show a gray icon and a retry link. This one gives the moment a physical form: a plug dangles on its cable next to a wall socket, and pressing Retry or dragging the plug sends it into the socket with a spring, a small spark and a green pilot light. The cable curve recalculates as the plug moves.

The main color is the connected state and the secondary one the spark. Replace the simulated connection with your real reconnect call and only move the plug when it succeeds. Disconnect pulls it out again, which makes the demo easy to replay.

## Code

### HTML

```html
<div class="uvq15-plg"><svg class="sc" viewBox="0 0 260 110" aria-hidden="true"><path class="cb" d="M-10 86 C24 108 42 55 64 55"/><g class="pg" transform="translate(70 0)"><rect class="pr" x="30" y="44" width="14" height="5" rx="1.5"/><rect class="pr" x="30" y="61" width="14" height="5" rx="1.5"/><rect class="gr" x="-8" y="47" width="12" height="16" rx="3"/><rect class="bd" x="0" y="38" width="34" height="34" rx="8"/><rect class="hl" x="5" y="42" width="5" height="26" rx="2.5"/></g><rect class="pl" x="206" y="18" width="46" height="74" rx="9"/><rect class="ho" x="214" y="44" width="7" height="5" rx="1.5"/><rect class="ho" x="214" y="61" width="7" height="5" rx="1.5"/><circle class="led" cx="238" cy="30" r="3.2"/><g class="spk"><line x1="201.1" y1="51.0" x2="192.4" y2="46.0"/><line x1="208.0" y1="47.0" x2="208.0" y2="37.0"/><line x1="214.9" y1="51.0" x2="223.6" y2="46.0"/><line x1="214.9" y1="59.0" x2="223.6" y2="64.0"/><line x1="208.0" y1="63.0" x2="208.0" y2="73.0"/><line x1="201.1" y1="59.0" x2="192.4" y2="64.0"/></g></svg><div class="ft"><p class="st" aria-live="polite"><i></i><b>Offline</b></p><button type="button" class="bt">Retry</button></div></div>
```

### CSS

```css
.uvq15-plg {
  --c1: #16a34a;
  --c2: #f59e0b;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq15-plg {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  gap: .8em;
  width: 18em;
  padding: 1em;
}

.uvq15-plg .sc {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: .8em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  touch-action: none;
}

.uvq15-plg .cb {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 70%,transparent);
  stroke-width: 5;
  stroke-linecap: round;
}

.uvq15-plg .pg {
  cursor: grab;
}

.uvq15-plg.drag .pg {
  cursor: grabbing;
}

.uvq15-plg .bd {
  fill: #e5e7eb;
  stroke: #9ca3af;
  stroke-width: 1.5;
}

.uvq15-plg .gr {
  fill: #6b7280;
}

.uvq15-plg .hl {
  fill: #fff;
  opacity: .7;
}

.uvq15-plg .pr {
  fill: #d4a017;
  stroke: #a16207;
  stroke-width: 1;
}

.uvq15-plg .pl {
  fill: #f1f5f9;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.uvq15-plg .ho {
  fill: #1f2937;
}

.uvq15-plg .led {
  fill: #cbd5e1;
  transition: fill calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.on .led {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-plg .spk line {
  stroke: var(--c2);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0;
}

.uvq15-plg .spk.go line {
  animation: uvq15-plg-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq15-plg-s {
  0% {
    opacity: 1;
    stroke-dasharray: 0 20;
  }
  40% {
    opacity: 1;
    stroke-dasharray: 10 20;
  }
  100% {
    opacity: 0;
    stroke-dasharray: 10 20;
    stroke-dashoffset: -10;
  }
}

.uvq15-plg .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8em;
}

.uvq15-plg .st {
  display: flex;
  align-items: center;
  gap: .45em;
  margin: 0;
  font-size: .85em;
}

.uvq15-plg .st i {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 .2em color-mix(in srgb,#ef4444 20%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.try .st i {
  background: var(--c2);
  animation: uvq15-plg-p calc(0.8s / var(--k)) ease-in-out infinite;
}

@keyframes uvq15-plg-p {
  50% {
    opacity: .3;
  }
}

.uvq15-plg.on .st i {
  background: var(--c1);
  box-shadow: 0 0 0 .2em color-mix(in srgb,var(--c1) 22%,transparent);
}

.uvq15-plg .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .6em 1.1em;
  border-radius: .7em;
  font-size: .9em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform .15s cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg .bt:hover {
  filter: brightness(1.08);
}

.uvq15-plg .bt:active {
  transform: scale(.96);
}

.uvq15-plg .bt:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-plg.on .bt {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

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

### JavaScript

```js
document.querySelectorAll(".uvq15-plg").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const sc=el.querySelector(".sc"),pg=el.querySelector(".pg"),cb=el.querySelector(".cb"),spk=el.querySelector(".spk"),st=el.querySelector(".st b"),bt=el.querySelector(".bt"),t0=bt.textContent,X0=70,X1=172;let x=X0,v=0,goal=X0,raf=0,drag=false,gx=0,on=false;
const draw=()=>{pg.setAttribute("transform","translate("+x.toFixed(2)+" 0)");const e=x-6,s=Math.max(0,(X1-x)/(X1-X0));cb.setAttribute("d","M-10 86 C"+(e*.35).toFixed(1)+" "+(86+22*s).toFixed(1)+" "+(e*.6).toFixed(1)+" "+(55+8*s).toFixed(1)+" "+e.toFixed(1)+" 55")};
const plugged=()=>{if(on)return;on=true;el.classList.remove("try");el.classList.add("on");spk.classList.remove("go");void spk.getBoundingClientRect();spk.classList.add("go");st.textContent="Connected";bt.textContent="Disconnect"};
const loose=()=>{if(!on)return;on=false;el.classList.remove("on");st.textContent="Offline";bt.textContent=t0};
const loop=()=>{v=(v+(goal-x)*.09)*.78;x+=v;if(x>X1){x=X1;v=-v*.25}if(Math.abs(goal-x)<.3&&Math.abs(v)<.15){x=goal;raf=0}else raf=requestAnimationFrame(loop);draw();if(x>=X1-.5)plugged();else if(x<X1-6)loose()};
const go=t=>{goal=t;if(rm){x=t;draw();if(t===X1)plugged();else loose();return}if(!raf)raf=requestAnimationFrame(loop)};
const sx=e=>{const r=sc.getBoundingClientRect();return(e.clientX-r.left)/r.width*260};
pg.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;v=0;gx=sx(e)-x;sc.setPointerCapture(e.pointerId);el.classList.add("drag")});
sc.addEventListener("pointermove",e=>{if(!drag)return;x=Math.max(30,Math.min(X1,sx(e)-gx));draw();if(x>=X1-.5)plugged();else loose()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(x>=X1-30){el.classList.add("try");st.textContent="Connecting…"}go(x>=X1-30?X1:X0)};sc.addEventListener("pointerup",up);sc.addEventListener("pointercancel",up);
bt.addEventListener("click",()=>{if(on){v=-6;go(X0);return}el.classList.add("try");st.textContent="Connecting…";go(X1)});draw();return()=>cancelAnimationFrame(raf)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq15-plg {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  gap: .8em;
  width: 18em;
  padding: 1em;
}

.uvq15-plg .sc {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: .8em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  touch-action: none;
}

.uvq15-plg .cb {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 70%,transparent);
  stroke-width: 5;
  stroke-linecap: round;
}

.uvq15-plg .pg {
  cursor: grab;
}

.uvq15-plg.drag .pg {
  cursor: grabbing;
}

.uvq15-plg .bd {
  fill: #e5e7eb;
  stroke: #9ca3af;
  stroke-width: 1.5;
}

.uvq15-plg .gr {
  fill: #6b7280;
}

.uvq15-plg .hl {
  fill: #fff;
  opacity: .7;
}

.uvq15-plg .pr {
  fill: #d4a017;
  stroke: #a16207;
  stroke-width: 1;
}

.uvq15-plg .pl {
  fill: #f1f5f9;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.uvq15-plg .ho {
  fill: #1f2937;
}

.uvq15-plg .led {
  fill: #cbd5e1;
  transition: fill calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.on .led {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-plg .spk line {
  stroke: var(--c2);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0;
}

.uvq15-plg .spk.go line {
  animation: uvq15-plg-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq15-plg-s {
  0% {
    opacity: 1;
    stroke-dasharray: 0 20;
  }
  40% {
    opacity: 1;
    stroke-dasharray: 10 20;
  }
  100% {
    opacity: 0;
    stroke-dasharray: 10 20;
    stroke-dashoffset: -10;
  }
}

.uvq15-plg .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8em;
}

.uvq15-plg .st {
  display: flex;
  align-items: center;
  gap: .45em;
  margin: 0;
  font-size: .85em;
}

.uvq15-plg .st i {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 .2em color-mix(in srgb,#ef4444 20%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.try .st i {
  background: var(--c2);
  animation: uvq15-plg-p calc(0.8s / var(--k)) ease-in-out infinite;
}

@keyframes uvq15-plg-p {
  50% {
    opacity: .3;
  }
}

.uvq15-plg.on .st i {
  background: var(--c1);
  box-shadow: 0 0 0 .2em color-mix(in srgb,var(--c1) 22%,transparent);
}

.uvq15-plg .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .6em 1.1em;
  border-radius: .7em;
  font-size: .9em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform .15s cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg .bt:hover {
  filter: brightness(1.08);
}

.uvq15-plg .bt:active {
  transform: scale(.96);
}

.uvq15-plg .bt:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-plg.on .bt {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const sc=el.querySelector(".sc"),pg=el.querySelector(".pg"),cb=el.querySelector(".cb"),spk=el.querySelector(".spk"),st=el.querySelector(".st b"),bt=el.querySelector(".bt"),t0=bt.textContent,X0=70,X1=172;let x=X0,v=0,goal=X0,raf=0,drag=false,gx=0,on=false;
const draw=()=>{pg.setAttribute("transform","translate("+x.toFixed(2)+" 0)");const e=x-6,s=Math.max(0,(X1-x)/(X1-X0));cb.setAttribute("d","M-10 86 C"+(e*.35).toFixed(1)+" "+(86+22*s).toFixed(1)+" "+(e*.6).toFixed(1)+" "+(55+8*s).toFixed(1)+" "+e.toFixed(1)+" 55")};
const plugged=()=>{if(on)return;on=true;el.classList.remove("try");el.classList.add("on");spk.classList.remove("go");void spk.getBoundingClientRect();spk.classList.add("go");st.textContent="Connected";bt.textContent="Disconnect"};
const loose=()=>{if(!on)return;on=false;el.classList.remove("on");st.textContent="Offline";bt.textContent=t0};
const loop=()=>{v=(v+(goal-x)*.09)*.78;x+=v;if(x>X1){x=X1;v=-v*.25}if(Math.abs(goal-x)<.3&&Math.abs(v)<.15){x=goal;raf=0}else raf=requestAnimationFrame(loop);draw();if(x>=X1-.5)plugged();else if(x<X1-6)loose()};
const go=t=>{goal=t;if(rm){x=t;draw();if(t===X1)plugged();else loose();return}if(!raf)raf=requestAnimationFrame(loop)};
const sx=e=>{const r=sc.getBoundingClientRect();return(e.clientX-r.left)/r.width*260};
pg.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;v=0;gx=sx(e)-x;sc.setPointerCapture(e.pointerId);el.classList.add("drag")});
sc.addEventListener("pointermove",e=>{if(!drag)return;x=Math.max(30,Math.min(X1,sx(e)-gx));draw();if(x>=X1-.5)plugged();else loose()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(x>=X1-30){el.classList.add("try");st.textContent="Connecting…"}go(x>=X1-30?X1:X0)};sc.addEventListener("pointerup",up);sc.addEventListener("pointercancel",up);
bt.addEventListener("click",()=>{if(on){v=-6;go(X0);return}el.classList.add("try");st.textContent="Connecting…";go(X1)});draw();return()=>cancelAnimationFrame(raf)
}

export default function Mi27PlugRetry() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#16a34a",
          "--c2": "#f59e0b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-plg"><svg className="sc" viewBox="0 0 260 110" aria-hidden="true"><path className="cb" d="M-10 86 C24 108 42 55 64 55" /><g className="pg" transform="translate(70 0)"><rect className="pr" x="30" y="44" width="14" height="5" rx="1.5" /><rect className="pr" x="30" y="61" width="14" height="5" rx="1.5" /><rect className="gr" x="-8" y="47" width="12" height="16" rx="3" /><rect className="bd" x="0" y="38" width="34" height="34" rx="8" /><rect className="hl" x="5" y="42" width="5" height="26" rx="2.5" /></g><rect className="pl" x="206" y="18" width="46" height="74" rx="9" /><rect className="ho" x="214" y="44" width="7" height="5" rx="1.5" /><rect className="ho" x="214" y="61" width="7" height="5" rx="1.5" /><circle className="led" cx="238" cy="30" r="3.2" /><g className="spk"><line x1="201.1" y1="51.0" x2="192.4" y2="46.0" /><line x1="208.0" y1="47.0" x2="208.0" y2="37.0" /><line x1="214.9" y1="51.0" x2="223.6" y2="46.0" /><line x1="214.9" y1="59.0" x2="223.6" y2="64.0" /><line x1="208.0" y1="63.0" x2="208.0" y2="73.0" /><line x1="201.1" y1="59.0" x2="192.4" y2="64.0" /></g></svg><div className="ft"><p className="st" aria-live="polite"><i></i><b>Offline</b></p><button type="button" className="bt">Retry</button></div></div>
      </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 “Retry by plugging in the cable” block (Microinteractions) from AIMRAN Library to my project.

## What it is
The plug hangs loose; retry or drag it and it springs into the socket, a spark flies and the light turns on.

## Chosen settings
- Main color: #16a34a
- Secondary color: #f59e0b
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Reintentar"

## 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
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq15-plg {
  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;
  border-radius: 1.3em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent),0 1.4em 2.6em -1.8em rgba(0,0,0,.35);
  display: grid;
  gap: .8em;
  width: 18em;
  padding: 1em;
}

.uvq15-plg .sc {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: .8em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  touch-action: none;
}

.uvq15-plg .cb {
  fill: none;
  stroke: color-mix(in srgb,var(--fg) 70%,transparent);
  stroke-width: 5;
  stroke-linecap: round;
}

.uvq15-plg .pg {
  cursor: grab;
}

.uvq15-plg.drag .pg {
  cursor: grabbing;
}

.uvq15-plg .bd {
  fill: #e5e7eb;
  stroke: #9ca3af;
  stroke-width: 1.5;
}

.uvq15-plg .gr {
  fill: #6b7280;
}

.uvq15-plg .hl {
  fill: #fff;
  opacity: .7;
}

.uvq15-plg .pr {
  fill: #d4a017;
  stroke: #a16207;
  stroke-width: 1;
}

.uvq15-plg .pl {
  fill: #f1f5f9;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.uvq15-plg .ho {
  fill: #1f2937;
}

.uvq15-plg .led {
  fill: #cbd5e1;
  transition: fill calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.on .led {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-plg .spk line {
  stroke: var(--c2);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0;
}

.uvq15-plg .spk.go line {
  animation: uvq15-plg-s calc(0.45s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

@keyframes uvq15-plg-s {
  0% {
    opacity: 1;
    stroke-dasharray: 0 20;
  }
  40% {
    opacity: 1;
    stroke-dasharray: 10 20;
  }
  100% {
    opacity: 0;
    stroke-dasharray: 10 20;
    stroke-dashoffset: -10;
  }
}

.uvq15-plg .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8em;
}

.uvq15-plg .st {
  display: flex;
  align-items: center;
  gap: .45em;
  margin: 0;
  font-size: .85em;
}

.uvq15-plg .st i {
  width: .6em;
  height: .6em;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 .2em color-mix(in srgb,#ef4444 20%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg.try .st i {
  background: var(--c2);
  animation: uvq15-plg-p calc(0.8s / var(--k)) ease-in-out infinite;
}

@keyframes uvq15-plg-p {
  50% {
    opacity: .3;
  }
}

.uvq15-plg.on .st i {
  background: var(--c1);
  box-shadow: 0 0 0 .2em color-mix(in srgb,var(--c1) 22%,transparent);
}

.uvq15-plg .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .6em 1.1em;
  border-radius: .7em;
  font-size: .9em;
  font-weight: 700;
  color: #fff;
  background: var(--c1);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform .15s cubic-bezier(.25,.1,.25,1);
}

.uvq15-plg .bt:hover {
  filter: brightness(1.08);
}

.uvq15-plg .bt:active {
  transform: scale(.96);
}

.uvq15-plg .bt:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq15-plg.on .bt {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

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

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const sc=el.querySelector(".sc"),pg=el.querySelector(".pg"),cb=el.querySelector(".cb"),spk=el.querySelector(".spk"),st=el.querySelector(".st b"),bt=el.querySelector(".bt"),t0=bt.textContent,X0=70,X1=172;let x=X0,v=0,goal=X0,raf=0,drag=false,gx=0,on=false;
const draw=()=>{pg.setAttribute("transform","translate("+x.toFixed(2)+" 0)");const e=x-6,s=Math.max(0,(X1-x)/(X1-X0));cb.setAttribute("d","M-10 86 C"+(e*.35).toFixed(1)+" "+(86+22*s).toFixed(1)+" "+(e*.6).toFixed(1)+" "+(55+8*s).toFixed(1)+" "+e.toFixed(1)+" 55")};
const plugged=()=>{if(on)return;on=true;el.classList.remove("try");el.classList.add("on");spk.classList.remove("go");void spk.getBoundingClientRect();spk.classList.add("go");st.textContent="Connected";bt.textContent="Disconnect"};
const loose=()=>{if(!on)return;on=false;el.classList.remove("on");st.textContent="Offline";bt.textContent=t0};
const loop=()=>{v=(v+(goal-x)*.09)*.78;x+=v;if(x>X1){x=X1;v=-v*.25}if(Math.abs(goal-x)<.3&&Math.abs(v)<.15){x=goal;raf=0}else raf=requestAnimationFrame(loop);draw();if(x>=X1-.5)plugged();else if(x<X1-6)loose()};
const go=t=>{goal=t;if(rm){x=t;draw();if(t===X1)plugged();else loose();return}if(!raf)raf=requestAnimationFrame(loop)};
const sx=e=>{const r=sc.getBoundingClientRect();return(e.clientX-r.left)/r.width*260};
pg.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;v=0;gx=sx(e)-x;sc.setPointerCapture(e.pointerId);el.classList.add("drag")});
sc.addEventListener("pointermove",e=>{if(!drag)return;x=Math.max(30,Math.min(X1,sx(e)-gx));draw();if(x>=X1-.5)plugged();else loose()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(x>=X1-30){el.classList.add("try");st.textContent="Connecting…"}go(x>=X1-30?X1:X0)};sc.addEventListener("pointerup",up);sc.addEventListener("pointercancel",up);
bt.addEventListener("click",()=>{if(on){v=-6;go(X0);return}el.classList.add("try");st.textContent="Connecting…";go(X1)});draw();return()=>cancelAnimationFrame(raf)
}

export default function Mi27PlugRetry() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#16a34a",
          "--c2": "#f59e0b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-plg"><svg className="sc" viewBox="0 0 260 110" aria-hidden="true"><path className="cb" d="M-10 86 C24 108 42 55 64 55" /><g className="pg" transform="translate(70 0)"><rect className="pr" x="30" y="44" width="14" height="5" rx="1.5" /><rect className="pr" x="30" y="61" width="14" height="5" rx="1.5" /><rect className="gr" x="-8" y="47" width="12" height="16" rx="3" /><rect className="bd" x="0" y="38" width="34" height="34" rx="8" /><rect className="hl" x="5" y="42" width="5" height="26" rx="2.5" /></g><rect className="pl" x="206" y="18" width="46" height="74" rx="9" /><rect className="ho" x="214" y="44" width="7" height="5" rx="1.5" /><rect className="ho" x="214" y="61" width="7" height="5" rx="1.5" /><circle className="led" cx="238" cy="30" r="3.2" /><g className="spk"><line x1="201.1" y1="51.0" x2="192.4" y2="46.0" /><line x1="208.0" y1="47.0" x2="208.0" y2="37.0" /><line x1="214.9" y1="51.0" x2="223.6" y2="46.0" /><line x1="214.9" y1="59.0" x2="223.6" y2="64.0" /><line x1="208.0" y1="63.0" x2="208.0" y2="73.0" /><line x1="201.1" y1="59.0" x2="192.4" y2="64.0" /></g></svg><div className="ft"><p className="st" aria-live="polite"><i></i><b>Offline</b></p><button type="button" className="bt">Retry</button></div></div>
      </div>
    </>
  );
}
```

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