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
Steps Card
Steps per day for a week, with the goal.
import { StepsCard } from "@/registry/vcare/ui/steps-card"
const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].map((label, i) => ({ label, value: [6200, 8400, 7100, 10300, 9100, 4300, 11800][i] }))
export default function StepsCardDemo() {
return <StepsCard className="mx-auto max-w-md" days={days} goal={8000} rangeLabel="This week" onPrevious={() => undefined} onNext={() => undefined} disableNext />
}Installation
npx shadcn@latest add @vcare/steps-cardOr install directly from the URL: https://ui.vcarehms.com/r/steps-card.json
- Add the registry items it uses: i18n, insight-card, range-switcher, use-count-up, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/steps-card.tsx
import { useState } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { InsightCard } from '@/registry/vcare/ui/insight-card';
import { useCountUp } from '@/registry/vcare/ui/use-count-up';
import { RangeSwitcher } from '@/registry/vcare/ui/range-switcher';
import { cn } from '@/registry/vcare/lib/utils';
export interface StepsDay {
/** Short column label, e.g. "Mon". */
label: string;
/** Full name shown above the headline when selected, e.g. "Monday". */
fullLabel?: string;
value: number;
}
interface Props {
days: StepsDay[];
/** Daily target. Bars are scaled to the larger of this and the best day. */
goal?: number;
rangeLabel: string;
onPrevious: () => void;
onNext: () => void;
disableNext?: boolean;
unit?: string;
color?: string;
className?: string;
}
/** Weekly steps: bars on a track, the picked day outlined, headline counting up to its value. */
export function StepsCard({ days, goal = 0, rangeLabel, onPrevious, onNext, disableNext, unit, color = 'var(--chart-1)', className }: Props) {
const { t, i18n } = useTranslation();
const [picked, setPicked] = useState(0);
const index = Math.min(picked, Math.max(0, days.length - 1));
const current = days[index];
const shown = useCountUp(current?.value ?? 0);
const scale = Math.max(goal, ...days.map((d) => d.value), 1);
const fmt = new Intl.NumberFormat(i18n.language);
return (
<InsightCard
className={className}
label={current?.fullLabel ?? current?.label}
value={fmt.format(shown)}
unit={unit ?? t('steps', { defaultValue: 'steps' })}
action={<RangeSwitcher label={rangeLabel} onPrevious={onPrevious} onNext={onNext} disableNext={disableNext} />}
>
<div className="grid grid-flow-col auto-cols-fr gap-2">
{days.map((d, i) => (
<button
key={d.label}
type="button"
aria-pressed={i === index}
aria-label={`${d.fullLabel ?? d.label}, ${fmt.format(d.value)}`}
onClick={() => setPicked(i)}
className="group flex min-w-0 flex-col items-center gap-2 outline-none"
>
<span
className={cn(
'flex h-40 w-full items-end overflow-hidden rounded-2xl bg-secondary p-0 outline-offset-2 transition-[outline-color,box-shadow] duration-150',
'outline-2 outline-transparent group-hover:outline-foreground/15 group-focus-visible:outline-ring',
i === index && 'outline-foreground/25',
)}
>
<span
className="w-full rounded-2xl transition-[height] duration-500 ease-out motion-reduce:transition-none"
style={{ height: `${(d.value / scale) * 100}%`, backgroundColor: color }}
/>
</span>
<span className={cn('text-xs transition-colors', i === index ? 'font-medium text-foreground' : 'text-muted-foreground')}>{d.label}</span>
</button>
))}
</div>
</InsightCard>
);
}Usage
import { StepsCard } from "@/components/ui/steps-card"Exports
StepsCard
Dependencies
@vcare/i18n(registry)@vcare/insight-card(registry)@vcare/range-switcher(registry)@vcare/use-count-up(registry)@vcare/utils(registry)
Raw item: /r/steps-card.json