# Nutrition facts label with servings

> A packaging nutrition table with label typography: change the number of servings and the figures roll to the new values.

- Category: [Cards](https://library.aimran.es/components/cards)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-card-nutrition-label
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Food labels are a strong typographic system: condensed heavy titles, thick rules and tabular numbers. This card follows it with a semantic table, a serving stepper with disabled limits and figures that count up or down with an eased animation, plus a round sticker for a claim. It works for recipe sites, food brands, meal planners and product pages.

The main color is the ink of rules and text, the second the sticker. Edit the nutrients with their value per serving and reference intake, and change the serving size in the label.

## Code

### HTML

```html
<article class="uvq07-nut"><h3>Nutrition facts</h3><p class="pd">Oat and cocoa granola</p><div class="sv"><span>40 g servings</span><div class="stp"><button type="button" class="mn" aria-label="Remove a serving" disabled>−</button><output aria-live="polite">1</output><button type="button" class="pl" aria-label="Add a serving">+</button></div></div><table><thead><tr><th scope="col"><span class="sr">Nutrient</span></th><th scope="col">Amount</th><th scope="col">%RI*</th></tr></thead><tbody><tr><th scope="row">Energy</th><td><b data-v="176" data-d="0">176</b> kcal</td><td data-ir="9">9 %</td></tr><tr><th scope="row">Fat</th><td><b data-v="6.4" data-d="1">6,4</b> g</td><td data-ir="9">9 %</td></tr><tr class="sb"><th scope="row">of which saturates</th><td><b data-v="1.2" data-d="1">1,2</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Carbohydrate</th><td><b data-v="24" data-d="1">24,0</b> g</td><td data-ir="9">9 %</td></tr><tr class="sb"><th scope="row">of which sugars</th><td><b data-v="5.6" data-d="1">5,6</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Fibre</th><td><b data-v="4.4" data-d="1">4,4</b> g</td><td data-ir="0"></td></tr><tr><th scope="row">Protein</th><td><b data-v="5.2" data-d="1">5,2</b> g</td><td data-ir="10">10 %</td></tr><tr><th scope="row">Salt</th><td><b data-v="0.08" data-d="2">0,08</b> g</td><td data-ir="1">1 %</td></tr></tbody></table><p class="ft">*Reference intake of an average adult (8400 kJ / 2000 kcal).</p><span class="bd" aria-hidden="true">High in fibre</span></article>
```

### CSS

```css
.uvq07-nut {
  --c1: #141414;
  --c2: #ffd23f;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq07-nut {
  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: 16em;
  padding: 1em 1.1em 1.1em;
  border-radius: .5em;
  font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
  color: var(--c1);
  background: #fffefb;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1.2em 2em -1.2em rgba(0,0,0,.5);
}

.uvq07-nut h3 {
  margin: 0;
  padding-right: 2.6em;
  font-size: 1.45em;
  font-weight: 900;
  font-stretch: condensed;
  letter-spacing: -.03em;
  line-height: 1;
}

.uvq07-nut .pd {
  margin: .35em 0 .5em;
  font-size: .78em;
}

.uvq07-nut .sv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45em 0;
  border-top: .5em solid var(--c1);
  border-bottom: 1px solid var(--c1);
  font-size: .8em;
  font-weight: 700;
}

.uvq07-nut .stp {
  display: flex;
  align-items: center;
  gap: .2em;
}

.uvq07-nut .stp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--c1);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq07-nut .stp button:hover:not(:disabled) {
  color: #fffefb;
  background: var(--c1);
}

.uvq07-nut .stp button:active:not(:disabled) {
  transform: scale(.86);
}

.uvq07-nut .stp button:disabled {
  opacity: .3;
  cursor: default;
}

.uvq07-nut .stp button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq07-nut output {
  min-width: 1.6em;
  text-align: center;
  font-size: 1.3em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut table {
  width: 100%;
  border-collapse: collapse;
  font-size: .74em;
}

.uvq07-nut thead th {
  padding: .35em 0;
  font-size: .85em;
  font-weight: 700;
  text-align: right;
  border-bottom: .25em solid var(--c1);
}

.uvq07-nut thead th:first-child {
  text-align: left;
}

.uvq07-nut tr {
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 35%,transparent);
}

.uvq07-nut tbody th {
  padding: .3em 0;
  text-align: left;
  font-weight: 800;
}

.uvq07-nut tr.sb th {
  padding-left: 1em;
  font-weight: 400;
}

.uvq07-nut td {
  padding: .3em 0 .3em .6em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut td b {
  font-weight: 800;
}

.uvq07-nut tbody tr:last-child {
  border-bottom: .5em solid var(--c1);
}

.uvq07-nut .ft {
  margin: .6em 0 0;
  font-size: .58em;
  line-height: 1.35;
  opacity: .8;
}

.uvq07-nut .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq07-nut .bd {
  position: absolute;
  right: -.7em;
  top: -.9em;
  display: grid;
  place-items: center;
  width: 4.6em;
  height: 4.6em;
  box-sizing: border-box;
  padding: .5em;
  border-radius: 50%;
  text-align: center;
  font-size: .66em;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  color: #1a1a1a;
  background: var(--c2);
  transform: rotate(12deg);
  box-shadow: 0 .3em .6em -.2em rgba(0,0,0,.35),inset 0 0 0 .25em rgba(255,255,255,.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq07-nut:hover .bd {
  transform: rotate(4deg) scale(1.06);
}

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

### JavaScript

```js
document.querySelectorAll(".uvq07-nut").forEach(el => {
  const o=el.querySelector("output"),mn=el.querySelector(".mn"),pl=el.querySelector(".pl"),vs=[...el.querySelectorAll("b[data-v]")],irs=[...el.querySelectorAll("td[data-ir]")],sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let n=1,raf=0;
const fmt=(v,d)=>v.toFixed(d).replace(".",",");
const set=m=>{const from=n;n=Math.max(1,Math.min(6,m));if(n===from)return;o.textContent=String(n);mn.disabled=n===1;pl.disabled=n===6;cancelAnimationFrame(raf);const t0=performance.now(),D=450/sp;
const f=now=>{const p=Math.min(1,(now-t0)/D),e=1-Math.pow(1-p,3),q=from+(n-from)*e;vs.forEach(b=>{b.textContent=fmt(+b.dataset.v*q,+b.dataset.d)});irs.forEach(t=>{const ir=+t.dataset.ir;if(ir>0)t.textContent=Math.round(ir*q)+" %"});if(p<1)raf=requestAnimationFrame(f)};raf=requestAnimationFrame(f)};
mn.addEventListener("click",()=>set(n-1));pl.addEventListener("click",()=>set(n+1));return()=>cancelAnimationFrame(raf)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq07-nut {
  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: 16em;
  padding: 1em 1.1em 1.1em;
  border-radius: .5em;
  font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
  color: var(--c1);
  background: #fffefb;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1.2em 2em -1.2em rgba(0,0,0,.5);
}

.uvq07-nut h3 {
  margin: 0;
  padding-right: 2.6em;
  font-size: 1.45em;
  font-weight: 900;
  font-stretch: condensed;
  letter-spacing: -.03em;
  line-height: 1;
}

.uvq07-nut .pd {
  margin: .35em 0 .5em;
  font-size: .78em;
}

.uvq07-nut .sv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45em 0;
  border-top: .5em solid var(--c1);
  border-bottom: 1px solid var(--c1);
  font-size: .8em;
  font-weight: 700;
}

.uvq07-nut .stp {
  display: flex;
  align-items: center;
  gap: .2em;
}

.uvq07-nut .stp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--c1);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq07-nut .stp button:hover:not(:disabled) {
  color: #fffefb;
  background: var(--c1);
}

.uvq07-nut .stp button:active:not(:disabled) {
  transform: scale(.86);
}

.uvq07-nut .stp button:disabled {
  opacity: .3;
  cursor: default;
}

.uvq07-nut .stp button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq07-nut output {
  min-width: 1.6em;
  text-align: center;
  font-size: 1.3em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut table {
  width: 100%;
  border-collapse: collapse;
  font-size: .74em;
}

.uvq07-nut thead th {
  padding: .35em 0;
  font-size: .85em;
  font-weight: 700;
  text-align: right;
  border-bottom: .25em solid var(--c1);
}

.uvq07-nut thead th:first-child {
  text-align: left;
}

.uvq07-nut tr {
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 35%,transparent);
}

.uvq07-nut tbody th {
  padding: .3em 0;
  text-align: left;
  font-weight: 800;
}

.uvq07-nut tr.sb th {
  padding-left: 1em;
  font-weight: 400;
}

.uvq07-nut td {
  padding: .3em 0 .3em .6em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut td b {
  font-weight: 800;
}

.uvq07-nut tbody tr:last-child {
  border-bottom: .5em solid var(--c1);
}

.uvq07-nut .ft {
  margin: .6em 0 0;
  font-size: .58em;
  line-height: 1.35;
  opacity: .8;
}

.uvq07-nut .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq07-nut .bd {
  position: absolute;
  right: -.7em;
  top: -.9em;
  display: grid;
  place-items: center;
  width: 4.6em;
  height: 4.6em;
  box-sizing: border-box;
  padding: .5em;
  border-radius: 50%;
  text-align: center;
  font-size: .66em;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  color: #1a1a1a;
  background: var(--c2);
  transform: rotate(12deg);
  box-shadow: 0 .3em .6em -.2em rgba(0,0,0,.35),inset 0 0 0 .25em rgba(255,255,255,.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq07-nut:hover .bd {
  transform: rotate(4deg) scale(1.06);
}

@media (prefers-reduced-motion:reduce) {
  .uvq07-nut,.uvq07-nut *,.uvq07-nut *::before,.uvq07-nut *::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 o=el.querySelector("output"),mn=el.querySelector(".mn"),pl=el.querySelector(".pl"),vs=[...el.querySelectorAll("b[data-v]")],irs=[...el.querySelectorAll("td[data-ir]")],sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let n=1,raf=0;
const fmt=(v,d)=>v.toFixed(d).replace(".",",");
const set=m=>{const from=n;n=Math.max(1,Math.min(6,m));if(n===from)return;o.textContent=String(n);mn.disabled=n===1;pl.disabled=n===6;cancelAnimationFrame(raf);const t0=performance.now(),D=450/sp;
const f=now=>{const p=Math.min(1,(now-t0)/D),e=1-Math.pow(1-p,3),q=from+(n-from)*e;vs.forEach(b=>{b.textContent=fmt(+b.dataset.v*q,+b.dataset.d)});irs.forEach(t=>{const ir=+t.dataset.ir;if(ir>0)t.textContent=Math.round(ir*q)+" %"});if(p<1)raf=requestAnimationFrame(f)};raf=requestAnimationFrame(f)};
mn.addEventListener("click",()=>set(n-1));pl.addEventListener("click",()=>set(n+1));return()=>cancelAnimationFrame(raf)
}

export default function CardNutritionLabel() {
  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": "#141414",
          "--c2": "#ffd23f",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uvq07-nut"><h3>Nutrition facts</h3><p className="pd">Oat and cocoa granola</p><div className="sv"><span>40 g servings</span><div className="stp"><button type="button" className="mn" aria-label="Remove a serving" disabled={true}>−</button><output aria-live="polite">1</output><button type="button" className="pl" aria-label="Add a serving">+</button></div></div><table><thead><tr><th scope="col"><span className="sr">Nutrient</span></th><th scope="col">Amount</th><th scope="col">%RI*</th></tr></thead><tbody><tr><th scope="row">Energy</th><td><b data-v="176" data-d="0">176</b> kcal</td><td data-ir="9">9 %</td></tr><tr><th scope="row">Fat</th><td><b data-v="6.4" data-d="1">6,4</b> g</td><td data-ir="9">9 %</td></tr><tr className="sb"><th scope="row">of which saturates</th><td><b data-v="1.2" data-d="1">1,2</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Carbohydrate</th><td><b data-v="24" data-d="1">24,0</b> g</td><td data-ir="9">9 %</td></tr><tr className="sb"><th scope="row">of which sugars</th><td><b data-v="5.6" data-d="1">5,6</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Fibre</th><td><b data-v="4.4" data-d="1">4,4</b> g</td><td data-ir="0"></td></tr><tr><th scope="row">Protein</th><td><b data-v="5.2" data-d="1">5,2</b> g</td><td data-ir="10">10 %</td></tr><tr><th scope="row">Salt</th><td><b data-v="0.08" data-d="2">0,08</b> g</td><td data-ir="1">1 %</td></tr></tbody></table><p className="ft">*Reference intake of an average adult (8400 kJ / 2000 kcal).</p><span className="bd" aria-hidden="true">High in fibre</span></article>
      </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 “Nutrition facts label with servings” block (Cards) from AIMRAN Library to my project.

## What it is
A packaging nutrition table with label typography: change the number of servings and the figures roll to the new values.

## Chosen settings
- Main color: #141414
- Secondary color: #ffd23f
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Granola de avena y cacao"

## 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 = `
.uvq07-nut {
  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: 16em;
  padding: 1em 1.1em 1.1em;
  border-radius: .5em;
  font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
  color: var(--c1);
  background: #fffefb;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1.2em 2em -1.2em rgba(0,0,0,.5);
}

.uvq07-nut h3 {
  margin: 0;
  padding-right: 2.6em;
  font-size: 1.45em;
  font-weight: 900;
  font-stretch: condensed;
  letter-spacing: -.03em;
  line-height: 1;
}

.uvq07-nut .pd {
  margin: .35em 0 .5em;
  font-size: .78em;
}

.uvq07-nut .sv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45em 0;
  border-top: .5em solid var(--c1);
  border-bottom: 1px solid var(--c1);
  font-size: .8em;
  font-weight: 700;
}

.uvq07-nut .stp {
  display: flex;
  align-items: center;
  gap: .2em;
}

.uvq07-nut .stp button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--c1);
  transition: transform calc(0.2s / var(--k)) cubic-bezier(.34,1.56,.64,1),background calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.15s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq07-nut .stp button:hover:not(:disabled) {
  color: #fffefb;
  background: var(--c1);
}

.uvq07-nut .stp button:active:not(:disabled) {
  transform: scale(.86);
}

.uvq07-nut .stp button:disabled {
  opacity: .3;
  cursor: default;
}

.uvq07-nut .stp button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

.uvq07-nut output {
  min-width: 1.6em;
  text-align: center;
  font-size: 1.3em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut table {
  width: 100%;
  border-collapse: collapse;
  font-size: .74em;
}

.uvq07-nut thead th {
  padding: .35em 0;
  font-size: .85em;
  font-weight: 700;
  text-align: right;
  border-bottom: .25em solid var(--c1);
}

.uvq07-nut thead th:first-child {
  text-align: left;
}

.uvq07-nut tr {
  border-bottom: 1px solid color-mix(in srgb,var(--c1) 35%,transparent);
}

.uvq07-nut tbody th {
  padding: .3em 0;
  text-align: left;
  font-weight: 800;
}

.uvq07-nut tr.sb th {
  padding-left: 1em;
  font-weight: 400;
}

.uvq07-nut td {
  padding: .3em 0 .3em .6em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.uvq07-nut td b {
  font-weight: 800;
}

.uvq07-nut tbody tr:last-child {
  border-bottom: .5em solid var(--c1);
}

.uvq07-nut .ft {
  margin: .6em 0 0;
  font-size: .58em;
  line-height: 1.35;
  opacity: .8;
}

.uvq07-nut .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq07-nut .bd {
  position: absolute;
  right: -.7em;
  top: -.9em;
  display: grid;
  place-items: center;
  width: 4.6em;
  height: 4.6em;
  box-sizing: border-box;
  padding: .5em;
  border-radius: 50%;
  text-align: center;
  font-size: .66em;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
  color: #1a1a1a;
  background: var(--c2);
  transform: rotate(12deg);
  box-shadow: 0 .3em .6em -.2em rgba(0,0,0,.35),inset 0 0 0 .25em rgba(255,255,255,.35);
  transition: transform calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq07-nut:hover .bd {
  transform: rotate(4deg) scale(1.06);
}

@media (prefers-reduced-motion:reduce) {
  .uvq07-nut,.uvq07-nut *,.uvq07-nut *::before,.uvq07-nut *::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 o=el.querySelector("output"),mn=el.querySelector(".mn"),pl=el.querySelector(".pl"),vs=[...el.querySelectorAll("b[data-v]")],irs=[...el.querySelectorAll("td[data-ir]")],sp=parseFloat(getComputedStyle(el).getPropertyValue("--k"))||1;let n=1,raf=0;
const fmt=(v,d)=>v.toFixed(d).replace(".",",");
const set=m=>{const from=n;n=Math.max(1,Math.min(6,m));if(n===from)return;o.textContent=String(n);mn.disabled=n===1;pl.disabled=n===6;cancelAnimationFrame(raf);const t0=performance.now(),D=450/sp;
const f=now=>{const p=Math.min(1,(now-t0)/D),e=1-Math.pow(1-p,3),q=from+(n-from)*e;vs.forEach(b=>{b.textContent=fmt(+b.dataset.v*q,+b.dataset.d)});irs.forEach(t=>{const ir=+t.dataset.ir;if(ir>0)t.textContent=Math.round(ir*q)+" %"});if(p<1)raf=requestAnimationFrame(f)};raf=requestAnimationFrame(f)};
mn.addEventListener("click",()=>set(n-1));pl.addEventListener("click",()=>set(n+1));return()=>cancelAnimationFrame(raf)
}

export default function CardNutritionLabel() {
  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": "#141414",
          "--c2": "#ffd23f",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uvq07-nut"><h3>Nutrition facts</h3><p className="pd">Oat and cocoa granola</p><div className="sv"><span>40 g servings</span><div className="stp"><button type="button" className="mn" aria-label="Remove a serving" disabled={true}>−</button><output aria-live="polite">1</output><button type="button" className="pl" aria-label="Add a serving">+</button></div></div><table><thead><tr><th scope="col"><span className="sr">Nutrient</span></th><th scope="col">Amount</th><th scope="col">%RI*</th></tr></thead><tbody><tr><th scope="row">Energy</th><td><b data-v="176" data-d="0">176</b> kcal</td><td data-ir="9">9 %</td></tr><tr><th scope="row">Fat</th><td><b data-v="6.4" data-d="1">6,4</b> g</td><td data-ir="9">9 %</td></tr><tr className="sb"><th scope="row">of which saturates</th><td><b data-v="1.2" data-d="1">1,2</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Carbohydrate</th><td><b data-v="24" data-d="1">24,0</b> g</td><td data-ir="9">9 %</td></tr><tr className="sb"><th scope="row">of which sugars</th><td><b data-v="5.6" data-d="1">5,6</b> g</td><td data-ir="6">6 %</td></tr><tr><th scope="row">Fibre</th><td><b data-v="4.4" data-d="1">4,4</b> g</td><td data-ir="0"></td></tr><tr><th scope="row">Protein</th><td><b data-v="5.2" data-d="1">5,2</b> g</td><td data-ir="10">10 %</td></tr><tr><th scope="row">Salt</th><td><b data-v="0.08" data-d="2">0,08</b> g</td><td data-ir="1">1 %</td></tr></tbody></table><p className="ft">*Reference intake of an average adult (8400 kJ / 2000 kcal).</p><span className="bd" aria-hidden="true">High in fibre</span></article>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
