Vector Motion
Medical

Bed Occupancy Card - Hospital Operations

Track hospital bed occupancy rates across wards. Monitor bed availability and patient census.

Bed Occupancy Card

The Bed Occupancy Card Track hospital bed occupancy rates and availability across different wards.

Preview

Installation

ash npx shadcn@latest add https://vectormotion.vercel.app/registry/bed-occupancy-card.json

Bed Occupancy Card
'use client'import React from 'react';import { Bed, UserPlus, UserMinus, AlertCircle } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip } from 'recharts';function cn(...inputs: ClassValue[]) {   return twMerge(clsx(inputs));}interface OccupancyData {   name: string;   value: number;   color: string;   [key: string]: any;}interface BedOccupancyCardProps {   className?: string;   title?: string;   subtitle?: string;   occupancyRate?: number;   data?: OccupancyData[];}const DEFAULT_DATA: OccupancyData[] = [   { name: 'Occupied', value: 42, color: '#3b82f6' }, // blue-500   { name: 'Available', value: 5, color: '#10b981' }, // emerald-500   { name: 'Cleaning', value: 3, color: '#f59e0b' }, // amber-500];const DEFAULT_TITLE = "Bed Occupancy";const DEFAULT_SUBTITLE = "General Ward Capacity";const DEFAULT_OCCUPANCY_RATE = 84;export const BedOccupancyCard: React.FC<BedOccupancyCardProps> = ({   className = "",   title = DEFAULT_TITLE,   subtitle = DEFAULT_SUBTITLE,   occupancyRate = DEFAULT_OCCUPANCY_RATE,   data = DEFAULT_DATA,}) => {   const isInteractive = true;   const index = 4;   return (      <motion.div         layoutId={isInteractive ? `card-${index}-${title}` : undefined}         transition={{ duration: 0.4, ease: "easeOut" }}         className={cn(            "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all flex flex-col h-full",            isInteractive ? "hover:border-primary/50 hover:shadow-md" : "",            className         )}      >         <div className="p-5 flex flex-col h-full relative z-10">            <div className="mb-4 flex items-start justify-between">               <div>                  <h3 className="font-bold text-lg text-foreground">                     {title}                  </h3>                  <div className="flex items-center gap-1.5 mt-1">                     <span className="relative flex h-2 w-2">                        <span className="relative inline-flex rounded-full h-2 w-2 bg-blue-500"></span>                     </span>                     <p className="text-sm text-muted-foreground font-medium">                        {subtitle}                     </p>                  </div>               </div>               <div className="rounded-xl bg-blue-500/10 p-2.5 text-blue-500 flex items-center justify-center ring-1 ring-blue-100 dark:ring-blue-800">                  <Bed className="h-5 w-5" />               </div>            </div>            <div className="flex-1 flex items-center gap-4">               {/* Chart Section */}               <div className="relative h-28 w-28 flex-shrink-0">                  <ResponsiveContainer width="100%" height="100%">                     <PieChart>                        <Pie                           data={data}                           cx="50%"                           cy="50%"                           innerRadius={35}                           outerRadius={50}                           paddingAngle={4}                           dataKey="value"                        >                           {data.map((entry, index) => (                              <Cell key={`cell-${index}`} fill={entry.color} stroke="none" />                           ))}                        </Pie>                        <Tooltip                           contentStyle={{ borderRadius: '8px', border: 'none', boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)' }}                        />                     </PieChart>                  </ResponsiveContainer>                  <div className="absolute inset-0 flex flex-col items-center justify-center">                     <span className={cn(                        "text-xl font-bold",                        occupancyRate > 90 ? "text-red-500" : "text-foreground"                     )}>                        {occupancyRate}%                     </span>                  </div>               </div>               {/* Stats Legend */}               <div className="flex-1 space-y-2">                  {data.map((entry, index) => (                     <div key={index} className="flex justify-between items-center text-xs">                        <div className="flex items-center gap-2">                           <div className="h-2 w-2 rounded-full" style={{ backgroundColor: entry.color }} />                           <span className="text-muted-foreground font-medium">{entry.name}</span>                        </div>                        <span className="font-bold text-foreground">{entry.value}</span>                     </div>                  ))}               </div>            </div>            {/* Footer Alert */}            {occupancyRate > 80 && (               <div className="mt-4 flex items-center gap-2 bg-amber-50 dark:bg-amber-900/10 p-2 rounded-lg border border-amber-100 dark:border-amber-800/20">                  <AlertCircle className="h-4 w-4 text-amber-500 flex-shrink-0" />                  <p className="text-xs text-amber-700 dark:text-amber-400 font-medium">High occupancy. Consider overflow.</p>               </div>            )}         </div>      </motion.div>   );};

Usage

This component is a demo card displaying medical metrics with animated visualizations and dark mode support.

Prop

Type