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
Charts and metrics
Metric List
A list of metrics, each with a value, change and sparkline.
import { MetricList } from "@/registry/vcare/ui/metric-list"
export default function MetricListDemo() {
return (
<MetricList
className="mx-auto max-w-md"
items={[
{ label: "New patients", value: 128, delta: 0.09, trend: [10, 12, 11, 15, 14, 18] },
{ label: "Collections", value: 384000, format: "currency", currency: "INR", delta: 0.04, trend: [40, 42, 39, 45, 47, 48] },
{ label: "No-shows", value: 11, delta: -0.2, invertDelta: true, trend: [16, 15, 14, 12, 13, 11] },
]}
/>
)
}Installation
npx shadcn@latest add @vcare/metric-listOr install directly from the URL: https://ui.vcarehms.com/r/metric-list.json
- Add the registry items it uses: delta-badge, format, metric-value, sparkline, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/metric-list.tsx
'use client';
import * as React from 'react';
import { cn } from '@/registry/vcare/lib/utils';
import { type NumberFormat } from '@/registry/vcare/lib/format';
import { DeltaBadge, getDeltaDirection } from '@/registry/vcare/ui/delta-badge';
import { Sparkline } from '@/registry/vcare/ui/sparkline';
import { MetricValue } from '@/registry/vcare/ui/metric-value';
export interface MetricListItem {
label: string;
value: number | string;
delta?: number;
trend?: number[];
format?: NumberFormat;
currency?: string;
invertDelta?: boolean;
icon?: React.ReactNode;
key?: string;
}
export interface MetricListProps extends React.ComponentProps<'div'> {
items: MetricListItem[];
/** Sparkline variant. */
variant?: 'area' | 'line';
/** Sparkline area fill. */
fill?: 'gradient' | 'dots';
showDivider?: boolean;
}
/** Compact rows of label, sparkline, value, and delta. */
function MetricList({ items, variant = 'line', fill, showDivider = true, className, ...props }: MetricListProps) {
return (
<div data-slot="metric-list" className={cn('flex flex-col', showDivider && 'divide-y', className)} {...props}>
{items.map((item) => {
const direction = getDeltaDirection(item.delta);
const positive = direction === 'flat' ? null : (direction === 'up') !== Boolean(item.invertDelta);
const color = positive === true ? 'var(--color-emerald-500)' : positive === false ? 'var(--color-red-500)' : 'var(--muted-foreground)';
return (
<div key={item.key ?? item.label} data-slot="metric-list-row" className="flex items-center gap-4 py-2.5 text-sm first:pt-0 last:pb-0">
<div className="flex min-w-0 flex-1 items-center gap-2">
{item.icon ? <span className="text-muted-foreground shrink-0 [&>svg]:size-4">{item.icon}</span> : null}
<span className="truncate">{item.label}</span>
</div>
{item.trend && item.trend.length > 1 ? (
<Sparkline data={item.trend} variant={variant} fill={fill} color={color} className="h-6 w-20 shrink-0" />
) : null}
<div className="flex w-28 shrink-0 items-center justify-end gap-2 tabular-nums">
<MetricValue value={item.value} format={item.format} currency={item.currency} className="font-medium" />
{item.delta !== undefined ? <DeltaBadge delta={item.delta} invert={item.invertDelta} variant="text" showIcon={false} /> : null}
</div>
</div>
);
})}
</div>
);
}
export { MetricList };Usage
import { MetricList } from "@/components/ui/metric-list"Exports
MetricList
Dependencies
@vcare/delta-badge(registry)@vcare/format(registry)@vcare/metric-value(registry)@vcare/sparkline(registry)@vcare/utils(registry)
Raw item: /r/metric-list.json