# Activity heatmap tooltip

> A twelve week practice grid: hover or move with the arrow keys and a tooltip shows the minutes and the date.

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

## Where to use it

A grid of twelve weeks by seven days in five shades of amber, like a contribution graph for piano practice. A single tooltip glides to the hovered or focused cell with the minutes and a date formatted in the page language. The grid has one tab stop, the arrow keys move in two dimensions, and Home and End jump along the row.

The main color sets the five levels of the scale. Replace the generated data with your own minutes, steps, commits or sales, and change the start date in the script so the labels line up with real days.

## Code

### HTML

```html
<div class="uvq08-hm"><p class="hd"><b>Piano practice</b><span>Last 12 weeks</span></p><div class="gd show" role="group" aria-label="Piano practice"><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v2" data-m="34" aria-label="34 min" tabindex="-1"></button><button type="button" class="v2" data-m="31" aria-label="31 min" tabindex="-1"></button><button type="button" class="v1" data-m="6" aria-label="6 min" tabindex="-1"></button><button type="button" class="v3" data-m="53" aria-label="53 min" tabindex="-1"></button><button type="button" class="v4" data-m="69" aria-label="69 min" tabindex="-1"></button><button type="button" class="v2" data-m="37" aria-label="37 min" tabindex="-1"></button><button type="button" class="v1" data-m="16" aria-label="16 min" tabindex="-1"></button><button type="button" class="v2" data-m="21" aria-label="21 min" tabindex="-1"></button><button type="button" class="v3" data-m="49" aria-label="49 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="55" aria-label="55 min" tabindex="-1"></button><button type="button" class="v4" data-m="63" aria-label="63 min" tabindex="-1"></button><button type="button" class="v4" data-m="61" aria-label="61 min" tabindex="-1"></button><button type="button" class="v2" data-m="25" aria-label="25 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v2" data-m="35" aria-label="35 min" tabindex="-1"></button><button type="button" class="v1" data-m="8" aria-label="8 min" tabindex="-1"></button><button type="button" class="v3" data-m="46" aria-label="46 min" tabindex="-1"></button><button type="button" class="v1" data-m="19" aria-label="19 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v1" data-m="16" aria-label="16 min" tabindex="-1"></button><button type="button" class="v3" data-m="55" aria-label="55 min" tabindex="-1"></button><button type="button" class="v3" data-m="44" aria-label="44 min" tabindex="-1"></button><button type="button" class="v3" data-m="45" aria-label="45 min" tabindex="-1"></button><button type="button" class="v3" data-m="51" aria-label="51 min" tabindex="-1"></button><button type="button" class="v3" data-m="51" aria-label="51 min" tabindex="-1"></button><button type="button" class="v1" data-m="7" aria-label="7 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v2" data-m="35" aria-label="35 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="40" aria-label="40 min" tabindex="-1"></button><button type="button" class="v4" data-m="75" aria-label="75 min" tabindex="-1"></button><button type="button" class="v1" data-m="18" aria-label="18 min" tabindex="-1"></button><button type="button" class="v1" data-m="16" aria-label="16 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="49" aria-label="49 min" tabindex="-1"></button><button type="button" class="v2" data-m="36" aria-label="36 min" tabindex="-1"></button><button type="button" class="v4" data-m="70" aria-label="70 min" tabindex="-1"></button><button type="button" class="v1" data-m="9" aria-label="9 min" tabindex="-1"></button><button type="button" class="v2" data-m="22" aria-label="22 min" tabindex="-1"></button><button type="button" class="v2" data-m="22" aria-label="22 min" tabindex="-1"></button><button type="button" class="v3" data-m="53" aria-label="53 min" tabindex="-1"></button><button type="button" class="v3" data-m="50" aria-label="50 min" tabindex="-1"></button><button type="button" class="v2" data-m="35" aria-label="35 min" tabindex="-1"></button><button type="button" class="v4" data-m="69" aria-label="69 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="58" aria-label="58 min" tabindex="-1"></button><button type="button" class="v2" data-m="33" aria-label="33 min" tabindex="-1"></button><button type="button" class="v3" data-m="45" aria-label="45 min" tabindex="-1"></button><button type="button" class="v2" data-m="35" aria-label="35 min" tabindex="-1"></button><button type="button" class="v3" data-m="57" aria-label="57 min" tabindex="-1"></button><button type="button" class="v3" data-m="52" aria-label="52 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="54" aria-label="54 min" tabindex="-1"></button><button type="button" class="v3" data-m="44" aria-label="44 min" tabindex="-1"></button><button type="button" class="v4" data-m="62" aria-label="62 min" tabindex="-1"></button><button type="button" class="v3" data-m="51" aria-label="51 min" tabindex="-1"></button><button type="button" class="v0" data-m="0" aria-label="0 min" tabindex="-1"></button><button type="button" class="v3" data-m="53" aria-label="53 min" tabindex="-1"></button><button type="button" class="v1" data-m="10" aria-label="10 min" tabindex="-1"></button><button type="button" class="v2" data-m="32" aria-label="32 min" tabindex="-1"></button><button type="button" class="v2" data-m="34" aria-label="34 min" tabindex="-1"></button><button type="button" class="v2" data-m="37" aria-label="37 min" tabindex="-1"></button><button type="button" class="v3" data-m="58" aria-label="58 min" tabindex="-1"></button><button type="button" class="v3" data-m="50" aria-label="50 min" tabindex="-1"></button><button type="button" class="v1" data-m="14" aria-label="14 min" tabindex="-1"></button><button type="button" class="v3" data-m="43" aria-label="43 min" tabindex="-1"></button><button type="button" class="v2" data-m="31" aria-label="31 min" tabindex="-1"></button><button type="button" class="v3" data-m="46" aria-label="46 min" tabindex="-1"></button><button type="button" class="v4" data-m="63" aria-label="63 min" tabindex="-1"></button><button type="button" class="v2" data-m="38" aria-label="38 min" tabindex="-1"></button><button type="button" class="v3" data-m="49" aria-label="49 min" tabindex="-1"></button><button type="button" class="v2" data-m="25" aria-label="25 min" tabindex="-1"></button><button type="button" class="v2" data-m="33" aria-label="33 min" tabindex="-1"></button><button type="button" class="v2" data-m="37" aria-label="37 min" tabindex="-1"></button><button type="button" class="v3" data-m="44" aria-label="44 min" tabindex="-1"></button><button type="button" class="v4" data-m="73" aria-label="73 min" tabindex="-1"></button><button type="button" class="v3 on" data-m="48" aria-label="48 min" tabindex="0"></button><span class="tt" aria-hidden="true"><b>48 min</b><span>Sun, Oct 25</span></span></div><p class="lg" aria-hidden="true"><span>Less</span><i class="v0"></i><i class="v1"></i><i class="v2"></i><i class="v3"></i><i class="v4"></i><span>More</span></p></div>
```

