# Download button that becomes a ring

> The button shrinks into a progress ring with the percentage, draws a check when it finishes and opens back up as Open.

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

## Where to use it

A download button has three moments worth showing: waiting, progress and done. This one keeps them in the same spot. The pill shrinks into a circle, a ring fills with the percentage in the middle, a check draws itself on green when it reaches the end, and the button widens again into an Open action. Pressing during the download cancels it.

The main color sets the idle and loading state and the secondary one the finished state. The progress here is simulated with requestAnimationFrame; connect it to your real fetch or upload events by updating the ring offset. The file row above is plain HTML.

## Code

### HTML

```html
<div class="uvq15-dlr"><div class="fl"><span class="ic" aria-hidden="true">PDF</span><div><b>informe-anual.pdf</b><small>4,2 MB</small></div></div><button type="button" class="bt" aria-label="Download"><span class="lb a"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5M5 20h14"/></svg><span>Download</span></span><svg class="rg" viewBox="0 0 40 40" aria-hidden="true"><circle class="tr" cx="20" cy="20" r="16"/><circle class="pg" cx="20" cy="20" r="16" pathLength="100"/></svg><span class="pc" aria-hidden="true">0</span><span class="ok" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1"/></svg></span><span class="lb b"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg><span>Open</span></span></button><p class="sr" aria-live="polite"></p></div>
```

### CSS

