terra vidhal

Nutrition Log

Component

About

A nutrition log with a calorie ring, macro progress bars and over-goal tones, an animated meal distribution bar, keyboard meal tabs, food entries with removal, preset food search, custom quick-add fields, an over-goal banner and a daily reset.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Nutrition Log to your project and fits it to your theme.

Code

How Nutrition Log is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import {
  NutritionLog,
  type NutritionGoals,
  type NutritionItem,
  type NutritionMeal,
} from "@/components/ui/nutrition-log";

const GOALS: NutritionGoals = { calories: 2200, protein: 120, carbs: 250, fat: 70 };

const PRESETS: Omit<NutritionItem, "id">[] = [
  { name: "Oat bowl", calories: 320, protein: 12, carbs: 48, fat: 8 },
  { name: "Greek yogurt", calories: 140, protein: 18, carbs: 8, fat: 4 },
  { name: "Chicken salad", calories: 420, protein: 38, carbs: 18, fat: 22 },
  { name: "Apple", calories: 72, protein: 0, carbs: 19, fat: 0 },
  { name: "Almonds", calories: 164, protein: 6, carbs: 6, fat: 14 },
  { name: "Pasta bowl", calories: 510, protein: 19, carbs: 74, fat: 15 },
  { name: "Boiled eggs", calories: 155, protein: 13, carbs: 1, fat: 11 },
];

const MEALS: NutritionMeal[] = [
  {
    id: "breakfast",
    label: "Breakfast",
    time: "07:40",
    items: [
      { id: "b1", name: "Oat bowl", calories: 320, protein: 12, carbs: 48, fat: 8 },
      { id: "b2", name: "Greek yogurt", calories: 140, protein: 18, carbs: 8, fat: 4 },
    ],
  },
  {
    id: "lunch",
    label: "Lunch",
    time: "12:30",
    items: [{ id: "l1", name: "Chicken salad", calories: 420, protein: 38, carbs: 18, fat: 22 }],
  },
  {
    id: "snack",
    label: "Snack",
    time: "16:00",
    items: [{ id: "s1", name: "Apple", calories: 72, protein: 0, carbs: 19, fat: 0 }],
  },
  {
    id: "dinner",
    label: "Dinner",
    time: "19:15",
    items: [],
  },
];

export default function NutritionLogDemo() {
  return (
    <main className="flex min-h-screen w-full items-start justify-center bg-gradient-to-b from-muted/40 via-background to-background px-4 py-8 sm:px-6">
      <NutritionLog
        meals={MEALS}
        goals={GOALS}
        presets={PRESETS}
        title="Daily food log"
      />
    </main>
  );
}

Dependencies

More by terra vidhal

View all
  • Project Timeline

    Project Timeline

    30
  • Kanban Board

    Kanban Board

    20
  • Gravity Stars Background

    Gravity Stars Background

    20
  • Booking Calendar

    Booking Calendar

    18
  • Notification Center

    Notification Center

    16
  • Audio Waveform

    Audio Waveform

    16
  • Kpi Counter

    Kpi Counter

    16
  • Topographic Lines

    Topographic Lines

    16

Explore more

Part of PrequelUI Animate — browse the full library on 21st.dev.