# Tachometer needle rating

> Rate from 0 to 10 by dragging a car dashboard needle; it springs past the mark and the zone color changes.

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

## Where to use it

Net Promoter questions are usually a row of eleven small buttons. This block puts the score on a dark car dial instead: drag the red needle or use the arrow keys, and it swings with a spring, overshoots slightly and settles. The readout shows the number and whether it is a detractor, passive or promoter score.

The Bounce slider controls how much the needle overshoots, from a firm stop to a lively wobble. The main color paints the needle and the secondary one the dial face. Use it at the end of a purchase, in feedback emails or in internal surveys.

## Code

### HTML

```html
<div class="uvq15-nps"><p class="q">Would you recommend us to a friend?</p><div class="dl" role="slider" tabindex="0" aria-label="Would you recommend us to a friend?" aria-valuemin="0" aria-valuemax="10" aria-valuenow="7" aria-valuetext="7"><svg viewBox="0 0 200 200" aria-hidden="true"><defs><radialGradient id="uvq15-nps-f" cx="50%" cy="40%" r="65%"><stop offset="0" stop-color="#fff" stop-opacity=".12"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient></defs><circle cx="100" cy="100" r="97" class="bz"/><circle cx="100" cy="100" r="91" class="fc"/><circle cx="100" cy="100" r="91" fill="url(#uvq15-nps-f)"/><path d="M27.25 142.00A84 84 0 0 1 147.07 30.43" stroke="#ef4444" stroke-width="5" fill="none"/><path d="M151.62 33.73A84 84 0 0 1 183.20 88.43" stroke="#f59e0b" stroke-width="5" fill="none"/><path d="M183.79 94.02A84 84 0 0 1 172.75 142.00" stroke="#22c55e" stroke-width="5" fill="none"/><line x1="41.98" y1="133.50" x2="32.45" y2="139.00" class="mj"/><line x1="31.52" y1="122.25" x2="25.82" y2="124.10" class="mn"/><line x1="33.37" y1="107.00" x2="22.43" y2="108.15" class="mj"/><line x1="28.39" y1="92.47" x2="22.43" y2="91.85" class="mn"/><line x1="36.28" y1="79.30" x2="25.82" y2="75.90" class="mj"/><line x1="37.65" y1="64.00" x2="32.45" y2="61.00" class="mn"/><line x1="50.21" y1="55.17" x2="42.03" y2="47.81" class="mj"/><line x1="57.68" y1="41.75" x2="54.15" y2="36.90" class="mn"/><line x1="72.75" y1="38.79" x2="68.27" y2="28.74" class="mj"/><line x1="85.03" y1="29.57" x2="83.78" y2="23.70" class="mn"/><line x1="100.00" y1="33.00" x2="100.00" y2="22.00" class="mj"/><line x1="114.97" y1="29.57" x2="116.22" y2="23.70" class="mn"/><line x1="127.25" y1="38.79" x2="131.73" y2="28.74" class="mj"/><line x1="142.32" y1="41.75" x2="145.85" y2="36.90" class="mn"/><line x1="149.79" y1="55.17" x2="157.97" y2="47.81" class="mj"/><line x1="162.35" y1="64.00" x2="167.55" y2="61.00" class="mn"/><line x1="163.72" y1="79.30" x2="174.18" y2="75.90" class="mj"/><line x1="171.61" y1="92.47" x2="177.57" y2="91.85" class="mn"/><line x1="166.63" y1="107.00" x2="177.57" y2="108.15" class="mj"/><line x1="168.48" y1="122.25" x2="174.18" y2="124.10" class="mn"/><line x1="158.02" y1="133.50" x2="167.55" y2="139.00" class="mj"/><text x="52.37" y="127.50">0</text><text x="45.30" y="105.75">1</text><text x="47.69" y="83.00">2</text><text x="59.13" y="63.20">3</text><text x="77.63" y="49.75">4</text><text x="100.00" y="45.00">5</text><text x="122.37" y="49.75">6</text><text x="140.87" y="63.20">7</text><text x="152.31" y="83.00">8</text><text x="154.70" y="105.75">9</text><text x="147.63" y="127.50">10</text><g class="nd" transform="rotate(48 100 100)"><path d="M96 114 L100 20 L104 114 Z"/><circle cx="100" cy="100" r="9" class="hb"/><circle cx="100" cy="100" r="3" class="hc"/></g></svg><div class="rd"><b>7</b><span>Passive</span></div></div><p class="ht">Drag the needle or use the arrow keys</p></div>
```