```css
.uvq15-dlr {
  --c1: #4f46e5;
  --c2: #10b981;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq15-dlr {
  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;
  justify-items: center;
  gap: 1em;
  width: 17em;
  padding: 1.1em;
}

.uvq15-dlr .fl {
  display: flex;
  align-items: center;
  gap: .7em;
  justify-self: stretch;
}

.uvq15-dlr .ic {
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 3.1em;
  border-radius: .4em;
  font-size: .7em;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg,#f87171,#dc2626);
  clip-path: polygon(0 0,72% 0,100% 22%,100% 100%,0 100%);
}

.uvq15-dlr .fl b {
  display: block;
  font-size: .9em;
}

.uvq15-dlr .fl small {
  font-size: .75em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-dlr .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  place-items: center;
  overflow: hidden;
  width: 13em;
  height: 3.2em;
  border-radius: 2em;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .7em 1.4em -.8em var(--c1);
  transition: width calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1),background calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq15-dlr .bt:active {
  transform: scale(.97);
}

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

.uvq15-dlr .bt>* {
  grid-area: 1/1;
}

.uvq15-dlr .lb {
  display: flex;
  align-items: center;
  gap: .45em;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq15-dlr .lb svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq15-dlr .b,.uvq15-dlr .pc,.uvq15-dlr .ok,.uvq15-dlr .rg {
  opacity: 0;
}

.uvq15-dlr .b {
  transform: translateY(.6em);
}

.uvq15-dlr .rg {
  width: 3.2em;
  height: 3.2em;
  transform: rotate(-90deg);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .rg circle {
  fill: none;
  stroke-width: 3;
}

.uvq15-dlr .tr {
  stroke: rgba(255,255,255,.25);
}

.uvq15-dlr .pg {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.uvq15-dlr .pc {
  font-size: .7em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .ok svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.uvq15-dlr.ld .bt,.uvq15-dlr.ok .bt {
  width: 3.2em;
}

.uvq15-dlr.ld .bt {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq15-dlr.ld .a,.uvq15-dlr.ok .a,.uvq15-dlr.op .a {
  opacity: 0;
  transform: scale(.6);
}

.uvq15-dlr.ld .rg,.uvq15-dlr.ld .pc {
  opacity: 1;
  transition-delay: calc(0.25s / var(--k));
}

.uvq15-dlr.ok .bt,.uvq15-dlr.op .bt {
  background: var(--c2);
  box-shadow: 0 .7em 1.4em -.8em var(--c2);
}

.uvq15-dlr.ok .ok {
  opacity: 1;
}

.uvq15-dlr.ok .ok path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq15-dlr.ok .bt {
  animation: uvq15-dlr-p calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

@keyframes uvq15-dlr-p {
  40% {
    transform: scale(1.15);
  }
}

.uvq15-dlr.op .b {
  opacity: 1;
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

.uvq15-dlr .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

### JavaScript

```js
document.querySelectorAll(".uvq15-dlr").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const bt=el.querySelector(".bt"),pg=el.querySelector(".pg"),pc=el.querySelector(".pc"),sr=el.querySelector(".sr"),lbA=bt.getAttribute("aria-label");let p=0,raf=0,tm=0,lt=0;
const mode=m=>{el.classList.remove("ld","ok","op");if(m)el.classList.add(m)};
const stop=()=>{cancelAnimationFrame(raf);clearTimeout(tm)};
const reset=()=>{p=0;pg.style.strokeDashoffset="100";pc.textContent="0";bt.setAttribute("aria-label",lbA)};
const tick=t=>{const dt=lt?t-lt:16;lt=t;p=Math.min(100,p+dt*k*(.015+Math.random()*.06));pg.style.strokeDashoffset=String(100-p);pc.textContent=String(Math.floor(p));
if(p<100){raf=requestAnimationFrame(tick);return}mode("ok");sr.textContent="Download complete";bt.setAttribute("aria-label","Download complete");tm=setTimeout(()=>{mode("op");bt.setAttribute("aria-label","Open")},(rm?100:1000)/k)};
bt.addEventListener("click",()=>{if(el.classList.contains("ok"))return;if(el.classList.contains("ld")){stop();mode("");reset();sr.textContent="Download canceled";return}
if(el.classList.contains("op")){mode("");reset();return}reset();lt=0;mode("ld");bt.setAttribute("aria-label","Cancel download");raf=requestAnimationFrame(tick)});return stop
});
```

### 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-dlr {
  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;
  justify-items: center;
  gap: 1em;
  width: 17em;
  padding: 1.1em;
}

.uvq15-dlr .fl {
  display: flex;
  align-items: center;
  gap: .7em;
  justify-self: stretch;
}

.uvq15-dlr .ic {
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 3.1em;
  border-radius: .4em;
  font-size: .7em;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg,#f87171,#dc2626);
  clip-path: polygon(0 0,72% 0,100% 22%,100% 100%,0 100%);
}

.uvq15-dlr .fl b {
  display: block;
  font-size: .9em;
}

.uvq15-dlr .fl small {
  font-size: .75em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-dlr .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  place-items: center;
  overflow: hidden;
  width: 13em;
  height: 3.2em;
  border-radius: 2em;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .7em 1.4em -.8em var(--c1);
  transition: width calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1),background calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq15-dlr .bt:active {
  transform: scale(.97);
}

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

.uvq15-dlr .bt>* {
  grid-area: 1/1;
}

.uvq15-dlr .lb {
  display: flex;
  align-items: center;
  gap: .45em;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq15-dlr .lb svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq15-dlr .b,.uvq15-dlr .pc,.uvq15-dlr .ok,.uvq15-dlr .rg {
  opacity: 0;
}

.uvq15-dlr .b {
  transform: translateY(.6em);
}

.uvq15-dlr .rg {
  width: 3.2em;
  height: 3.2em;
  transform: rotate(-90deg);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .rg circle {
  fill: none;
  stroke-width: 3;
}

.uvq15-dlr .tr {
  stroke: rgba(255,255,255,.25);
}

.uvq15-dlr .pg {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.uvq15-dlr .pc {
  font-size: .7em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .ok svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.uvq15-dlr.ld .bt,.uvq15-dlr.ok .bt {
  width: 3.2em;
}

.uvq15-dlr.ld .bt {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq15-dlr.ld .a,.uvq15-dlr.ok .a,.uvq15-dlr.op .a {
  opacity: 0;
  transform: scale(.6);
}

.uvq15-dlr.ld .rg,.uvq15-dlr.ld .pc {
  opacity: 1;
  transition-delay: calc(0.25s / var(--k));
}

.uvq15-dlr.ok .bt,.uvq15-dlr.op .bt {
  background: var(--c2);
  box-shadow: 0 .7em 1.4em -.8em var(--c2);
}

.uvq15-dlr.ok .ok {
  opacity: 1;
}

.uvq15-dlr.ok .ok path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq15-dlr.ok .bt {
  animation: uvq15-dlr-p calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

@keyframes uvq15-dlr-p {
  40% {
    transform: scale(1.15);
  }
}

.uvq15-dlr.op .b {
  opacity: 1;
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

.uvq15-dlr .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion:reduce) {
  .uvq15-dlr,.uvq15-dlr *,.uvq15-dlr *::before,.uvq15-dlr *::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 bt=el.querySelector(".bt"),pg=el.querySelector(".pg"),pc=el.querySelector(".pc"),sr=el.querySelector(".sr"),lbA=bt.getAttribute("aria-label");let p=0,raf=0,tm=0,lt=0;
const mode=m=>{el.classList.remove("ld","ok","op");if(m)el.classList.add(m)};
const stop=()=>{cancelAnimationFrame(raf);clearTimeout(tm)};
const reset=()=>{p=0;pg.style.strokeDashoffset="100";pc.textContent="0";bt.setAttribute("aria-label",lbA)};
const tick=t=>{const dt=lt?t-lt:16;lt=t;p=Math.min(100,p+dt*k*(.015+Math.random()*.06));pg.style.strokeDashoffset=String(100-p);pc.textContent=String(Math.floor(p));
if(p<100){raf=requestAnimationFrame(tick);return}mode("ok");sr.textContent="Download complete";bt.setAttribute("aria-label","Download complete");tm=setTimeout(()=>{mode("op");bt.setAttribute("aria-label","Open")},(rm?100:1000)/k)};
bt.addEventListener("click",()=>{if(el.classList.contains("ok"))return;if(el.classList.contains("ld")){stop();mode("");reset();sr.textContent="Download canceled";return}
if(el.classList.contains("op")){mode("");reset();return}reset();lt=0;mode("ld");bt.setAttribute("aria-label","Cancel download");raf=requestAnimationFrame(tick)});return stop
}

export default function Mi27DownloadRing() {
  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": "#4f46e5",
          "--c2": "#10b981",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-dlr"><div className="fl"><span className="ic" aria-hidden="true">PDF</span><div><b>informe-anual.pdf</b><small>4,2 MB</small></div></div><button type="button" className="bt" aria-label="Download"><span className="lb a"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5M5 20h14" /></svg><span>Download</span></span><svg className="rg" viewBox="0 0 40 40" aria-hidden="true"><circle className="tr" cx="20" cy="20" r="16" /><circle className="pg" cx="20" cy="20" r="16" pathLength="100" /></svg><span className="pc" aria-hidden="true">0</span><span className="ok" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1" /></svg></span><span className="lb b"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" /></svg><span>Open</span></span></button><p className="sr" aria-live="polite"></p></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 “Download button that becomes a ring” block (Microinteractions) from AIMRAN Library to my project.

## What it is
The button shrinks into a progress ring with the percentage, draws a check when it finishes and opens back up as Open.

## Chosen settings
- Main color: #4f46e5
- Secondary color: #10b981
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Descargar"

## 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-dlr {
  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;
  justify-items: center;
  gap: 1em;
  width: 17em;
  padding: 1.1em;
}

.uvq15-dlr .fl {
  display: flex;
  align-items: center;
  gap: .7em;
  justify-self: stretch;
}

.uvq15-dlr .ic {
  display: grid;
  place-items: center;
  width: 2.6em;
  height: 3.1em;
  border-radius: .4em;
  font-size: .7em;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg,#f87171,#dc2626);
  clip-path: polygon(0 0,72% 0,100% 22%,100% 100%,0 100%);
}

.uvq15-dlr .fl b {
  display: block;
  font-size: .9em;
}

.uvq15-dlr .fl small {
  font-size: .75em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-dlr .bt {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr);
  place-items: center;
  overflow: hidden;
  width: 13em;
  height: 3.2em;
  border-radius: 2em;
  color: #fff;
  background: var(--c1);
  box-shadow: 0 .7em 1.4em -.8em var(--c1);
  transition: width calc(0.5s / var(--k)) cubic-bezier(.22,1,.36,1),background calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1),box-shadow calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

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

.uvq15-dlr .bt:active {
  transform: scale(.97);
}

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

.uvq15-dlr .bt>* {
  grid-area: 1/1;
}

.uvq15-dlr .lb {
  display: flex;
  align-items: center;
  gap: .45em;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.4s / var(--k)) cubic-bezier(.22,1,.36,1);
}

.uvq15-dlr .lb svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq15-dlr .b,.uvq15-dlr .pc,.uvq15-dlr .ok,.uvq15-dlr .rg {
  opacity: 0;
}

.uvq15-dlr .b {
  transform: translateY(.6em);
}

.uvq15-dlr .rg {
  width: 3.2em;
  height: 3.2em;
  transform: rotate(-90deg);
  transition: opacity calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .rg circle {
  fill: none;
  stroke-width: 3;
}

.uvq15-dlr .tr {
  stroke: rgba(255,255,255,.25);
}

.uvq15-dlr .pg {
  stroke: #fff;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.uvq15-dlr .pc {
  font-size: .7em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-dlr .ok svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.uvq15-dlr.ld .bt,.uvq15-dlr.ok .bt {
  width: 3.2em;
}

.uvq15-dlr.ld .bt {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq15-dlr.ld .a,.uvq15-dlr.ok .a,.uvq15-dlr.op .a {
  opacity: 0;
  transform: scale(.6);
}

.uvq15-dlr.ld .rg,.uvq15-dlr.ld .pc {
  opacity: 1;
  transition-delay: calc(0.25s / var(--k));
}

.uvq15-dlr.ok .bt,.uvq15-dlr.op .bt {
  background: var(--c2);
  box-shadow: 0 .7em 1.4em -.8em var(--c2);
}

.uvq15-dlr.ok .ok {
  opacity: 1;
}

.uvq15-dlr.ok .ok path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset calc(0.4s / var(--k)) cubic-bezier(.25,.1,.25,1) calc(0.2s / var(--k));
}

.uvq15-dlr.ok .bt {
  animation: uvq15-dlr-p calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

@keyframes uvq15-dlr-p {
  40% {
    transform: scale(1.15);
  }
}

.uvq15-dlr.op .b {
  opacity: 1;
  transform: none;
  transition-delay: calc(0.2s / var(--k));
}

.uvq15-dlr .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion:reduce) {
  .uvq15-dlr,.uvq15-dlr *,.uvq15-dlr *::before,.uvq15-dlr *::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 bt=el.querySelector(".bt"),pg=el.querySelector(".pg"),pc=el.querySelector(".pc"),sr=el.querySelector(".sr"),lbA=bt.getAttribute("aria-label");let p=0,raf=0,tm=0,lt=0;
const mode=m=>{el.classList.remove("ld","ok","op");if(m)el.classList.add(m)};
const stop=()=>{cancelAnimationFrame(raf);clearTimeout(tm)};
const reset=()=>{p=0;pg.style.strokeDashoffset="100";pc.textContent="0";bt.setAttribute("aria-label",lbA)};
const tick=t=>{const dt=lt?t-lt:16;lt=t;p=Math.min(100,p+dt*k*(.015+Math.random()*.06));pg.style.strokeDashoffset=String(100-p);pc.textContent=String(Math.floor(p));
if(p<100){raf=requestAnimationFrame(tick);return}mode("ok");sr.textContent="Download complete";bt.setAttribute("aria-label","Download complete");tm=setTimeout(()=>{mode("op");bt.setAttribute("aria-label","Open")},(rm?100:1000)/k)};
bt.addEventListener("click",()=>{if(el.classList.contains("ok"))return;if(el.classList.contains("ld")){stop();mode("");reset();sr.textContent="Download canceled";return}
if(el.classList.contains("op")){mode("");reset();return}reset();lt=0;mode("ld");bt.setAttribute("aria-label","Cancel download");raf=requestAnimationFrame(tick)});return stop
}

export default function Mi27DownloadRing() {
  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": "#4f46e5",
          "--c2": "#10b981",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-dlr"><div className="fl"><span className="ic" aria-hidden="true">PDF</span><div><b>informe-anual.pdf</b><small>4,2 MB</small></div></div><button type="button" className="bt" aria-label="Download"><span className="lb a"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5M5 20h14" /></svg><span>Download</span></span><svg className="rg" viewBox="0 0 40 40" aria-hidden="true"><circle className="tr" cx="20" cy="20" r="16" /><circle className="pg" cx="20" cy="20" r="16" pathLength="100" /></svg><span className="pc" aria-hidden="true">0</span><span className="ok" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1" /></svg></span><span className="lb b"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" /></svg><span>Open</span></span></button><p className="sr" aria-live="polite"></p></div>
      </div>
    </>
  );
}
```

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