Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Dashboard cards
Stage Bars Card
Time spent in each stage, as bars.
import { StageBarsCard } from "@/registry/vcare/ui/stage-bars-card"
export default function StageBarsCardDemo() {
return (
<StageBarsCard
className="mx-auto max-w-md"
label="Where patients wait"
format={(v) => `${v} min`}
stages={[
{ name: "Registration", value: 6 },
{ name: "Doctor", value: 22 },
{ name: "Lab", value: 14 },
{ name: "Pharmacy", value: 8 },
{ name: "Billing", value: 4 },
]}
/>
)
}Installation
npx shadcn@latest add @vcare/stage-bars-cardOr install directly from the URL: https://ui.vcarehms.com/r/stage-bars-card.json
- Add the registry items it uses: insight-card, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/stage-bars-card.tsx
import { useEffect, useState } from 'react';
import { InsightCard } from '@/registry/vcare/ui/insight-card';
import { cn } from '@/registry/vcare/lib/utils';
export interface Stage {
name: string;
value: number;
}
interface Props {
stages: Stage[];
label?: string;
action?: React.ReactNode;
/** One color fading by step instead of a color per stage. */
mono?: boolean;
/** Formats each stage's value. Share is always measured against the first stage. */
format?: (value: number) => string;
className?: string;
}
const COLORS = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)', 'var(--chart-4)', 'var(--chart-5)'];
/** The pills alone, for panels that bring their own frame. Name and value sit inside, share of the first stage on the right. */
export function StageBars({ stages, mono, format = (v) => v.toLocaleString() }: Pick<Props, 'stages' | 'mono' | 'format'>) {
const [ready, setReady] = useState(false);
useEffect(() => {
const frame = requestAnimationFrame(() => setReady(true));
return () => cancelAnimationFrame(frame);
}, []);
const top = stages[0]?.value || Math.max(...stages.map((s) => s.value), 1);
return (
<ul className="flex flex-col gap-2">
{stages.map((s, i) => {
const share = top > 0 ? s.value / top : 0;
const color = mono ? 'var(--chart-1)' : COLORS[i % COLORS.length];
return (
<li key={s.name} className="flex items-center gap-3">
<div className="relative h-10 min-w-0 flex-1 overflow-hidden rounded-full bg-secondary">
<div
className={cn('absolute inset-y-0 start-0 rounded-full transition-[width] duration-700 ease-out motion-reduce:transition-none')}
style={{
width: ready ? `${Math.max(share * 100, 4)}%` : '0%',
// A tint rather than a solid fill, so the label stays legible over any chart color in both themes.
backgroundColor: `color-mix(in oklab, ${color} ${mono ? 55 - i * (30 / Math.max(stages.length - 1, 1)) : 45}%, transparent)`,
boxShadow: `inset 3px 0 0 ${color}`,
}}
/>
<span className="absolute inset-0 flex items-center justify-between gap-3 px-4 text-sm font-medium">
<span className="truncate">{s.name}</span>
<span className="tabular-nums">{format(s.value)}</span>
</span>
</div>
<span className="w-12 shrink-0 text-end text-sm text-muted-foreground tabular-nums">{Math.round(share * 100)}%</span>
</li>
);
})}
</ul>
);
}
/** Stage bars on the standard insight tray. */
export function StageBarsCard({ stages, label, action, mono, format, className }: Props) {
return (
<InsightCard className={className} label={label} action={action}>
<StageBars stages={stages} mono={mono} format={format} />
</InsightCard>
);
}Usage
import { StageBars, StageBarsCard } from "@/components/ui/stage-bars-card"Exports
StageBars, StageBarsCard
Dependencies
@vcare/insight-card(registry)@vcare/utils(registry)
Raw item: /r/stage-bars-card.json