### CSS

```css
.uvq15-nps {
  --c1: #ef4444;
  --c2: #18181b;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --bnc: 60;
  /* rebote */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq15-nps {
  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;
  display: grid;
  justify-items: center;
  gap: .6em;
  width: 16em;
  --z: #f59e0b;
}

.uvq15-nps .q {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.uvq15-nps .dl {
  position: relative;
  width: 14em;
  height: 14em;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  outline: 0;
  user-select: none;
}

.uvq15-nps .dl:active {
  cursor: grabbing;
}

.uvq15-nps .dl:focus-visible {
  box-shadow: 0 0 0 3px var(--bg),0 0 0 5px var(--c1);
}

.uvq15-nps svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.uvq15-nps .bz {
  fill: #a1a1aa;
  stroke: #e4e4e7;
  stroke-width: 2;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

.uvq15-nps .fc {
  fill: var(--c2);
}

.uvq15-nps .mj {
  stroke: #f4f4f5;
  stroke-width: 2.4;
}

.uvq15-nps .mn {
  stroke: #a1a1aa;
  stroke-width: 1.2;
}

.uvq15-nps text {
  fill: #e4e4e7;
  font: 700 12px ui-monospace,"SF Mono",Menlo,monospace;
  text-anchor: middle;
  dominant-baseline: central;
}

.uvq15-nps .nd path {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-nps .hb {
  fill: #3f3f46;
  stroke: #71717a;
  stroke-width: 1.5;
}

.uvq15-nps .hc {
  fill: var(--c1);
}

.uvq15-nps .rd {
  position: absolute;
  left: 50%;
  top: 62%;
  display: grid;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}

.uvq15-nps .rd b {
  font: 800 2.1em/1 ui-monospace,"SF Mono",Menlo,monospace;
  color: var(--z);
  text-shadow: 0 0 .4em var(--z);
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-nps .rd span {
  margin-top: .25em;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #d4d4d8;
}

.uvq15-nps .ht {
  margin: 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}
```

### JavaScript

```js
document.querySelectorAll(".uvq15-nps").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const dl=el.querySelector(".dl"),nd=el.querySelector(".nd"),num=el.querySelector(".rd b"),lab=el.querySelector(".rd span");const L=["Detractor","Passive","Promoter"],C=["#ef4444","#f59e0b","#22c55e"];
let v=7,a=48,va=0,raf=0,on=false,damp=.76;
const draw=()=>nd.setAttribute("transform","rotate("+a.toFixed(2)+" 100 100)");
const loop=()=>{const t=-120+v*24;va=(va+(t-a)*.16)*damp;a+=va;if(Math.abs(t-a)<.05&&Math.abs(va)<.05){a=t;raf=0}else raf=requestAnimationFrame(loop);draw()};
const set=x=>{x=Math.max(0,Math.min(10,Math.round(x)));if(x!==v){v=x;const z=v<=6?0:v<=8?1:2;num.textContent=String(v);lab.textContent=L[z];el.style.setProperty("--z",C[z]);dl.setAttribute("aria-valuenow",String(v));dl.setAttribute("aria-valuetext",v+" · "+L[z])}
if(rm){a=-120+v*24;draw();return}const b=parseFloat(getComputedStyle(el).getPropertyValue("--bnc"));damp=.55+(isNaN(b)?60:b)/100*.37;if(!raf)raf=requestAnimationFrame(loop)};
const at=e=>{const r=dl.getBoundingClientRect(),x=e.clientX-r.left-r.width/2,y=e.clientY-r.top-r.height/2;let g=Math.atan2(x,-y)*180/Math.PI;if(g>150)g=-120;else if(g<-150)g=120;set((Math.max(-120,Math.min(120,g))+120)/24)};
dl.addEventListener("pointerdown",e=>{on=true;dl.setPointerCapture(e.pointerId);at(e)});
dl.addEventListener("pointermove",e=>{if(on)at(e)});
const up=()=>{on=false};dl.addEventListener("pointerup",up);dl.addEventListener("pointercancel",up);
dl.addEventListener("keydown",e=>{const m={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1}[e.key];if(m){e.preventDefault();set(v+m)}else if(e.key==="Home"){e.preventDefault();set(0)}else if(e.key==="End"){e.preventDefault();set(10)}});
dl.setAttribute("aria-valuetext","7 · "+L[1]);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-nps {
  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;
  display: grid;
  justify-items: center;
  gap: .6em;
  width: 16em;
  --z: #f59e0b;
}

.uvq15-nps .q {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.uvq15-nps .dl {
  position: relative;
  width: 14em;
  height: 14em;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  outline: 0;
  user-select: none;
}

.uvq15-nps .dl:active {
  cursor: grabbing;
}

.uvq15-nps .dl:focus-visible {
  box-shadow: 0 0 0 3px var(--bg),0 0 0 5px var(--c1);
}

.uvq15-nps svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.uvq15-nps .bz {
  fill: #a1a1aa;
  stroke: #e4e4e7;
  stroke-width: 2;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

.uvq15-nps .fc {
  fill: var(--c2);
}

.uvq15-nps .mj {
  stroke: #f4f4f5;
  stroke-width: 2.4;
}

.uvq15-nps .mn {
  stroke: #a1a1aa;
  stroke-width: 1.2;
}

.uvq15-nps text {
  fill: #e4e4e7;
  font: 700 12px ui-monospace,"SF Mono",Menlo,monospace;
  text-anchor: middle;
  dominant-baseline: central;
}

.uvq15-nps .nd path {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-nps .hb {
  fill: #3f3f46;
  stroke: #71717a;
  stroke-width: 1.5;
}

.uvq15-nps .hc {
  fill: var(--c1);
}

.uvq15-nps .rd {
  position: absolute;
  left: 50%;
  top: 62%;
  display: grid;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}

.uvq15-nps .rd b {
  font: 800 2.1em/1 ui-monospace,"SF Mono",Menlo,monospace;
  color: var(--z);
  text-shadow: 0 0 .4em var(--z);
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-nps .rd span {
  margin-top: .25em;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #d4d4d8;
}

.uvq15-nps .ht {
  margin: 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}
`;

