# Route elevation profile tooltip

> Scrub a route's elevation profile with a finger, the mouse or the arrow keys: the tooltip gives altitude, distance and slope.

- Category: [Tooltips](https://library.aimran.es/components/tooltips)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-tip-elevation-profile
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A hiking card with an SVG elevation profile and a small route map in the corner. Move along the profile and a dashed guide, a dot and a tooltip follow you with the altitude, the kilometer and the slope, colored green, amber or red by steepness, while an orange marker walks the route on the map. The profile is an ARIA slider, so the arrow keys move it too.

The main color draws the line, the area and the route, the second tints the map. Replace the elevation list in data-e and the route points in data-r with your own GPX samples, and numbers will format in the page language.

## Code

### HTML

```html
<div class="uvq08-elv" style="--p:0.650;--y:0.2981"><div class="hd"><span class="tx"><b>Climb to Peñalara</b><span>8 km · +918 m · 3 h 10 min</span></span><svg class="rt" viewBox="0 0 60 60" aria-hidden="true"><polyline points="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8"/><circle class="a" cx="8" cy="57" r="2.6"/><circle class="b" cx="54.5" cy="11.8" r="2.6"/><circle class="me" cx="34.1" cy="22.6" r="3.2"/></svg></div><div class="pf pk" role="slider" tabindex="0" aria-label="Elevation profile" aria-valuemin="0" aria-valuemax="8" aria-valuenow="5.2" aria-valuetext="km 5,2, 2.258 m" data-e="1510,1527,1549,1571,1595,1618,1641,1663,1684,1706,1727,1750,1774,1799,1827,1858,1890,1925,1962,2001,2040,2079,2118,2156,2192,2227,2258,2287,2313,2337,2357,2376,2392,2406,2419,2423,2426,2428,2427,2425,2421" data-r="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8"><svg viewBox="0 0 200 80" preserveAspectRatio="none" aria-hidden="true"><path class="ar" d="M0 80 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5 L200 80Z"/><path class="li" d="M0 76.0 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5"/></svg><i class="vl" aria-hidden="true"></i><i class="dt" aria-hidden="true"></i><span class="tt md" aria-hidden="true"><b>2.258 m</b><span class="km">km 5,2</span><span class="sl">+16 %</span></span></div><div class="ax" aria-hidden="true"><span>0</span><span>4 km</span><span>8 km</span></div></div>
```

### CSS

```css
.uvq08-elv {
  --c1: #0f766e;
  --c2: #99f6e4;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq08-elv {
  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;
  width: 18em;
  padding: 1em 1.1em .8em;
  border-radius: 1.2em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
}

.uvq08-elv .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: .7em;
}

.uvq08-elv .tx {
  display: grid;
  gap: .15em;
}

.uvq08-elv .tx span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  font-variant-numeric: tabular-nums;
}

.uvq08-elv .rt {
  flex: none;
  width: 3.6em;
  height: 3.6em;
  border-radius: .7em;
  background: repeating-radial-gradient(circle at 70% 30%,transparent 0 .45em,color-mix(in srgb,var(--fg) 10%,transparent) .45em calc(.45em + 1px)),color-mix(in srgb,var(--c2) 25%,transparent);
  overflow: visible;
}

.uvq08-elv .rt polyline {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4 3;
}

.uvq08-elv .rt .a {
  fill: var(--bg);
  stroke: var(--c1);
  stroke-width: 1.6;
}

.uvq08-elv .rt .b {
  fill: var(--c1);
}

.uvq08-elv .rt .me {
  fill: #f97316;
  stroke: var(--bg);
  stroke-width: 1.5;
  transition: cx calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),cy calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .pf {
  position: relative;
  height: 6em;
  margin-top: 2.6em;
  border-radius: .5em;
  outline: 0;
  cursor: crosshair;
  touch-action: none;
}

.uvq08-elv .pf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-elv .pf svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.uvq08-elv .ar {
  fill: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq08-elv .li {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.uvq08-elv .vl,.uvq08-elv .dt,.uvq08-elv .tt {
  position: absolute;
  left: calc(var(--p) * 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .vl {
  top: calc(var(--y) * 100%);
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed color-mix(in srgb,var(--fg) 45%,transparent);
}

.uvq08-elv .dt {
  top: calc(var(--y) * 100%);
  width: .7em;
  height: .7em;
  translate: -50% -50%;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 0 2px var(--bg);
}

.uvq08-elv .tt {
  top: calc(var(--y) * 100%);
  z-index: 3;
  display: grid;
  grid-template-columns: auto auto;
  gap: .1em .6em;
  padding: .45em .65em;
  border-radius: .6em;
  font-size: .74em;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  translate: calc(var(--p) * -100%) calc(-100% - 1.2em);
}

.uvq08-elv .tt b {
  grid-column: 1/-1;
  font-size: 1.15em;
}

.uvq08-elv .km {
  opacity: .7;
}

.uvq08-elv .sl {
  font-weight: 800;
}

.uvq08-elv .lo .sl {
  color: #22c55e;
}

.uvq08-elv .md .sl {
  color: #f59e0b;
}

.uvq08-elv .hi .sl {
  color: #ef4444;
}

.uvq08-elv .dn .sl {
  color: #38bdf8;
}

.uvq08-elv .pf:is(:hover,:focus-visible,.pk,.on) :is(.vl,.dt,.tt) {
  opacity: 1;
}

.uvq08-elv .ax {
  display: flex;
  justify-content: space-between;
  margin-top: .35em;
  font-size: .65em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}
```

### JavaScript

```js
document.querySelectorAll(".uvq08-elv").forEach(el => {
  const unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const pf=el.querySelector(".pf"),E=pf.dataset.e.split(",").map(Number),R=pf.dataset.r.split(" ").map(p=>p.split(",")),me=el.querySelector(".me"),tt=pf.querySelector(".tt"),vb=tt.querySelector("b"),km=tt.querySelector(".km"),sl=tt.querySelector(".sl"),n=E.length,mn=Math.min(...E),mxE=Math.max(...E),lang=document.documentElement.lang||undefined;let cur=26;
const nf=(v,d)=>v.toLocaleString(lang,{minimumFractionDigits:d,maximumFractionDigits:d});
const set=i=>{i=Math.max(0,Math.min(n-1,i));cur=i;const y=(76-(E[i]-mn)/(mxE-mn)*64)/80,s=i?Math.round((E[i]-E[i-1])/2):0,k=nf(i*0.2,1);el.style.setProperty("--p",String(i/(n-1)));el.style.setProperty("--y",y.toFixed(4));vb.textContent=nf(E[i],0)+" m";km.textContent="km "+k;sl.textContent=(s>0?"+":"")+s+" %";tt.className="tt "+(s<0?"dn":s<6?"lo":s<12?"md":"hi");me.setAttribute("cx",R[i][0]);me.setAttribute("cy",R[i][1]);pf.setAttribute("aria-valuenow",(i*0.2).toFixed(1));pf.setAttribute("aria-valuetext","km "+k+", "+nf(E[i],0)+" m, "+sl.textContent)};
const at=e=>{const r=pf.getBoundingClientRect();set(Math.round((e.clientX-r.left)/r.width*(n-1)))};
pf.addEventListener("pointermove",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerdown",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerleave",()=>pf.classList.remove("on"));
pf.addEventListener("keydown",e=>{const d={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:5,PageDown:-5}[e.key];if(e.key==="Home")set(0);else if(e.key==="End")set(n-1);else if(d)set(cur+d);else return;e.preventDefault()});
set(cur)
});
```

### 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 = `
.uvq08-elv {
  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;
  width: 18em;
  padding: 1em 1.1em .8em;
  border-radius: 1.2em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
}

.uvq08-elv .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: .7em;
}

