StealThis .dev

Cookbook — Nutrition facts panel

A clean, label-style nutrition panel for cookbook recipes with big per-serving calories, inline CSS macro bars showing the carb, protein and fat split, and a detailed nutrient table with percent Daily Values for saturated fat, fiber, sugar, sodium and more. A per-serving versus per-100g toggle recomputes every value, while a servings stepper scales totals up or down. Built with accessible table semantics, aria-live updates, warm editorial styling and a print-friendly layout.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Nutrition facts panel

A crisp, label-style nutrition panel that sits beside an editorial recipe card. Calories per serving lead in a large serif numeral, followed by a macronutrient split rendered as inline CSS bars — carbs, protein and fat each show grams plus their share of total energy. A full breakdown table lists saturated fat, fiber, sugars, sodium, calcium, iron and more, each with a color-coded percent Daily Value pill so high and low contributors read at a glance.

Two interactions keep the panel honest. A per-serving / per-100 g toggle recomputes every amount and the calorie headline from the same underlying recipe totals, and a servings stepper scales the whole pot up or down — change it to 6 and each portion shrinks accordingly. All dynamic regions are wrapped in aria-live containers, the breakdown uses real table semantics with a caption and scoped headers, and the layout collapses to a single column on small screens and strips its chrome for clean printing.

The food “photo” is pure CSS — layered radial gradients and blurred blobs framed in warm paper, accented with herb and citrus emoji — so the resource stays fully self-contained with no images or libraries.

Illustrative UI only — recipes & nutrition data are fictional, not dietary advice.