Health Bar
solanaui/health-barFreeComponent
A visual health/risk indicator bar that transitions from green to yellow to red based on a percentage value.
Live preview
live · rendered by the registry
Rendered by solanaui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solanaui.dev/r/health-bar.jsonSource
1import { cn } from "@/lib/utils";23interface HealthBarProps {4 value: number;5 label?: string;6 showValue?: boolean;7 className?: string;8}910const getHealthColor = (value: number) => {11 if (value >= 66) return "text-emerald-500";12 if (value >= 33) return "text-yellow-500";13 return "text-red-400";14};1516const HealthBar = ({17 value,18 label = "Health Factor",19 showValue = true,20 className,21}: HealthBarProps) => {22 const clamped = Math.max(0, Math.min(100, value));2324 return (25 <div className={cn("flex flex-col gap-2 w-full", className)}>26 <div className="flex items-center justify-between">27 <span className="text-sm text-muted-foreground">{label}</span>28 {showValue && (29 <span className={cn("text-sm font-medium", getHealthColor(clamped))}>30 {clamped.toFixed(0)}%31 </span>32 )}33 </div>34 <div className="relative h-2.5 w-full rounded-full bg-muted">35 <div36 className="absolute inset-y-0 left-0 overflow-hidden rounded-full transition-all duration-300"37 style={{ width: `${clamped}%` }}38 >39 <div40 className="h-full bg-gradient-to-r from-red-400 via-yellow-500 to-emerald-500"41 style={{ width: `${clamped > 0 ? (100 / clamped) * 100 : 100}%` }}42 />43 </div>44 </div>45 </div>46 );47};4849export type { HealthBarProps };50export { HealthBar };
Files it writes
More from solanaui
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Action Boxaction-box | solanaui | Components | Free | no deps | |
| Activity Feedactivity-feed | solanaui | Components | Free | 1 dep | |
| Address Displayaddress-display | solanaui | Components | Free | 1 dep | |
| Auth Cardauth-card | solanaui | Components | Free | no deps | |
| Leverage Sliderleverage-slider | solanaui | Components | Free | no deps | |
| NFT Cardnft-card | solanaui | Components | Free | no deps | |
| Order Bookorder-book | solanaui | Components | Free | no deps | |
| Order Formorder-form | solanaui | Components | Free | 1 dep |