.uvq08-elv .tx {
  display: grid;
  gap: .15em;
}

.uvq08-elv .tx span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  font-variant-numeric: tabular-nums;
}

.uvq08-elv .rt {
  flex: none;
  width: 3.6em;
  height: 3.6em;
  border-radius: .7em;
  background: repeating-radial-gradient(circle at 70% 30%,transparent 0 .45em,color-mix(in srgb,var(--fg) 10%,transparent) .45em calc(.45em + 1px)),color-mix(in srgb,var(--c2) 25%,transparent);
  overflow: visible;
}

.uvq08-elv .rt polyline {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4 3;
}

.uvq08-elv .rt .a {
  fill: var(--bg);
  stroke: var(--c1);
  stroke-width: 1.6;
}

.uvq08-elv .rt .b {
  fill: var(--c1);
}

.uvq08-elv .rt .me {
  fill: #f97316;
  stroke: var(--bg);
  stroke-width: 1.5;
  transition: cx calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),cy calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .pf {
  position: relative;
  height: 6em;
  margin-top: 2.6em;
  border-radius: .5em;
  outline: 0;
  cursor: crosshair;
  touch-action: none;
}

.uvq08-elv .pf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-elv .pf svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.uvq08-elv .ar {
  fill: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq08-elv .li {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.uvq08-elv .vl,.uvq08-elv .dt,.uvq08-elv .tt {
  position: absolute;
  left: calc(var(--p) * 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .vl {
  top: calc(var(--y) * 100%);
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed color-mix(in srgb,var(--fg) 45%,transparent);
}

.uvq08-elv .dt {
  top: calc(var(--y) * 100%);
  width: .7em;
  height: .7em;
  translate: -50% -50%;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 0 2px var(--bg);
}

.uvq08-elv .tt {
  top: calc(var(--y) * 100%);
  z-index: 3;
  display: grid;
  grid-template-columns: auto auto;
  gap: .1em .6em;
  padding: .45em .65em;
  border-radius: .6em;
  font-size: .74em;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  translate: calc(var(--p) * -100%) calc(-100% - 1.2em);
}

.uvq08-elv .tt b {
  grid-column: 1/-1;
  font-size: 1.15em;
}

.uvq08-elv .km {
  opacity: .7;
}

.uvq08-elv .sl {
  font-weight: 800;
}

.uvq08-elv .lo .sl {
  color: #22c55e;
}

.uvq08-elv .md .sl {
  color: #f59e0b;
}

.uvq08-elv .hi .sl {
  color: #ef4444;
}

.uvq08-elv .dn .sl {
  color: #38bdf8;
}

.uvq08-elv .pf:is(:hover,:focus-visible,.pk,.on) :is(.vl,.dt,.tt) {
  opacity: 1;
}

.uvq08-elv .ax {
  display: flex;
  justify-content: space-between;
  margin-top: .35em;
  font-size: .65em;
  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 unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const pf=el.querySelector(".pf"),E=pf.dataset.e.split(",").map(Number),R=pf.dataset.r.split(" ").map(p=>p.split(",")),me=el.querySelector(".me"),tt=pf.querySelector(".tt"),vb=tt.querySelector("b"),km=tt.querySelector(".km"),sl=tt.querySelector(".sl"),n=E.length,mn=Math.min(...E),mxE=Math.max(...E),lang=document.documentElement.lang||undefined;let cur=26;
const nf=(v,d)=>v.toLocaleString(lang,{minimumFractionDigits:d,maximumFractionDigits:d});
const set=i=>{i=Math.max(0,Math.min(n-1,i));cur=i;const y=(76-(E[i]-mn)/(mxE-mn)*64)/80,s=i?Math.round((E[i]-E[i-1])/2):0,k=nf(i*0.2,1);el.style.setProperty("--p",String(i/(n-1)));el.style.setProperty("--y",y.toFixed(4));vb.textContent=nf(E[i],0)+" m";km.textContent="km "+k;sl.textContent=(s>0?"+":"")+s+" %";tt.className="tt "+(s<0?"dn":s<6?"lo":s<12?"md":"hi");me.setAttribute("cx",R[i][0]);me.setAttribute("cy",R[i][1]);pf.setAttribute("aria-valuenow",(i*0.2).toFixed(1));pf.setAttribute("aria-valuetext","km "+k+", "+nf(E[i],0)+" m, "+sl.textContent)};
const at=e=>{const r=pf.getBoundingClientRect();set(Math.round((e.clientX-r.left)/r.width*(n-1)))};
pf.addEventListener("pointermove",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerdown",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerleave",()=>pf.classList.remove("on"));
pf.addEventListener("keydown",e=>{const d={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:5,PageDown:-5}[e.key];if(e.key==="Home")set(0);else if(e.key==="End")set(n-1);else if(d)set(cur+d);else return;e.preventDefault()});
set(cur)
}

export default function TipElevationProfile() {
  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": "#0f766e",
          "--c2": "#99f6e4",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-elv" style={{ "--p": "0.650", "--y": "0.2981" } as CSSProperties}><div className="hd"><span className="tx"><b>Climb to Peñalara</b><span>8 km · +918 m · 3 h 10 min</span></span><svg className="rt" viewBox="0 0 60 60" aria-hidden="true"><polyline points="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8" /><circle className="a" cx="8" cy="57" r="2.6" /><circle className="b" cx="54.5" cy="11.8" r="2.6" /><circle className="me" cx="34.1" cy="22.6" r="3.2" /></svg></div><div className="pf pk" role="slider" tabIndex={0} aria-label="Elevation profile" aria-valuemin="0" aria-valuemax="8" aria-valuenow="5.2" aria-valuetext="km 5,2, 2.258 m" data-e="1510,1527,1549,1571,1595,1618,1641,1663,1684,1706,1727,1750,1774,1799,1827,1858,1890,1925,1962,2001,2040,2079,2118,2156,2192,2227,2258,2287,2313,2337,2357,2376,2392,2406,2419,2423,2426,2428,2427,2425,2421" data-r="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8"><svg viewBox="0 0 200 80" preserveAspectRatio="none" aria-hidden="true"><path className="ar" d="M0 80 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5 L200 80Z" /><path className="li" d="M0 76.0 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5" /></svg><i className="vl" aria-hidden="true"></i><i className="dt" aria-hidden="true"></i><span className="tt md" aria-hidden="true"><b>2.258 m</b><span className="km">km 5,2</span><span className="sl">+16 %</span></span></div><div className="ax" aria-hidden="true"><span>0</span><span>4 km</span><span>8 km</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 “Route elevation profile tooltip” block (Tooltips) from AIMRAN Library to my project.

## What it is
Scrub a route's elevation profile with a finger, the mouse or the arrow keys: the tooltip gives altitude, distance and slope.

## Chosen settings
- Main color: #0f766e
- Secondary color: #99f6e4
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Subida a Peñalara"

## 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 = `
.uvq08-elv {
  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;
  width: 18em;
  padding: 1em 1.1em .8em;
  border-radius: 1.2em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
}

.uvq08-elv .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: .7em;
}

.uvq08-elv .tx {
  display: grid;
  gap: .15em;
}

.uvq08-elv .tx span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  font-variant-numeric: tabular-nums;
}

.uvq08-elv .rt {
  flex: none;
  width: 3.6em;
  height: 3.6em;
  border-radius: .7em;
  background: repeating-radial-gradient(circle at 70% 30%,transparent 0 .45em,color-mix(in srgb,var(--fg) 10%,transparent) .45em calc(.45em + 1px)),color-mix(in srgb,var(--c2) 25%,transparent);
  overflow: visible;
}

.uvq08-elv .rt polyline {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4 3;
}

.uvq08-elv .rt .a {
  fill: var(--bg);
  stroke: var(--c1);
  stroke-width: 1.6;
}

.uvq08-elv .rt .b {
  fill: var(--c1);
}

.uvq08-elv .rt .me {
  fill: #f97316;
  stroke: var(--bg);
  stroke-width: 1.5;
  transition: cx calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),cy calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .pf {
  position: relative;
  height: 6em;
  margin-top: 2.6em;
  border-radius: .5em;
  outline: 0;
  cursor: crosshair;
  touch-action: none;
}

.uvq08-elv .pf:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-elv .pf svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.uvq08-elv .ar {
  fill: color-mix(in srgb,var(--c1) 18%,transparent);
}

.uvq08-elv .li {
  fill: none;
  stroke: var(--c1);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.uvq08-elv .vl,.uvq08-elv .dt,.uvq08-elv .tt {
  position: absolute;
  left: calc(var(--p) * 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-elv .vl {
  top: calc(var(--y) * 100%);
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed color-mix(in srgb,var(--fg) 45%,transparent);
}

.uvq08-elv .dt {
  top: calc(var(--y) * 100%);
  width: .7em;
  height: .7em;
  translate: -50% -50%;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 0 2px var(--bg);
}

.uvq08-elv .tt {
  top: calc(var(--y) * 100%);
  z-index: 3;
  display: grid;
  grid-template-columns: auto auto;
  gap: .1em .6em;
  padding: .45em .65em;
  border-radius: .6em;
  font-size: .74em;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  translate: calc(var(--p) * -100%) calc(-100% - 1.2em);
}

.uvq08-elv .tt b {
  grid-column: 1/-1;
  font-size: 1.15em;
}

.uvq08-elv .km {
  opacity: .7;
}

.uvq08-elv .sl {
  font-weight: 800;
}

.uvq08-elv .lo .sl {
  color: #22c55e;
}

.uvq08-elv .md .sl {
  color: #f59e0b;
}

.uvq08-elv .hi .sl {
  color: #ef4444;
}

.uvq08-elv .dn .sl {
  color: #38bdf8;
}

.uvq08-elv .pf:is(:hover,:focus-visible,.pk,.on) :is(.vl,.dt,.tt) {
  opacity: 1;
}

.uvq08-elv .ax {
  display: flex;
  justify-content: space-between;
  margin-top: .35em;
  font-size: .65em;
  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 unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const pf=el.querySelector(".pf"),E=pf.dataset.e.split(",").map(Number),R=pf.dataset.r.split(" ").map(p=>p.split(",")),me=el.querySelector(".me"),tt=pf.querySelector(".tt"),vb=tt.querySelector("b"),km=tt.querySelector(".km"),sl=tt.querySelector(".sl"),n=E.length,mn=Math.min(...E),mxE=Math.max(...E),lang=document.documentElement.lang||undefined;let cur=26;
const nf=(v,d)=>v.toLocaleString(lang,{minimumFractionDigits:d,maximumFractionDigits:d});
const set=i=>{i=Math.max(0,Math.min(n-1,i));cur=i;const y=(76-(E[i]-mn)/(mxE-mn)*64)/80,s=i?Math.round((E[i]-E[i-1])/2):0,k=nf(i*0.2,1);el.style.setProperty("--p",String(i/(n-1)));el.style.setProperty("--y",y.toFixed(4));vb.textContent=nf(E[i],0)+" m";km.textContent="km "+k;sl.textContent=(s>0?"+":"")+s+" %";tt.className="tt "+(s<0?"dn":s<6?"lo":s<12?"md":"hi");me.setAttribute("cx",R[i][0]);me.setAttribute("cy",R[i][1]);pf.setAttribute("aria-valuenow",(i*0.2).toFixed(1));pf.setAttribute("aria-valuetext","km "+k+", "+nf(E[i],0)+" m, "+sl.textContent)};
const at=e=>{const r=pf.getBoundingClientRect();set(Math.round((e.clientX-r.left)/r.width*(n-1)))};
pf.addEventListener("pointermove",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerdown",e=>{pf.classList.add("on");at(e)});pf.addEventListener("pointerleave",()=>pf.classList.remove("on"));
pf.addEventListener("keydown",e=>{const d={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1,PageUp:5,PageDown:-5}[e.key];if(e.key==="Home")set(0);else if(e.key==="End")set(n-1);else if(d)set(cur+d);else return;e.preventDefault()});
set(cur)
}

export default function TipElevationProfile() {
  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": "#0f766e",
          "--c2": "#99f6e4",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-elv" style={{ "--p": "0.650", "--y": "0.2981" } as CSSProperties}><div className="hd"><span className="tx"><b>Climb to Peñalara</b><span>8 km · +918 m · 3 h 10 min</span></span><svg className="rt" viewBox="0 0 60 60" aria-hidden="true"><polyline points="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8" /><circle className="a" cx="8" cy="57" r="2.6" /><circle className="b" cx="54.5" cy="11.8" r="2.6" /><circle className="me" cx="34.1" cy="22.6" r="3.2" /></svg></div><div className="pf pk" role="slider" tabIndex={0} aria-label="Elevation profile" aria-valuemin="0" aria-valuemax="8" aria-valuenow="5.2" aria-valuetext="km 5,2, 2.258 m" data-e="1510,1527,1549,1571,1595,1618,1641,1663,1684,1706,1727,1750,1774,1799,1827,1858,1890,1925,1962,2001,2040,2079,2118,2156,2192,2227,2258,2287,2313,2337,2357,2376,2392,2406,2419,2423,2426,2428,2427,2425,2421" data-r="8,57 10.4,55.8 12.8,54.5 15,53 17.1,51.4 18.9,49.7 20.5,47.9 21.7,46 22.6,44 23.3,42.1 23.7,40.1 23.8,38.2 23.8,36.3 23.6,34.5 23.3,32.7 23.1,31.2 22.9,29.7 22.9,28.4 23.1,27.2 23.5,26.2 24.1,25.3 25.1,24.6 26.4,24 27.9,23.5 29.8,23.1 31.8,22.8 34.1,22.6 36.5,22.4 38.9,22.1 41.3,21.9 43.7,21.6 45.9,21.2 48,20.7 49.8,20.1 51.3,19.3 52.5,18.4 53.4,17.4 54,16.2 54.4,14.9 54.5,13.4 54.5,11.8"><svg viewBox="0 0 200 80" preserveAspectRatio="none" aria-hidden="true"><path className="ar" d="M0 80 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5 L200 80Z" /><path className="li" d="M0 76.0 L0 76.0 L5 74.8 L10 73.3 L15 71.7 L20 70.1 L25 68.5 L30 66.9 L35 65.3 L40 63.9 L45 62.3 L50 60.9 L55 59.3 L60 57.6 L65 55.9 L70 53.9 L75 51.7 L80 49.5 L85 47.1 L90 44.5 L95 41.8 L100 39.1 L105 36.3 L110 33.6 L115 31.0 L120 28.5 L125 26.0 L130 23.9 L135 21.8 L140 20.0 L145 18.3 L150 16.9 L155 15.6 L160 14.5 L165 13.5 L170 12.6 L175 12.3 L180 12.1 L185 12.0 L190 12.1 L195 12.2 L200 12.5" /></svg><i className="vl" aria-hidden="true"></i><i className="dt" aria-hidden="true"></i><span className="tt md" aria-hidden="true"><b>2.258 m</b><span className="km">km 5,2</span><span className="sl">+16 %</span></span></div><div className="ax" aria-hidden="true"><span>0</span><span>4 km</span><span>8 km</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.
````
