# Tape measure with inertia

> Pick your height by dragging a yellow tape measure that keeps gliding with inertia and snaps to the nearest centimeter.

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

## Where to use it

Number pickers for height, weight or quantity are tedious with plus and minus buttons. This one uses a yellow tape measure behind a red marker: drag it, flick it and it keeps gliding with momentum, stretches with resistance past either end and settles exactly on the nearest centimeter. The large readout above updates as the tape moves.

The Inertia slider decides how far a flick carries the tape. Arrow keys move one centimeter, Page Up and Page Down ten, and the mouse wheel scrolls it too. Change the range in the script and the labels in the markup to measure weight or distance instead.

## Code

### HTML

```html
<div class="uvq15-tap"><p class="hd"><span>Your height</span><output class="v"><b>170</b><small>cm</small></output></p><div class="win" role="slider" tabindex="0" aria-label="Your height" aria-valuemin="120" aria-valuemax="220" aria-valuenow="170" aria-valuetext="170 cm"><div class="tp"><span style="left:calc(0 * var(--u))">120</span><span style="left:calc(10 * var(--u))">130</span><span style="left:calc(20 * var(--u))">140</span><span style="left:calc(30 * var(--u))">150</span><span style="left:calc(40 * var(--u))">160</span><span style="left:calc(50 * var(--u))">170</span><span style="left:calc(60 * var(--u))">180</span><span style="left:calc(70 * var(--u))">190</span><span style="left:calc(80 * var(--u))">200</span><span style="left:calc(90 * var(--u))">210</span><span style="left:calc(100 * var(--u))">220</span></div><i class="mk" aria-hidden="true"></i></div><p class="ht">Drag the tape or use the arrow keys</p></div>
```

### CSS