// 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 dl=el.querySelector(".dl"),nd=el.querySelector(".nd"),num=el.querySelector(".rd b"),lab=el.querySelector(".rd span");const L=["Detractor","Passive","Promoter"],C=["#ef4444","#f59e0b","#22c55e"];
let v=7,a=48,va=0,raf=0,on=false,damp=.76;
const draw=()=>nd.setAttribute("transform","rotate("+a.toFixed(2)+" 100 100)");
const loop=()=>{const t=-120+v*24;va=(va+(t-a)*.16)*damp;a+=va;if(Math.abs(t-a)<.05&&Math.abs(va)<.05){a=t;raf=0}else raf=requestAnimationFrame(loop);draw()};
const set=x=>{x=Math.max(0,Math.min(10,Math.round(x)));if(x!==v){v=x;const z=v<=6?0:v<=8?1:2;num.textContent=String(v);lab.textContent=L[z];el.style.setProperty("--z",C[z]);dl.setAttribute("aria-valuenow",String(v));dl.setAttribute("aria-valuetext",v+" · "+L[z])}
if(rm){a=-120+v*24;draw();return}const b=parseFloat(getComputedStyle(el).getPropertyValue("--bnc"));damp=.55+(isNaN(b)?60:b)/100*.37;if(!raf)raf=requestAnimationFrame(loop)};
const at=e=>{const r=dl.getBoundingClientRect(),x=e.clientX-r.left-r.width/2,y=e.clientY-r.top-r.height/2;let g=Math.atan2(x,-y)*180/Math.PI;if(g>150)g=-120;else if(g<-150)g=120;set((Math.max(-120,Math.min(120,g))+120)/24)};
dl.addEventListener("pointerdown",e=>{on=true;dl.setPointerCapture(e.pointerId);at(e)});
dl.addEventListener("pointermove",e=>{if(on)at(e)});
const up=()=>{on=false};dl.addEventListener("pointerup",up);dl.addEventListener("pointercancel",up);
dl.addEventListener("keydown",e=>{const m={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1}[e.key];if(m){e.preventDefault();set(v+m)}else if(e.key==="Home"){e.preventDefault();set(0)}else if(e.key==="End"){e.preventDefault();set(10)}});
dl.setAttribute("aria-valuetext","7 · "+L[1]);return()=>cancelAnimationFrame(raf)
}