### CSS

```css
.uvq08-hm {
  --c1: #d97706;
  --c2: #fde68a;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq08-hm {
  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;
  margin-top: 1.6em;
  padding: 1em 1.1em .85em;
  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-hm .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .8em;
}

.uvq08-hm .hd span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .gd {
  position: relative;
  display: grid;
  grid-template-rows: repeat(7,1em);
  grid-auto-flow: column;
  grid-auto-columns: 1em;
  gap: .24em;
}

.uvq08-hm .gd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: .22em;
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm :is(.gd button,.lg i).v0 {
  background: color-mix(in srgb,var(--fg) 8%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v1 {
  background: color-mix(in srgb,var(--c1) 28%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v2 {
  background: color-mix(in srgb,var(--c1) 52%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v3 {
  background: color-mix(in srgb,var(--c1) 78%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v4 {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq08-hm .gd button:hover {
  transform: scale(1.15);
}

.uvq08-hm .gd button.on {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--bg),0 0 0 3.5px var(--fg);
}

.uvq08-hm .gd button:focus-visible {
  outline: 0;
}

.uvq08-hm .tt {
  position: absolute;
  left: var(--x,19.64em);
  top: var(--y,10.33em);
  z-index: 3;
  display: grid;
  padding: .4em .65em;
  border-radius: .55em;
  font-size: .72em;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translate(-50%,calc(-100% - .9em));
  opacity: 0;
  pointer-events: none;
  transition: left calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),top calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm .tt b {
  font-variant-numeric: tabular-nums;
}

.uvq08-hm .tt span {
  font-size: .85em;
  opacity: .75;
}

.uvq08-hm .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,-55%) rotate(45deg);
  border-radius: 0 0 .15em 0;
}

.uvq08-hm .gd.show .tt {
  opacity: 1;
}

.uvq08-hm .lg {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .25em;
  margin: .8em 0 0;
  font-size: .68em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .lg i {
  width: 1em;
  height: 1em;
  border-radius: .25em;
}

.uvq08-hm .lg span:first-child {
  margin-right: .3em;
}

.uvq08-hm .lg span:last-child {
  margin-left: .3em;
}
```