```css
.uvq15-tap {
  --c1: #facc15;
  --c2: #dc2626;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fr: 70;
  /* inercia */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq15-tap {
  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;
  gap: .7em;
  width: 19em;
  --u: calc(var(--s,16px) * .55);
}

.uvq15-tap .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-weight: 700;
}

.uvq15-tap .v b {
  font-size: 2.4em;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.uvq15-tap .v small {
  margin-left: .2em;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-tap .win {
  position: relative;
  height: 4.4em;
  border-radius: .7em;
  overflow: hidden;
  background: #27272a;
  box-shadow: inset 0 .3em .6em rgba(0,0,0,.5),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: 0;
  -webkit-mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
  mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
}

.uvq15-tap.drag .win {
  cursor: grabbing;
}

.uvq15-tap .win:focus-visible {
  box-shadow: inset 0 0 0 3px var(--c2);
}

.uvq15-tap:has(.win:focus-visible) .hd b {
  color: var(--c2);
}

.uvq15-tap .tp {
  position: absolute;
  left: calc(50% - 50 * var(--u));
  top: .5em;
  bottom: .5em;
  width: calc(100 * var(--u) + 1px);
  border-radius: .2em;
  background: linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/var(--u) 26% repeat-x,linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/calc(5 * var(--u)) 42% repeat-x,linear-gradient(90deg,#1c1917 1.5px,transparent 0) 0 0/calc(10 * var(--u)) 60% repeat-x,linear-gradient(transparent 70%,rgba(0,0,0,.12)),var(--c1);
  box-shadow: 0 0 0 1em var(--c1),inset 0 1px 0 rgba(255,255,255,.4);
  will-change: transform;
}

.uvq15-tap .tp span {
  position: absolute;
  bottom: .15em;
  translate: -50% 0;
  font: 800 .7em ui-monospace,"SF Mono",Menlo,monospace;
  color: #1c1917;
}

.uvq15-tap .mk {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--c2);
  box-shadow: 0 0 .5em var(--c2);
}

.uvq15-tap .mk::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  border: .4em solid transparent;
  border-top-color: var(--c2);
  translate: -50% 0;
}

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

### JavaScript

```js
document.querySelectorAll(".uvq15-tap").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1,rm=matchMedia("(prefers-reduced-motion:reduce)").matches;const win=el.querySelector(".win"),tp=el.querySelector(".tp"),vb=el.querySelector(".v b"),MIN=120,MAX=220;let v=170,vel=0,raf=0,drag=false,sx=0,sv=0,lx=0,lt=0,last=170,goal=null,fr=.94;
const U=()=>(tp.offsetWidth-1)/100,cl=x=>Math.max(MIN,Math.min(MAX,x));
const draw=()=>{tp.style.transform="translateX("+((170-v)*U())+"px)";const r=Math.round(cl(v));if(r!==last){last=r;vb.textContent=String(r);win.setAttribute("aria-valuenow",String(r));win.setAttribute("aria-valuetext",r+" cm")}};
const loop=()=>{if(Math.abs(vel)>.01&&goal===null){vel*=fr;v+=vel;if(v<MIN||v>MAX){v+=(cl(v)-v)*.25;vel*=.6}}else{vel=0;const t=goal===null?Math.round(cl(v)):goal;v+=(t-v)*(rm?1:.2);if(Math.abs(t-v)<.01){v=t;goal=null;draw();raf=0;return}}draw();raf=requestAnimationFrame(loop)};
const go=()=>{const f=parseFloat(getComputedStyle(el).getPropertyValue("--fr"));fr=.82+(isNaN(f)?70:f)/100*.15;if(!raf)raf=requestAnimationFrame(loop)};
win.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;goal=null;sx=lx=e.clientX;lt=performance.now();sv=v;vel=0;win.setPointerCapture(e.pointerId);el.classList.add("drag")});
win.addEventListener("pointermove",e=>{if(!drag)return;const sc=win.getBoundingClientRect().width/win.offsetWidth||1,u=U()*sc;let nv=sv-(e.clientX-sx)/u;if(nv<MIN)nv=MIN-(MIN-nv)*.3;if(nv>MAX)nv=MAX+(nv-MAX)*.3;const t=performance.now();vel=vel*.6-(e.clientX-lx)/u*(16/Math.max(8,t-lt))*.4;lx=e.clientX;lt=t;v=nv;draw()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(rm||performance.now()-lt>80)vel=0;go()};win.addEventListener("pointerup",up);win.addEventListener("pointercancel",up);
win.addEventListener("keydown",e=>{const m={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:10,PageDown:-10}[e.key];let t=null;if(m)t=Math.round(cl(goal===null?v:goal))+m;else if(e.key==="Home")t=MIN;else if(e.key==="End")t=MAX;if(t===null)return;e.preventDefault();goal=cl(t);vel=0;go()});
const wh=e=>{e.preventDefault();goal=null;vel+=(e.deltaX||e.deltaY)/60;go()};win.addEventListener("wheel",wh,{passive:false});
draw();return()=>{cancelAnimationFrame(raf);win.removeEventListener("wheel",wh)}
});
```

### 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-tap {
  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;
  gap: .7em;
  width: 19em;
  --u: calc(var(--s,16px) * .55);
}

.uvq15-tap .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-weight: 700;
}

.uvq15-tap .v b {
  font-size: 2.4em;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.uvq15-tap .v small {
  margin-left: .2em;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-tap .win {
  position: relative;
  height: 4.4em;
  border-radius: .7em;
  overflow: hidden;
  background: #27272a;
  box-shadow: inset 0 .3em .6em rgba(0,0,0,.5),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: 0;
  -webkit-mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
  mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
}

.uvq15-tap.drag .win {
  cursor: grabbing;
}

.uvq15-tap .win:focus-visible {
  box-shadow: inset 0 0 0 3px var(--c2);
}

.uvq15-tap:has(.win:focus-visible) .hd b {
  color: var(--c2);
}

.uvq15-tap .tp {
  position: absolute;
  left: calc(50% - 50 * var(--u));
  top: .5em;
  bottom: .5em;
  width: calc(100 * var(--u) + 1px);
  border-radius: .2em;
  background: linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/var(--u) 26% repeat-x,linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/calc(5 * var(--u)) 42% repeat-x,linear-gradient(90deg,#1c1917 1.5px,transparent 0) 0 0/calc(10 * var(--u)) 60% repeat-x,linear-gradient(transparent 70%,rgba(0,0,0,.12)),var(--c1);
  box-shadow: 0 0 0 1em var(--c1),inset 0 1px 0 rgba(255,255,255,.4);
  will-change: transform;
}

.uvq15-tap .tp span {
  position: absolute;
  bottom: .15em;
  translate: -50% 0;
  font: 800 .7em ui-monospace,"SF Mono",Menlo,monospace;
  color: #1c1917;
}

.uvq15-tap .mk {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--c2);
  box-shadow: 0 0 .5em var(--c2);
}

.uvq15-tap .mk::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  border: .4em solid transparent;
  border-top-color: var(--c2);
  translate: -50% 0;
}

.uvq15-tap .ht {
  margin: 0;
  font-size: .72em;
  text-align: center;
  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 win=el.querySelector(".win"),tp=el.querySelector(".tp"),vb=el.querySelector(".v b"),MIN=120,MAX=220;let v=170,vel=0,raf=0,drag=false,sx=0,sv=0,lx=0,lt=0,last=170,goal=null,fr=.94;
const U=()=>(tp.offsetWidth-1)/100,cl=x=>Math.max(MIN,Math.min(MAX,x));
const draw=()=>{tp.style.transform="translateX("+((170-v)*U())+"px)";const r=Math.round(cl(v));if(r!==last){last=r;vb.textContent=String(r);win.setAttribute("aria-valuenow",String(r));win.setAttribute("aria-valuetext",r+" cm")}};
const loop=()=>{if(Math.abs(vel)>.01&&goal===null){vel*=fr;v+=vel;if(v<MIN||v>MAX){v+=(cl(v)-v)*.25;vel*=.6}}else{vel=0;const t=goal===null?Math.round(cl(v)):goal;v+=(t-v)*(rm?1:.2);if(Math.abs(t-v)<.01){v=t;goal=null;draw();raf=0;return}}draw();raf=requestAnimationFrame(loop)};
const go=()=>{const f=parseFloat(getComputedStyle(el).getPropertyValue("--fr"));fr=.82+(isNaN(f)?70:f)/100*.15;if(!raf)raf=requestAnimationFrame(loop)};
win.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;goal=null;sx=lx=e.clientX;lt=performance.now();sv=v;vel=0;win.setPointerCapture(e.pointerId);el.classList.add("drag")});
win.addEventListener("pointermove",e=>{if(!drag)return;const sc=win.getBoundingClientRect().width/win.offsetWidth||1,u=U()*sc;let nv=sv-(e.clientX-sx)/u;if(nv<MIN)nv=MIN-(MIN-nv)*.3;if(nv>MAX)nv=MAX+(nv-MAX)*.3;const t=performance.now();vel=vel*.6-(e.clientX-lx)/u*(16/Math.max(8,t-lt))*.4;lx=e.clientX;lt=t;v=nv;draw()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(rm||performance.now()-lt>80)vel=0;go()};win.addEventListener("pointerup",up);win.addEventListener("pointercancel",up);
win.addEventListener("keydown",e=>{const m={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:10,PageDown:-10}[e.key];let t=null;if(m)t=Math.round(cl(goal===null?v:goal))+m;else if(e.key==="Home")t=MIN;else if(e.key==="End")t=MAX;if(t===null)return;e.preventDefault();goal=cl(t);vel=0;go()});
const wh=e=>{e.preventDefault();goal=null;vel+=(e.deltaX||e.deltaY)/60;go()};win.addEventListener("wheel",wh,{passive:false});
draw();return()=>{cancelAnimationFrame(raf);win.removeEventListener("wheel",wh)}
}

export default function Mi27TapeScrub() {
  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": "#facc15",
          "--c2": "#dc2626",
          "--s": "16px",
          "--k": "1",
          "--fr": "70",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-tap"><p className="hd"><span>Your height</span><output className="v"><b>170</b><small>cm</small></output></p><div className="win" role="slider" tabIndex={0} aria-label="Your height" aria-valuemin="120" aria-valuemax="220" aria-valuenow="170" aria-valuetext="170 cm"><div className="tp"><span style={{ left: "calc(0 * var(--u))" }}>120</span><span style={{ left: "calc(10 * var(--u))" }}>130</span><span style={{ left: "calc(20 * var(--u))" }}>140</span><span style={{ left: "calc(30 * var(--u))" }}>150</span><span style={{ left: "calc(40 * var(--u))" }}>160</span><span style={{ left: "calc(50 * var(--u))" }}>170</span><span style={{ left: "calc(60 * var(--u))" }}>180</span><span style={{ left: "calc(70 * var(--u))" }}>190</span><span style={{ left: "calc(80 * var(--u))" }}>200</span><span style={{ left: "calc(90 * var(--u))" }}>210</span><span style={{ left: "calc(100 * var(--u))" }}>220</span></div><i className="mk" aria-hidden="true"></i></div><p className="ht">Drag the tape 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 “Tape measure with inertia” block (Microinteractions) from AIMRAN Library to my project.

## What it is
Pick your height by dragging a yellow tape measure that keeps gliding with inertia and snaps to the nearest centimeter.

## Chosen settings
- Main color: #facc15
- Secondary color: #dc2626
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Inertia: 70% (from 0 to 100%)
- Text: "Tu altura"

## 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-tap {
  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;
  gap: .7em;
  width: 19em;
  --u: calc(var(--s,16px) * .55);
}

.uvq15-tap .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-weight: 700;
}

.uvq15-tap .v b {
  font-size: 2.4em;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.uvq15-tap .v small {
  margin-left: .2em;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq15-tap .win {
  position: relative;
  height: 4.4em;
  border-radius: .7em;
  overflow: hidden;
  background: #27272a;
  box-shadow: inset 0 .3em .6em rgba(0,0,0,.5),0 0 0 1px color-mix(in srgb,var(--fg) 10%,transparent);
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: 0;
  -webkit-mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
  mask-image: linear-gradient(90deg,transparent,#000 18%,#000 82%,transparent);
}

.uvq15-tap.drag .win {
  cursor: grabbing;
}

.uvq15-tap .win:focus-visible {
  box-shadow: inset 0 0 0 3px var(--c2);
}

.uvq15-tap:has(.win:focus-visible) .hd b {
  color: var(--c2);
}

.uvq15-tap .tp {
  position: absolute;
  left: calc(50% - 50 * var(--u));
  top: .5em;
  bottom: .5em;
  width: calc(100 * var(--u) + 1px);
  border-radius: .2em;
  background: linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/var(--u) 26% repeat-x,linear-gradient(90deg,#1c1917 1px,transparent 0) 0 0/calc(5 * var(--u)) 42% repeat-x,linear-gradient(90deg,#1c1917 1.5px,transparent 0) 0 0/calc(10 * var(--u)) 60% repeat-x,linear-gradient(transparent 70%,rgba(0,0,0,.12)),var(--c1);
  box-shadow: 0 0 0 1em var(--c1),inset 0 1px 0 rgba(255,255,255,.4);
  will-change: transform;
}

.uvq15-tap .tp span {
  position: absolute;
  bottom: .15em;
  translate: -50% 0;
  font: 800 .7em ui-monospace,"SF Mono",Menlo,monospace;
  color: #1c1917;
}

.uvq15-tap .mk {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--c2);
  box-shadow: 0 0 .5em var(--c2);
}

.uvq15-tap .mk::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  border: .4em solid transparent;
  border-top-color: var(--c2);
  translate: -50% 0;
}

.uvq15-tap .ht {
  margin: 0;
  font-size: .72em;
  text-align: center;
  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 win=el.querySelector(".win"),tp=el.querySelector(".tp"),vb=el.querySelector(".v b"),MIN=120,MAX=220;let v=170,vel=0,raf=0,drag=false,sx=0,sv=0,lx=0,lt=0,last=170,goal=null,fr=.94;
const U=()=>(tp.offsetWidth-1)/100,cl=x=>Math.max(MIN,Math.min(MAX,x));
const draw=()=>{tp.style.transform="translateX("+((170-v)*U())+"px)";const r=Math.round(cl(v));if(r!==last){last=r;vb.textContent=String(r);win.setAttribute("aria-valuenow",String(r));win.setAttribute("aria-valuetext",r+" cm")}};
const loop=()=>{if(Math.abs(vel)>.01&&goal===null){vel*=fr;v+=vel;if(v<MIN||v>MAX){v+=(cl(v)-v)*.25;vel*=.6}}else{vel=0;const t=goal===null?Math.round(cl(v)):goal;v+=(t-v)*(rm?1:.2);if(Math.abs(t-v)<.01){v=t;goal=null;draw();raf=0;return}}draw();raf=requestAnimationFrame(loop)};
const go=()=>{const f=parseFloat(getComputedStyle(el).getPropertyValue("--fr"));fr=.82+(isNaN(f)?70:f)/100*.15;if(!raf)raf=requestAnimationFrame(loop)};
win.addEventListener("pointerdown",e=>{drag=true;cancelAnimationFrame(raf);raf=0;goal=null;sx=lx=e.clientX;lt=performance.now();sv=v;vel=0;win.setPointerCapture(e.pointerId);el.classList.add("drag")});
win.addEventListener("pointermove",e=>{if(!drag)return;const sc=win.getBoundingClientRect().width/win.offsetWidth||1,u=U()*sc;let nv=sv-(e.clientX-sx)/u;if(nv<MIN)nv=MIN-(MIN-nv)*.3;if(nv>MAX)nv=MAX+(nv-MAX)*.3;const t=performance.now();vel=vel*.6-(e.clientX-lx)/u*(16/Math.max(8,t-lt))*.4;lx=e.clientX;lt=t;v=nv;draw()});
const up=()=>{if(!drag)return;drag=false;el.classList.remove("drag");if(rm||performance.now()-lt>80)vel=0;go()};win.addEventListener("pointerup",up);win.addEventListener("pointercancel",up);
win.addEventListener("keydown",e=>{const m={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:10,PageDown:-10}[e.key];let t=null;if(m)t=Math.round(cl(goal===null?v:goal))+m;else if(e.key==="Home")t=MIN;else if(e.key==="End")t=MAX;if(t===null)return;e.preventDefault();goal=cl(t);vel=0;go()});
const wh=e=>{e.preventDefault();goal=null;vel+=(e.deltaX||e.deltaY)/60;go()};win.addEventListener("wheel",wh,{passive:false});
draw();return()=>{cancelAnimationFrame(raf);win.removeEventListener("wheel",wh)}
}

export default function Mi27TapeScrub() {
  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": "#facc15",
          "--c2": "#dc2626",
          "--s": "16px",
          "--k": "1",
          "--fr": "70",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq15-tap"><p className="hd"><span>Your height</span><output className="v"><b>170</b><small>cm</small></output></p><div className="win" role="slider" tabIndex={0} aria-label="Your height" aria-valuemin="120" aria-valuemax="220" aria-valuenow="170" aria-valuetext="170 cm"><div className="tp"><span style={{ left: "calc(0 * var(--u))" }}>120</span><span style={{ left: "calc(10 * var(--u))" }}>130</span><span style={{ left: "calc(20 * var(--u))" }}>140</span><span style={{ left: "calc(30 * var(--u))" }}>150</span><span style={{ left: "calc(40 * var(--u))" }}>160</span><span style={{ left: "calc(50 * var(--u))" }}>170</span><span style={{ left: "calc(60 * var(--u))" }}>180</span><span style={{ left: "calc(70 * var(--u))" }}>190</span><span style={{ left: "calc(80 * var(--u))" }}>200</span><span style={{ left: "calc(90 * var(--u))" }}>210</span><span style={{ left: "calc(100 * var(--u))" }}>220</span></div><i className="mk" aria-hidden="true"></i></div><p className="ht">Drag the tape 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.
````