export default function Mi27NpsGauge() {
  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": "#ef4444",
          "--c2": "#18181b",
          "--s": "16px",
          "--k": "1",
          "--bnc": "60",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-nps"><p className="q">Would you recommend us to a friend?</p><div className="dl" role="slider" tabIndex={0} aria-label="Would you recommend us to a friend?" aria-valuemin="0" aria-valuemax="10" aria-valuenow="7" aria-valuetext="7"><svg viewBox="0 0 200 200" aria-hidden="true"><defs><radialGradient id="uvq15-nps-f" cx="50%" cy="40%" r="65%"><stop offset="0" stopColor="#fff" stopOpacity=".12" /><stop offset="1" stopColor="#fff" stopOpacity="0" /></radialGradient></defs><circle cx="100" cy="100" r="97" className="bz" /><circle cx="100" cy="100" r="91" className="fc" /><circle cx="100" cy="100" r="91" fill="url(#uvq15-nps-f)" /><path d="M27.25 142.00A84 84 0 0 1 147.07 30.43" stroke="#ef4444" strokeWidth="5" fill="none" /><path d="M151.62 33.73A84 84 0 0 1 183.20 88.43" stroke="#f59e0b" strokeWidth="5" fill="none" /><path d="M183.79 94.02A84 84 0 0 1 172.75 142.00" stroke="#22c55e" strokeWidth="5" fill="none" /><line x1="41.98" y1="133.50" x2="32.45" y2="139.00" className="mj" /><line x1="31.52" y1="122.25" x2="25.82" y2="124.10" className="mn" /><line x1="33.37" y1="107.00" x2="22.43" y2="108.15" className="mj" /><line x1="28.39" y1="92.47" x2="22.43" y2="91.85" className="mn" /><line x1="36.28" y1="79.30" x2="25.82" y2="75.90" className="mj" /><line x1="37.65" y1="64.00" x2="32.45" y2="61.00" className="mn" /><line x1="50.21" y1="55.17" x2="42.03" y2="47.81" className="mj" /><line x1="57.68" y1="41.75" x2="54.15" y2="36.90" className="mn" /><line x1="72.75" y1="38.79" x2="68.27" y2="28.74" className="mj" /><line x1="85.03" y1="29.57" x2="83.78" y2="23.70" className="mn" /><line x1="100.00" y1="33.00" x2="100.00" y2="22.00" className="mj" /><line x1="114.97" y1="29.57" x2="116.22" y2="23.70" className="mn" /><line x1="127.25" y1="38.79" x2="131.73" y2="28.74" className="mj" /><line x1="142.32" y1="41.75" x2="145.85" y2="36.90" className="mn" /><line x1="149.79" y1="55.17" x2="157.97" y2="47.81" className="mj" /><line x1="162.35" y1="64.00" x2="167.55" y2="61.00" className="mn" /><line x1="163.72" y1="79.30" x2="174.18" y2="75.90" className="mj" /><line x1="171.61" y1="92.47" x2="177.57" y2="91.85" className="mn" /><line x1="166.63" y1="107.00" x2="177.57" y2="108.15" className="mj" /><line x1="168.48" y1="122.25" x2="174.18" y2="124.10" className="mn" /><line x1="158.02" y1="133.50" x2="167.55" y2="139.00" className="mj" /><text x="52.37" y="127.50">0</text><text x="45.30" y="105.75">1</text><text x="47.69" y="83.00">2</text><text x="59.13" y="63.20">3</text><text x="77.63" y="49.75">4</text><text x="100.00" y="45.00">5</text><text x="122.37" y="49.75">6</text><text x="140.87" y="63.20">7</text><text x="152.31" y="83.00">8</text><text x="154.70" y="105.75">9</text><text x="147.63" y="127.50">10</text><g className="nd" transform="rotate(48 100 100)"><path d="M96 114 L100 20 L104 114 Z" /><circle cx="100" cy="100" r="9" className="hb" /><circle cx="100" cy="100" r="3" className="hc" /></g></svg><div className="rd"><b>7</b><span>Passive</span></div></div><p className="ht">Drag the needle or use the arrow keys</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 “Tachometer needle rating” block (Microinteractions) from AIMRAN Library to my project.

## What it is
Rate from 0 to 10 by dragging a car dashboard needle; it springs past the mark and the zone color changes.

## Chosen settings
- Main color: #ef4444
- Secondary color: #18181b
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Bounce: 60% (from 0 to 100%)
- Text: "¿Nos recomendarías a un amigo?"

## 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-nps {
  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;
  display: grid;
  justify-items: center;
  gap: .6em;
  width: 16em;
  --z: #f59e0b;
}