### JavaScript

```js
document.querySelectorAll(".uvq08-hm").forEach(el => {
  const gd=el.querySelector(".gd"),tt=gd.querySelector(".tt"),vb=tt.querySelector("b"),ds=tt.querySelector("span"),cs=[...gd.querySelectorAll("button")];let cur=cs.find(c=>c.tabIndex===0)||cs[0];
const day=i=>new Date(2026,7,3+i).toLocaleDateString(document.documentElement.lang||undefined,{weekday:"short",day:"numeric",month:"short"});
cs.forEach((c,i)=>c.setAttribute("aria-label",c.dataset.m+" min, "+day(i)));
const show=c=>{cs.forEach(x=>x.classList.toggle("on",x===c));const r=gd.getBoundingClientRect(),q=c.getBoundingClientRect(),sc=r.width/gd.offsetWidth||1;gd.style.setProperty("--x",((q.left-r.left+q.width/2)/sc)+"px");gd.style.setProperty("--y",((q.top-r.top)/sc)+"px");vb.textContent=c.dataset.m+" min";ds.textContent=day(cs.indexOf(c));gd.classList.add("show")};
const hide=()=>{gd.classList.remove("show");cs.forEach(x=>x.classList.remove("on"))};
const go=c=>{if(!c)return;cur.tabIndex=-1;cur=c;c.tabIndex=0;c.focus()};
cs.forEach(c=>{c.addEventListener("pointerenter",()=>show(c));c.addEventListener("focus",()=>{cur.tabIndex=-1;cur=c;c.tabIndex=0;show(c)})});
gd.addEventListener("pointerleave",()=>{if(!gd.contains(document.activeElement))hide()});gd.addEventListener("focusout",e=>{if(!gd.contains(e.relatedTarget))hide()});
gd.addEventListener("keydown",e=>{const i=cs.indexOf(cur),r=i%7;if(e.key==="ArrowUp"){if(r)go(cs[i-1])}else if(e.key==="ArrowDown"){if(r<6)go(cs[i+1])}else if(e.key==="ArrowLeft")go(cs[i-7]);else if(e.key==="ArrowRight")go(cs[i+7]);else if(e.key==="Home")go(cs[r]);else if(e.key==="End")go(cs[cs.length-7+r]);else return;e.preventDefault()});
const f=requestAnimationFrame(()=>show(cur));return()=>cancelAnimationFrame(f)
});
```

### 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-hm {
  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;
  margin-top: 1.6em;
  padding: 1em 1.1em .85em;
  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-hm .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .8em;
}

.uvq08-hm .hd span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .gd {
  position: relative;
  display: grid;
  grid-template-rows: repeat(7,1em);
  grid-auto-flow: column;
  grid-auto-columns: 1em;
  gap: .24em;
}

