# Tape measure progress bar

> A yellow tape measure stretches out as progress grows and, when it reaches the end, snaps back into its case.

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

## Where to use it

A real progress bar with role progressbar and a live value, shown as a tape measure: a yellow case with a rubber rim and a small display, and a metal blade with millimetre and centimetre ticks and a hook at the tip. When it reaches one hundred the tape snaps back with a springy jolt. It suits DIY shops, renovation and quote tools.

The main color sets the case and the blade, the second the rubber rim and the lock button. Replace the demo script with your real progress by setting the value, and keep the reading in the case as the percentage.

## Code

### HTML

```html
<div class="uvq10-tap" role="progressbar" aria-label="Loading" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="tr" aria-hidden="true"><div class="tp"><span style="--i:1">10</span><span style="--i:2">20</span><span style="--i:3">30</span><span style="--i:4">40</span><span style="--i:5">50</span><span style="--i:6">60</span><span style="--i:7">70</span><span style="--i:8">80</span><span style="--i:9">90</span><span style="--i:10">100</span><i class="hk"></i></div></div><div class="cs" aria-hidden="true"><i class="bt"></i><span class="rd"><b>0</b> cm</span></div></div>
```

### CSS

```css
.uvq10-tap {
  --c1: #ffcc00;
  --c2: #1f2023;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq10-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;
  position: relative;
  width: 15em;
  height: 4.4em;
}

.uvq10-tap .tr {
  position: absolute;
  left: 3.3em;
  top: 2.1em;
  width: 11.6em;
  height: 1.7em;
  overflow: hidden;
}

.uvq10-tap .tp {
  position: absolute;
  right: 100%;
  top: .3em;
  width: 11em;
  height: 1.1em;
  transform: translateX(calc(var(--p,0) * .11em));
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.3,.7,.4,1);
  background: repeating-linear-gradient(to left,#1a1a1a 0 1px,transparent 1px .22em) right top/100% .22em no-repeat,repeating-linear-gradient(to left,#1a1a1a 0 1.5px,transparent 1.5px 1.1em) right top/100% .42em no-repeat,linear-gradient(color-mix(in srgb,var(--c1) 80%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 85%,#000));
  box-shadow: 0 .15em .25em rgba(0,0,0,.3);
}

.uvq10-tap.back .tp {
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.5,1.5,.5,1);
}

.uvq10-tap .tp span {
  position: absolute;
  right: calc(var(--i) * 1.1em);
  bottom: .1em;
  transform: translateX(50%);
  font: 800 .5em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #1a1a1a;
}

.uvq10-tap .tp span:nth-child(5n) {
  color: #c1121f;
}

.uvq10-tap .hk {
  position: absolute;
  right: -.16em;
  top: -.2em;
  width: .2em;
  height: 1.5em;
  border-radius: .05em;
  background: linear-gradient(90deg,#4b5563,#d1d5db,#6b7280);
}

.uvq10-tap .cs {
  position: absolute;
  left: 0;
  top: .3em;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3.9em;
  height: 3.9em;
  border-radius: 1.1em 1em 1em 1.5em;
  background: radial-gradient(circle at 46% 44%,color-mix(in srgb,var(--c1) 80%,#fff) 0 .95em,var(--c1) 1em 1.45em,color-mix(in srgb,var(--c1) 80%,#000) 1.6em);
  box-shadow: inset 0 0 0 .32em var(--c2),0 .6em 1em -.5em rgba(0,0,0,.5);
}

.uvq10-tap .bt {
  position: absolute;
  left: 1.5em;
  top: -.28em;
  width: 1em;
  height: .4em;
  border-radius: .2em .2em 0 0;
  background: var(--c2);
}

.uvq10-tap .rd {
  padding: .25em .4em;
  border-radius: .25em;
  background: #16181b;
  color: #e7f5d0;
  font: 700 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.uvq10-tap .rd b {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
}

.uvq10-tap.back .cs {
  animation: uvq10-tap-j calc(0.35s / var(--k)) calc(0.3s / var(--k)) ease-out;
}

@keyframes uvq10-tap-j {
  30% {
    transform: translateX(.18em) rotate(4deg);
  }
  65% {
    transform: translateX(-.06em) rotate(-1.5deg);
  }
}

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

### JavaScript

```js
document.querySelectorAll(".uvq10-tap").forEach(el => {
  const k=parseFloat(getComputedStyle(el).getPropertyValue('--k'))||1;
const rd=el.querySelector('.rd b');let p=0,t;
const set=()=>{const v=Math.round(p);el.style.setProperty('--p',String(p));rd.textContent=String(v);el.setAttribute('aria-valuenow',String(v));};
const tick=()=>{if(p>=100){el.classList.add('back');p=0;set();t=setTimeout(()=>{el.classList.remove('back');tick();},900/k);return;}p=Math.min(100,p+1+Math.random()*6);set();t=setTimeout(tick,(p>=100?1300:300)/k);};
set();t=setTimeout(tick,500/k);
return()=>clearTimeout(t);
});
```

### 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 = `
.uvq10-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;
  position: relative;
  width: 15em;
  height: 4.4em;
}