.uvq15-nps .q {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.uvq15-nps .dl {
  position: relative;
  width: 14em;
  height: 14em;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  outline: 0;
  user-select: none;
}

.uvq15-nps .dl:active {
  cursor: grabbing;
}

.uvq15-nps .dl:focus-visible {
  box-shadow: 0 0 0 3px var(--bg),0 0 0 5px var(--c1);
}

.uvq15-nps svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.uvq15-nps .bz {
  fill: #a1a1aa;
  stroke: #e4e4e7;
  stroke-width: 2;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

.uvq15-nps .fc {
  fill: var(--c2);
}

.uvq15-nps .mj {
  stroke: #f4f4f5;
  stroke-width: 2.4;
}

.uvq15-nps .mn {
  stroke: #a1a1aa;
  stroke-width: 1.2;
}

.uvq15-nps text {
  fill: #e4e4e7;
  font: 700 12px ui-monospace,"SF Mono",Menlo,monospace;
  text-anchor: middle;
  dominant-baseline: central;
}

.uvq15-nps .nd path {
  fill: var(--c1);
  filter: drop-shadow(0 0 3px var(--c1));
}

.uvq15-nps .hb {
  fill: #3f3f46;
  stroke: #71717a;
  stroke-width: 1.5;
}

.uvq15-nps .hc {
  fill: var(--c1);
}

.uvq15-nps .rd {
  position: absolute;
  left: 50%;
  top: 62%;
  display: grid;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}

.uvq15-nps .rd b {
  font: 800 2.1em/1 ui-monospace,"SF Mono",Menlo,monospace;
  color: var(--z);
  text-shadow: 0 0 .4em var(--z);
  transition: color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq15-nps .rd span {
  margin-top: .25em;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #d4d4d8;
}

.uvq15-nps .ht {
  margin: 0;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}
`;

// 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 dl=el.querySelector(".dl"),nd=el.querySelector(".nd"),num=el.querySelector(".rd b"),lab=el.querySelector(".rd span");const L=["Detractor","Passive","Promoter"],C=["#ef4444","#f59e0b","#22c55e"];
let v=7,a=48,va=0,raf=0,on=false,damp=.76;
const draw=()=>nd.setAttribute("transform","rotate("+a.toFixed(2)+" 100 100)");
const loop=()=>{const t=-120+v*24;va=(va+(t-a)*.16)*damp;a+=va;if(Math.abs(t-a)<.05&&Math.abs(va)<.05){a=t;raf=0}else raf=requestAnimationFrame(loop);draw()};
const set=x=>{x=Math.max(0,Math.min(10,Math.round(x)));if(x!==v){v=x;const z=v<=6?0:v<=8?1:2;num.textContent=String(v);lab.textContent=L[z];el.style.setProperty("--z",C[z]);dl.setAttribute("aria-valuenow",String(v));dl.setAttribute("aria-valuetext",v+" · "+L[z])}
if(rm){a=-120+v*24;draw();return}const b=parseFloat(getComputedStyle(el).getPropertyValue("--bnc"));damp=.55+(isNaN(b)?60:b)/100*.37;if(!raf)raf=requestAnimationFrame(loop)};
const at=e=>{const r=dl.getBoundingClientRect(),x=e.clientX-r.left-r.width/2,y=e.clientY-r.top-r.height/2;let g=Math.atan2(x,-y)*180/Math.PI;if(g>150)g=-120;else if(g<-150)g=120;set((Math.max(-120,Math.min(120,g))+120)/24)};
dl.addEventListener("pointerdown",e=>{on=true;dl.setPointerCapture(e.pointerId);at(e)});
dl.addEventListener("pointermove",e=>{if(on)at(e)});
const up=()=>{on=false};dl.addEventListener("pointerup",up);dl.addEventListener("pointercancel",up);
dl.addEventListener("keydown",e=>{const m={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1}[e.key];if(m){e.preventDefault();set(v+m)}else if(e.key==="Home"){e.preventDefault();set(0)}else if(e.key==="End"){e.preventDefault();set(10)}});
dl.setAttribute("aria-valuetext","7 · "+L[1]);return()=>cancelAnimationFrame(raf)
}

export default function Mi27NpsGauge() {
  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": "#ef4444",
          "--c2": "#18181b",
          "--s": "16px",
          "--k": "1",
          "--bnc": "60",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-nps"><p className="q">Would you recommend us to a friend?</p><div className="dl" role="slider" tabIndex={0} aria-label="Would you recommend us to a friend?" aria-valuemin="0" aria-valuemax="10" aria-valuenow="7" aria-valuetext="7"><svg viewBox="0 0 200 200" aria-hidden="true"><defs><radialGradient id="uvq15-nps-f" cx="50%" cy="40%" r="65%"><stop offset="0" stopColor="#fff" stopOpacity=".12" /><stop offset="1" stopColor="#fff" stopOpacity="0" /></radialGradient></defs><circle cx="100" cy="100" r="97" className="bz" /><circle cx="100" cy="100" r="91" className="fc" /><circle cx="100" cy="100" r="91" fill="url(#uvq15-nps-f)" /><path d="M27.25 142.00A84 84 0 0 1 147.07 30.43" stroke="#ef4444" strokeWidth="5" fill="none" /><path d="M151.62 33.73A84 84 0 0 1 183.20 88.43" stroke="#f59e0b" strokeWidth="5" fill="none" /><path d="M183.79 94.02A84 84 0 0 1 172.75 142.00" stroke="#22c55e" strokeWidth="5" fill="none" /><line x1="41.98" y1="133.50" x2="32.45" y2="139.00" className="mj" /><line x1="31.52" y1="122.25" x2="25.82" y2="124.10" className="mn" /><line x1="33.37" y1="107.00" x2="22.43" y2="108.15" className="mj" /><line x1="28.39" y1="92.47" x2="22.43" y2="91.85" className="mn" /><line x1="36.28" y1="79.30" x2="25.82" y2="75.90" className="mj" /><line x1="37.65" y1="64.00" x2="32.45" y2="61.00" className="mn" /><line x1="50.21" y1="55.17" x2="42.03" y2="47.81" className="mj" /><line x1="57.68" y1="41.75" x2="54.15" y2="36.90" className="mn" /><line x1="72.75" y1="38.79" x2="68.27" y2="28.74" className="mj" /><line x1="85.03" y1="29.57" x2="83.78" y2="23.70" className="mn" /><line x1="100.00" y1="33.00" x2="100.00" y2="22.00" className="mj" /><line x1="114.97" y1="29.57" x2="116.22" y2="23.70" className="mn" /><line x1="127.25" y1="38.79" x2="131.73" y2="28.74" className="mj" /><line x1="142.32" y1="41.75" x2="145.85" y2="36.90" className="mn" /><line x1="149.79" y1="55.17" x2="157.97" y2="47.81" className="mj" /><line x1="162.35" y1="64.00" x2="167.55" y2="61.00" className="mn" /><line x1="163.72" y1="79.30" x2="174.18" y2="75.90" className="mj" /><line x1="171.61" y1="92.47" x2="177.57" y2="91.85" className="mn" /><line x1="166.63" y1="107.00" x2="177.57" y2="108.15" className="mj" /><line x1="168.48" y1="122.25" x2="174.18" y2="124.10" className="mn" /><line x1="158.02" y1="133.50" x2="167.55" y2="139.00" className="mj" /><text x="52.37" y="127.50">0</text><text x="45.30" y="105.75">1</text><text x="47.69" y="83.00">2</text><text x="59.13" y="63.20">3</text><text x="77.63" y="49.75">4</text><text x="100.00" y="45.00">5</text><text x="122.37" y="49.75">6</text><text x="140.87" y="63.20">7</text><text x="152.31" y="83.00">8</text><text x="154.70" y="105.75">9</text><text x="147.63" y="127.50">10</text><g className="nd" transform="rotate(48 100 100)"><path d="M96 114 L100 20 L104 114 Z" /><circle cx="100" cy="100" r="9" className="hb" /><circle cx="100" cy="100" r="3" className="hc" /></g></svg><div className="rd"><b>7</b><span>Passive</span></div></div><p className="ht">Drag the needle or use the arrow keys</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.
````