.uvq08-hm .gd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: .22em;
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm :is(.gd button,.lg i).v0 {
  background: color-mix(in srgb,var(--fg) 8%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v1 {
  background: color-mix(in srgb,var(--c1) 28%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v2 {
  background: color-mix(in srgb,var(--c1) 52%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v3 {
  background: color-mix(in srgb,var(--c1) 78%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v4 {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq08-hm .gd button:hover {
  transform: scale(1.15);
}

.uvq08-hm .gd button.on {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--bg),0 0 0 3.5px var(--fg);
}

.uvq08-hm .gd button:focus-visible {
  outline: 0;
}

.uvq08-hm .tt {
  position: absolute;
  left: var(--x,19.64em);
  top: var(--y,10.33em);
  z-index: 3;
  display: grid;
  padding: .4em .65em;
  border-radius: .55em;
  font-size: .72em;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translate(-50%,calc(-100% - .9em));
  opacity: 0;
  pointer-events: none;
  transition: left calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),top calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm .tt b {
  font-variant-numeric: tabular-nums;
}

.uvq08-hm .tt span {
  font-size: .85em;
  opacity: .75;
}

.uvq08-hm .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,-55%) rotate(45deg);
  border-radius: 0 0 .15em 0;
}

.uvq08-hm .gd.show .tt {
  opacity: 1;
}

.uvq08-hm .lg {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .25em;
  margin: .8em 0 0;
  font-size: .68em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .lg i {
  width: 1em;
  height: 1em;
  border-radius: .25em;
}

.uvq08-hm .lg span:first-child {
  margin-right: .3em;
}

.uvq08-hm .lg span:last-child {
  margin-left: .3em;
}
`;

// 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 gd=el.querySelector(".gd"),tt=gd.querySelector(".tt"),vb=tt.querySelector("b"),ds=tt.querySelector("span"),cs=[...gd.querySelectorAll("button")];let cur=cs.find(c=>c.tabIndex===0)||cs[0];
const day=i=>new Date(2026,7,3+i).toLocaleDateString(document.documentElement.lang||undefined,{weekday:"short",day:"numeric",month:"short"});
cs.forEach((c,i)=>c.setAttribute("aria-label",c.dataset.m+" min, "+day(i)));
const show=c=>{cs.forEach(x=>x.classList.toggle("on",x===c));const r=gd.getBoundingClientRect(),q=c.getBoundingClientRect(),sc=r.width/gd.offsetWidth||1;gd.style.setProperty("--x",((q.left-r.left+q.width/2)/sc)+"px");gd.style.setProperty("--y",((q.top-r.top)/sc)+"px");vb.textContent=c.dataset.m+" min";ds.textContent=day(cs.indexOf(c));gd.classList.add("show")};
const hide=()=>{gd.classList.remove("show");cs.forEach(x=>x.classList.remove("on"))};
const go=c=>{if(!c)return;cur.tabIndex=-1;cur=c;c.tabIndex=0;c.focus()};
cs.forEach(c=>{c.addEventListener("pointerenter",()=>show(c));c.addEventListener("focus",()=>{cur.tabIndex=-1;cur=c;c.tabIndex=0;show(c)})});
gd.addEventListener("pointerleave",()=>{if(!gd.contains(document.activeElement))hide()});gd.addEventListener("focusout",e=>{if(!gd.contains(e.relatedTarget))hide()});
gd.addEventListener("keydown",e=>{const i=cs.indexOf(cur),r=i%7;if(e.key==="ArrowUp"){if(r)go(cs[i-1])}else if(e.key==="ArrowDown"){if(r<6)go(cs[i+1])}else if(e.key==="ArrowLeft")go(cs[i-7]);else if(e.key==="ArrowRight")go(cs[i+7]);else if(e.key==="Home")go(cs[r]);else if(e.key==="End")go(cs[cs.length-7+r]);else return;e.preventDefault()});
const f=requestAnimationFrame(()=>show(cur));return()=>cancelAnimationFrame(f)
}

export default function TipHeatmapGrid() {
  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": "#d97706",
          "--c2": "#fde68a",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-hm"><p className="hd"><b>Piano practice</b><span>Last 12 weeks</span></p><div className="gd show" role="group" aria-label="Piano practice"><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="34" aria-label="34 min" tabIndex={-1}></button><button type="button" className="v2" data-m="31" aria-label="31 min" tabIndex={-1}></button><button type="button" className="v1" data-m="6" aria-label="6 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v4" data-m="69" aria-label="69 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v2" data-m="21" aria-label="21 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="55" aria-label="55 min" tabIndex={-1}></button><button type="button" className="v4" data-m="63" aria-label="63 min" tabIndex={-1}></button><button type="button" className="v4" data-m="61" aria-label="61 min" tabIndex={-1}></button><button type="button" className="v2" data-m="25" aria-label="25 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v1" data-m="8" aria-label="8 min" tabIndex={-1}></button><button type="button" className="v3" data-m="46" aria-label="46 min" tabIndex={-1}></button><button type="button" className="v1" data-m="19" aria-label="19 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v3" data-m="55" aria-label="55 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v3" data-m="45" aria-label="45 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v1" data-m="7" aria-label="7 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="40" aria-label="40 min" tabIndex={-1}></button><button type="button" className="v4" data-m="75" aria-label="75 min" tabIndex={-1}></button><button type="button" className="v1" data-m="18" aria-label="18 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v2" data-m="36" aria-label="36 min" tabIndex={-1}></button><button type="button" className="v4" data-m="70" aria-label="70 min" tabIndex={-1}></button><button type="button" className="v1" data-m="9" aria-label="9 min" tabIndex={-1}></button><button type="button" className="v2" data-m="22" aria-label="22 min" tabIndex={-1}></button><button type="button" className="v2" data-m="22" aria-label="22 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v3" data-m="50" aria-label="50 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v4" data-m="69" aria-label="69 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="58" aria-label="58 min" tabIndex={-1}></button><button type="button" className="v2" data-m="33" aria-label="33 min" tabIndex={-1}></button><button type="button" className="v3" data-m="45" aria-label="45 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v3" data-m="57" aria-label="57 min" tabIndex={-1}></button><button type="button" className="v3" data-m="52" aria-label="52 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="54" aria-label="54 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v4" data-m="62" aria-label="62 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v1" data-m="10" aria-label="10 min" tabIndex={-1}></button><button type="button" className="v2" data-m="32" aria-label="32 min" tabIndex={-1}></button><button type="button" className="v2" data-m="34" aria-label="34 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v3" data-m="58" aria-label="58 min" tabIndex={-1}></button><button type="button" className="v3" data-m="50" aria-label="50 min" tabIndex={-1}></button><button type="button" className="v1" data-m="14" aria-label="14 min" tabIndex={-1}></button><button type="button" className="v3" data-m="43" aria-label="43 min" tabIndex={-1}></button><button type="button" className="v2" data-m="31" aria-label="31 min" tabIndex={-1}></button><button type="button" className="v3" data-m="46" aria-label="46 min" tabIndex={-1}></button><button type="button" className="v4" data-m="63" aria-label="63 min" tabIndex={-1}></button><button type="button" className="v2" data-m="38" aria-label="38 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v2" data-m="25" aria-label="25 min" tabIndex={-1}></button><button type="button" className="v2" data-m="33" aria-label="33 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v4" data-m="73" aria-label="73 min" tabIndex={-1}></button><button type="button" className="v3 on" data-m="48" aria-label="48 min" tabIndex={0}></button><span className="tt" aria-hidden="true"><b>48 min</b><span>Sun, Oct 25</span></span></div><p className="lg" aria-hidden="true"><span>Less</span><i className="v0"></i><i className="v1"></i><i className="v2"></i><i className="v3"></i><i className="v4"></i><span>More</span></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 “Activity heatmap tooltip” block (Tooltips) from AIMRAN Library to my project.

## What it is
A twelve week practice grid: hover or move with the arrow keys and a tooltip shows the minutes and the date.

## Chosen settings
- Main color: #d97706
- Secondary color: #fde68a
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Práctica de piano"

## 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-hm {
  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;
  margin-top: 1.6em;
  padding: 1em 1.1em .85em;
  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-hm .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  margin: 0 0 .8em;
}

.uvq08-hm .hd span {
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .gd {
  position: relative;
  display: grid;
  grid-template-rows: repeat(7,1em);
  grid-auto-flow: column;
  grid-auto-columns: 1em;
  gap: .24em;
}

.uvq08-hm .gd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: .22em;
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),box-shadow calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm :is(.gd button,.lg i).v0 {
  background: color-mix(in srgb,var(--fg) 8%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v1 {
  background: color-mix(in srgb,var(--c1) 28%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v2 {
  background: color-mix(in srgb,var(--c1) 52%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v3 {
  background: color-mix(in srgb,var(--c1) 78%,transparent);
}

.uvq08-hm :is(.gd button,.lg i).v4 {
  background: color-mix(in srgb,var(--c1) 85%,#000);
}

.uvq08-hm .gd button:hover {
  transform: scale(1.15);
}

.uvq08-hm .gd button.on {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px var(--bg),0 0 0 3.5px var(--fg);
}

.uvq08-hm .gd button:focus-visible {
  outline: 0;
}

.uvq08-hm .tt {
  position: absolute;
  left: var(--x,19.64em);
  top: var(--y,10.33em);
  z-index: 3;
  display: grid;
  padding: .4em .65em;
  border-radius: .55em;
  font-size: .72em;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translate(-50%,calc(-100% - .9em));
  opacity: 0;
  pointer-events: none;
  transition: left calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),top calc(0.3s / var(--k)) cubic-bezier(.22,1,.36,1),opacity calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-hm .tt b {
  font-variant-numeric: tabular-nums;
}

.uvq08-hm .tt span {
  font-size: .85em;
  opacity: .75;
}

.uvq08-hm .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,-55%) rotate(45deg);
  border-radius: 0 0 .15em 0;
}

.uvq08-hm .gd.show .tt {
  opacity: 1;
}

.uvq08-hm .lg {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .25em;
  margin: .8em 0 0;
  font-size: .68em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-hm .lg i {
  width: 1em;
  height: 1em;
  border-radius: .25em;
}

.uvq08-hm .lg span:first-child {
  margin-right: .3em;
}

.uvq08-hm .lg span:last-child {
  margin-left: .3em;
}
`;

// 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 gd=el.querySelector(".gd"),tt=gd.querySelector(".tt"),vb=tt.querySelector("b"),ds=tt.querySelector("span"),cs=[...gd.querySelectorAll("button")];let cur=cs.find(c=>c.tabIndex===0)||cs[0];
const day=i=>new Date(2026,7,3+i).toLocaleDateString(document.documentElement.lang||undefined,{weekday:"short",day:"numeric",month:"short"});
cs.forEach((c,i)=>c.setAttribute("aria-label",c.dataset.m+" min, "+day(i)));
const show=c=>{cs.forEach(x=>x.classList.toggle("on",x===c));const r=gd.getBoundingClientRect(),q=c.getBoundingClientRect(),sc=r.width/gd.offsetWidth||1;gd.style.setProperty("--x",((q.left-r.left+q.width/2)/sc)+"px");gd.style.setProperty("--y",((q.top-r.top)/sc)+"px");vb.textContent=c.dataset.m+" min";ds.textContent=day(cs.indexOf(c));gd.classList.add("show")};
const hide=()=>{gd.classList.remove("show");cs.forEach(x=>x.classList.remove("on"))};
const go=c=>{if(!c)return;cur.tabIndex=-1;cur=c;c.tabIndex=0;c.focus()};
cs.forEach(c=>{c.addEventListener("pointerenter",()=>show(c));c.addEventListener("focus",()=>{cur.tabIndex=-1;cur=c;c.tabIndex=0;show(c)})});
gd.addEventListener("pointerleave",()=>{if(!gd.contains(document.activeElement))hide()});gd.addEventListener("focusout",e=>{if(!gd.contains(e.relatedTarget))hide()});
gd.addEventListener("keydown",e=>{const i=cs.indexOf(cur),r=i%7;if(e.key==="ArrowUp"){if(r)go(cs[i-1])}else if(e.key==="ArrowDown"){if(r<6)go(cs[i+1])}else if(e.key==="ArrowLeft")go(cs[i-7]);else if(e.key==="ArrowRight")go(cs[i+7]);else if(e.key==="Home")go(cs[r]);else if(e.key==="End")go(cs[cs.length-7+r]);else return;e.preventDefault()});
const f=requestAnimationFrame(()=>show(cur));return()=>cancelAnimationFrame(f)
}

export default function TipHeatmapGrid() {
  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": "#d97706",
          "--c2": "#fde68a",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-hm"><p className="hd"><b>Piano practice</b><span>Last 12 weeks</span></p><div className="gd show" role="group" aria-label="Piano practice"><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="34" aria-label="34 min" tabIndex={-1}></button><button type="button" className="v2" data-m="31" aria-label="31 min" tabIndex={-1}></button><button type="button" className="v1" data-m="6" aria-label="6 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v4" data-m="69" aria-label="69 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v2" data-m="21" aria-label="21 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="55" aria-label="55 min" tabIndex={-1}></button><button type="button" className="v4" data-m="63" aria-label="63 min" tabIndex={-1}></button><button type="button" className="v4" data-m="61" aria-label="61 min" tabIndex={-1}></button><button type="button" className="v2" data-m="25" aria-label="25 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v1" data-m="8" aria-label="8 min" tabIndex={-1}></button><button type="button" className="v3" data-m="46" aria-label="46 min" tabIndex={-1}></button><button type="button" className="v1" data-m="19" aria-label="19 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v3" data-m="55" aria-label="55 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v3" data-m="45" aria-label="45 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v1" data-m="7" aria-label="7 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="40" aria-label="40 min" tabIndex={-1}></button><button type="button" className="v4" data-m="75" aria-label="75 min" tabIndex={-1}></button><button type="button" className="v1" data-m="18" aria-label="18 min" tabIndex={-1}></button><button type="button" className="v1" data-m="16" aria-label="16 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v2" data-m="36" aria-label="36 min" tabIndex={-1}></button><button type="button" className="v4" data-m="70" aria-label="70 min" tabIndex={-1}></button><button type="button" className="v1" data-m="9" aria-label="9 min" tabIndex={-1}></button><button type="button" className="v2" data-m="22" aria-label="22 min" tabIndex={-1}></button><button type="button" className="v2" data-m="22" aria-label="22 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v3" data-m="50" aria-label="50 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v4" data-m="69" aria-label="69 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="58" aria-label="58 min" tabIndex={-1}></button><button type="button" className="v2" data-m="33" aria-label="33 min" tabIndex={-1}></button><button type="button" className="v3" data-m="45" aria-label="45 min" tabIndex={-1}></button><button type="button" className="v2" data-m="35" aria-label="35 min" tabIndex={-1}></button><button type="button" className="v3" data-m="57" aria-label="57 min" tabIndex={-1}></button><button type="button" className="v3" data-m="52" aria-label="52 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="54" aria-label="54 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v4" data-m="62" aria-label="62 min" tabIndex={-1}></button><button type="button" className="v3" data-m="51" aria-label="51 min" tabIndex={-1}></button><button type="button" className="v0" data-m="0" aria-label="0 min" tabIndex={-1}></button><button type="button" className="v3" data-m="53" aria-label="53 min" tabIndex={-1}></button><button type="button" className="v1" data-m="10" aria-label="10 min" tabIndex={-1}></button><button type="button" className="v2" data-m="32" aria-label="32 min" tabIndex={-1}></button><button type="button" className="v2" data-m="34" aria-label="34 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v3" data-m="58" aria-label="58 min" tabIndex={-1}></button><button type="button" className="v3" data-m="50" aria-label="50 min" tabIndex={-1}></button><button type="button" className="v1" data-m="14" aria-label="14 min" tabIndex={-1}></button><button type="button" className="v3" data-m="43" aria-label="43 min" tabIndex={-1}></button><button type="button" className="v2" data-m="31" aria-label="31 min" tabIndex={-1}></button><button type="button" className="v3" data-m="46" aria-label="46 min" tabIndex={-1}></button><button type="button" className="v4" data-m="63" aria-label="63 min" tabIndex={-1}></button><button type="button" className="v2" data-m="38" aria-label="38 min" tabIndex={-1}></button><button type="button" className="v3" data-m="49" aria-label="49 min" tabIndex={-1}></button><button type="button" className="v2" data-m="25" aria-label="25 min" tabIndex={-1}></button><button type="button" className="v2" data-m="33" aria-label="33 min" tabIndex={-1}></button><button type="button" className="v2" data-m="37" aria-label="37 min" tabIndex={-1}></button><button type="button" className="v3" data-m="44" aria-label="44 min" tabIndex={-1}></button><button type="button" className="v4" data-m="73" aria-label="73 min" tabIndex={-1}></button><button type="button" className="v3 on" data-m="48" aria-label="48 min" tabIndex={0}></button><span className="tt" aria-hidden="true"><b>48 min</b><span>Sun, Oct 25</span></span></div><p className="lg" aria-hidden="true"><span>Less</span><i className="v0"></i><i className="v1"></i><i className="v2"></i><i className="v3"></i><i className="v4"></i><span>More</span></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.
````
