About
A segmented health/HP meter that fills proportionally to a value and pulses when health is low, for games, dashboards or RPG-style status displays.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Health Bar to your project and fits it to your theme.
Code
How Health Bar is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import * as React from "react";
import { HealthBar } from "@/components/ui/health-bar";
export default function HealthBarDemo() {
const [hp, setHp] = React.useState(72);
const max = 100;
return (
<div className="flex min-h-screen w-full items-center justify-center bg-background p-8 text-foreground">
<div className="flex w-full max-w-sm flex-col gap-6">
<HealthBar value={hp} max={max} />
<HealthBar value={18} max={max} label="MP" segments={10} />
<div className="flex items-center justify-center gap-3">
<button
type="button"
onClick={() => setHp((v) => Math.max(0, v - 15))}
className="rounded-md border-2 border-foreground bg-card px-3 py-1.5 font-mono text-xs uppercase tracking-wide text-foreground transition-colors hover:bg-secondary"
>
Hit -15
</button>
<button
type="button"
onClick={() => setHp((v) => Math.min(max, v + 15))}
className="rounded-md border-2 border-foreground bg-card px-3 py-1.5 font-mono text-xs uppercase tracking-wide text-foreground transition-colors hover:bg-secondary"
>
Heal +15
</button>
</div>
</div>
</div>
);
}








