Vector Motion
Medical

Length of Stay Card - Hospital Performance

Monitor patient length of stay and discharge planning. Track LOS trends and efficiency metrics.

Length of Stay Card

The Length of Stay Card Monitor average patient length of stay metrics.

Preview

Installation

ash npx shadcn@latest add https://vectormotion.vercel.app/registry/length-of-stay-card.json

Length of Stay Card
'use client'import React from 'react';import { BedDouble, TrendingUp } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";function cn(...inputs: ClassValue[]) {   return twMerge(clsx(inputs));}interface LengthOfStayCardProps {   className?: string;   title?: string;   subtitle?: string;   avgLengthOfStay?: number;   targetGoal?: number;   progressPercentage?: number;}const DEFAULT_TITLE = "ALOS";const DEFAULT_SUBTITLE = "Avg Length of Stay";const DEFAULT_AVG_LENGTH_OF_STAY = 4.2;const DEFAULT_TARGET_GOAL = 3.8;export const LengthOfStayCard: React.FC<LengthOfStayCardProps> = ({   className = "",   title = DEFAULT_TITLE,   subtitle = DEFAULT_SUBTITLE,   avgLengthOfStay = DEFAULT_AVG_LENGTH_OF_STAY,   targetGoal = DEFAULT_TARGET_GOAL,   progressPercentage, // Helper to calculate if not provided}) => {   const isInteractive = true;   const index = 15;   // Calculate progress if not provided (inverse relationship: lower is better/closer to target)   // Simple visualization logic: map relative difference to percentage   const calculatedProgress = progressPercentage ?? Math.min(100, Math.max(0, (targetGoal / avgLengthOfStay) * 100));   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-indigo-300 dark:hover:border-indigo-700 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-indigo-500"></span>                     </span>                     <p className="text-sm text-muted-foreground font-medium">                        {subtitle}                     </p>                  </div>               </div>               <div className="rounded-xl bg-indigo-50 dark:bg-indigo-900/20 p-2.5 text-indigo-500 dark:text-indigo-400 flex items-center justify-center ring-1 ring-indigo-100 dark:ring-indigo-800">                  <BedDouble className="h-5 w-5" />               </div>            </div>            <div className="flex-1 flex flex-col justify-between">               <div>                  <div className="flex items-baseline gap-2 mb-2">                     <span className="text-4xl font-bold text-foreground tracking-tighter">{avgLengthOfStay}</span>                     <span className="text-sm font-medium text-muted-foreground">days</span>                  </div>               </div>               <div className="space-y-2">                  <div className="relative pt-4">                     <div className="absolute top-0 left-[75%] -translate-x-1/2 flex flex-col items-center">                        <span className="text-[10px] font-bold text-muted-foreground mb-1">Target</span>                        <div className="h-2 w-0.5 bg-zinc-300 dark:bg-zinc-700" />                     </div>                     <div className="w-full bg-zinc-100 dark:bg-zinc-800 rounded-full h-3 overflow-hidden">                        <motion.div                           initial={{ width: 0 }}                           animate={{ width: `${calculatedProgress}%` }}                           transition={{ duration: 1 }}                           className="bg-indigo-500 h-full rounded-full"                        />                     </div>                  </div>                  <div className="flex justify-between items-center bg-indigo-50 dark:bg-indigo-900/10 p-2 rounded-lg text-xs">                     <span className="font-medium text-indigo-900 dark:text-indigo-100">Target Goal</span>                     <span className="font-bold text-indigo-600 dark:text-indigo-400">{targetGoal} Days</span>                  </div>               </div>            </div>         </div>      </motion.div>   );};

Usage

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

Prop

Type