.uvq10-tap .tr {
  position: absolute;
  left: 3.3em;
  top: 2.1em;
  width: 11.6em;
  height: 1.7em;
  overflow: hidden;
}

.uvq10-tap .tp {
  position: absolute;
  right: 100%;
  top: .3em;
  width: 11em;
  height: 1.1em;
  transform: translateX(calc(var(--p,0) * .11em));
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.3,.7,.4,1);
  background: repeating-linear-gradient(to left,#1a1a1a 0 1px,transparent 1px .22em) right top/100% .22em no-repeat,repeating-linear-gradient(to left,#1a1a1a 0 1.5px,transparent 1.5px 1.1em) right top/100% .42em no-repeat,linear-gradient(color-mix(in srgb,var(--c1) 80%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 85%,#000));
  box-shadow: 0 .15em .25em rgba(0,0,0,.3);
}

.uvq10-tap.back .tp {
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.5,1.5,.5,1);
}

.uvq10-tap .tp span {
  position: absolute;
  right: calc(var(--i) * 1.1em);
  bottom: .1em;
  transform: translateX(50%);
  font: 800 .5em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #1a1a1a;
}

.uvq10-tap .tp span:nth-child(5n) {
  color: #c1121f;
}

.uvq10-tap .hk {
  position: absolute;
  right: -.16em;
  top: -.2em;
  width: .2em;
  height: 1.5em;
  border-radius: .05em;
  background: linear-gradient(90deg,#4b5563,#d1d5db,#6b7280);
}

.uvq10-tap .cs {
  position: absolute;
  left: 0;
  top: .3em;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3.9em;
  height: 3.9em;
  border-radius: 1.1em 1em 1em 1.5em;
  background: radial-gradient(circle at 46% 44%,color-mix(in srgb,var(--c1) 80%,#fff) 0 .95em,var(--c1) 1em 1.45em,color-mix(in srgb,var(--c1) 80%,#000) 1.6em);
  box-shadow: inset 0 0 0 .32em var(--c2),0 .6em 1em -.5em rgba(0,0,0,.5);
}

.uvq10-tap .bt {
  position: absolute;
  left: 1.5em;
  top: -.28em;
  width: 1em;
  height: .4em;
  border-radius: .2em .2em 0 0;
  background: var(--c2);
}

.uvq10-tap .rd {
  padding: .25em .4em;
  border-radius: .25em;
  background: #16181b;
  color: #e7f5d0;
  font: 700 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.uvq10-tap .rd b {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
}

.uvq10-tap.back .cs {
  animation: uvq10-tap-j calc(0.35s / var(--k)) calc(0.3s / var(--k)) ease-out;
}

@keyframes uvq10-tap-j {
  30% {
    transform: translateX(.18em) rotate(4deg);
  }
  65% {
    transform: translateX(-.06em) rotate(-1.5deg);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq10-tap,.uvq10-tap *,.uvq10-tap *::before,.uvq10-tap *::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;
const rd=el.querySelector('.rd b');let p=0,t;
const set=()=>{const v=Math.round(p);el.style.setProperty('--p',String(p));rd.textContent=String(v);el.setAttribute('aria-valuenow',String(v));};
const tick=()=>{if(p>=100){el.classList.add('back');p=0;set();t=setTimeout(()=>{el.classList.remove('back');tick();},900/k);return;}p=Math.min(100,p+1+Math.random()*6);set();t=setTimeout(tick,(p>=100?1300:300)/k);};
set();t=setTimeout(tick,500/k);
return()=>clearTimeout(t);
}

export default function LdTapeMeasure() {
  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": "#ffcc00",
          "--c2": "#1f2023",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq10-tap" role="progressbar" aria-label="Loading" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div className="tr" aria-hidden="true"><div className="tp"><span style={{ "--i": "1" } as CSSProperties}>10</span><span style={{ "--i": "2" } as CSSProperties}>20</span><span style={{ "--i": "3" } as CSSProperties}>30</span><span style={{ "--i": "4" } as CSSProperties}>40</span><span style={{ "--i": "5" } as CSSProperties}>50</span><span style={{ "--i": "6" } as CSSProperties}>60</span><span style={{ "--i": "7" } as CSSProperties}>70</span><span style={{ "--i": "8" } as CSSProperties}>80</span><span style={{ "--i": "9" } as CSSProperties}>90</span><span style={{ "--i": "10" } as CSSProperties}>100</span><i className="hk"></i></div></div><div className="cs" aria-hidden="true"><i className="bt"></i><span className="rd"><b>0</b> cm</span></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 “Tape measure progress bar” block (Loaders) from AIMRAN Library to my project.

## What it is
A yellow tape measure stretches out as progress grows and, when it reaches the end, snaps back into its case.

## Chosen settings
- Main color: #ffcc00
- Secondary color: #1f2023
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)

## 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 = `
.uvq10-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;
  position: relative;
  width: 15em;
  height: 4.4em;
}

.uvq10-tap .tr {
  position: absolute;
  left: 3.3em;
  top: 2.1em;
  width: 11.6em;
  height: 1.7em;
  overflow: hidden;
}

.uvq10-tap .tp {
  position: absolute;
  right: 100%;
  top: .3em;
  width: 11em;
  height: 1.1em;
  transform: translateX(calc(var(--p,0) * .11em));
  transition: transform calc(0.3s / var(--k)) cubic-bezier(.3,.7,.4,1);
  background: repeating-linear-gradient(to left,#1a1a1a 0 1px,transparent 1px .22em) right top/100% .22em no-repeat,repeating-linear-gradient(to left,#1a1a1a 0 1.5px,transparent 1.5px 1.1em) right top/100% .42em no-repeat,linear-gradient(color-mix(in srgb,var(--c1) 80%,#fff),var(--c1) 40%,color-mix(in srgb,var(--c1) 85%,#000));
  box-shadow: 0 .15em .25em rgba(0,0,0,.3);
}

.uvq10-tap.back .tp {
  transition: transform calc(0.45s / var(--k)) cubic-bezier(.5,1.5,.5,1);
}

.uvq10-tap .tp span {
  position: absolute;
  right: calc(var(--i) * 1.1em);
  bottom: .1em;
  transform: translateX(50%);
  font: 800 .5em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: #1a1a1a;
}

.uvq10-tap .tp span:nth-child(5n) {
  color: #c1121f;
}

.uvq10-tap .hk {
  position: absolute;
  right: -.16em;
  top: -.2em;
  width: .2em;
  height: 1.5em;
  border-radius: .05em;
  background: linear-gradient(90deg,#4b5563,#d1d5db,#6b7280);
}

.uvq10-tap .cs {
  position: absolute;
  left: 0;
  top: .3em;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3.9em;
  height: 3.9em;
  border-radius: 1.1em 1em 1em 1.5em;
  background: radial-gradient(circle at 46% 44%,color-mix(in srgb,var(--c1) 80%,#fff) 0 .95em,var(--c1) 1em 1.45em,color-mix(in srgb,var(--c1) 80%,#000) 1.6em);
  box-shadow: inset 0 0 0 .32em var(--c2),0 .6em 1em -.5em rgba(0,0,0,.5);
}

.uvq10-tap .bt {
  position: absolute;
  left: 1.5em;
  top: -.28em;
  width: 1em;
  height: .4em;
  border-radius: .2em .2em 0 0;
  background: var(--c2);
}

.uvq10-tap .rd {
  padding: .25em .4em;
  border-radius: .25em;
  background: #16181b;
  color: #e7f5d0;
  font: 700 .62em/1 ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.uvq10-tap .rd b {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
}

.uvq10-tap.back .cs {
  animation: uvq10-tap-j calc(0.35s / var(--k)) calc(0.3s / var(--k)) ease-out;
}

@keyframes uvq10-tap-j {
  30% {
    transform: translateX(.18em) rotate(4deg);
  }
  65% {
    transform: translateX(-.06em) rotate(-1.5deg);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq10-tap,.uvq10-tap *,.uvq10-tap *::before,.uvq10-tap *::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;
const rd=el.querySelector('.rd b');let p=0,t;
const set=()=>{const v=Math.round(p);el.style.setProperty('--p',String(p));rd.textContent=String(v);el.setAttribute('aria-valuenow',String(v));};
const tick=()=>{if(p>=100){el.classList.add('back');p=0;set();t=setTimeout(()=>{el.classList.remove('back');tick();},900/k);return;}p=Math.min(100,p+1+Math.random()*6);set();t=setTimeout(tick,(p>=100?1300:300)/k);};
set();t=setTimeout(tick,500/k);
return()=>clearTimeout(t);
}

export default function LdTapeMeasure() {
  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": "#ffcc00",
          "--c2": "#1f2023",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq10-tap" role="progressbar" aria-label="Loading" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div className="tr" aria-hidden="true"><div className="tp"><span style={{ "--i": "1" } as CSSProperties}>10</span><span style={{ "--i": "2" } as CSSProperties}>20</span><span style={{ "--i": "3" } as CSSProperties}>30</span><span style={{ "--i": "4" } as CSSProperties}>40</span><span style={{ "--i": "5" } as CSSProperties}>50</span><span style={{ "--i": "6" } as CSSProperties}>60</span><span style={{ "--i": "7" } as CSSProperties}>70</span><span style={{ "--i": "8" } as CSSProperties}>80</span><span style={{ "--i": "9" } as CSSProperties}>90</span><span style={{ "--i": "10" } as CSSProperties}>100</span><i className="hk"></i></div></div><div className="cs" aria-hidden="true"><i className="bt"></i><span className="rd"><b>0</b> cm</span></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.
````
