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
Most Active Days Card
Which days of the week are most active, as rings.
import { useState } from "react"
import { MostActiveDaysCard } from "@/registry/vcare/ui/most-active-days-card"
export default function MostActiveDaysCardDemo() {
const [month, setMonth] = useState(() => new Date())
const [selected, setSelected] = useState<Date | null>(null)
return (
<MostActiveDaysCard
className="mx-auto max-w-md"
month={month}
onMonthChange={setMonth}
selected={selected}
onSelect={setSelected}
total="18 days"
getDay={(d) => (d > new Date() ? undefined : [((d.getDate() * 7) % 10) / 10, ((d.getDate() * 3) % 10) / 10, 0.6])}
/>
)
}Installation
npx shadcn@latest add @vcare/most-active-days-cardOr install directly from the URL: https://ui.vcarehms.com/r/most-active-days-card.json
- Install the dependencies:
npm i date-fns - Add the registry items it uses: activity-rings, calendar-locale, i18n, insight-card, range-switcher, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/most-active-days-card.tsx
import { addDays, eachDayOfInterval, endOfMonth, format, isSameDay, startOfMonth, startOfWeek } from 'date-fns';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { InsightCard } from '@/registry/vcare/ui/insight-card';
import { RangeSwitcher, monthLabel, shiftMonth } from '@/registry/vcare/ui/range-switcher';
import { ActivityRings } from '@/registry/vcare/ui/activity-rings';
import { calendarLocale } from '@/registry/vcare/lib/calendar-locale';
import { cn } from '@/registry/vcare/lib/utils';
interface Props {
month: Date;
onMonthChange: (month: Date) => void;
/** Goal progress per ring for a day (1 = goal met), or nothing for a day without data. */
getDay: (date: Date) => number[] | undefined;
selected?: Date | null;
onSelect?: (date: Date) => void;
/** Headline total for the month. */
total?: string;
unit?: string;
className?: string;
}
/** A month grid where each day carries a tiny set of goal rings. Clicking a day selects it for a rings card beside it. */
export function MostActiveDaysCard({ month, onMonthChange, getDay, selected, onSelect, total, unit, className }: Props) {
const { t, i18n } = useTranslation();
const locale = calendarLocale(i18n.language);
const first = startOfMonth(month);
const lead = (first.getDay() + 6) % 7; // Monday first
const days = eachDayOfInterval({ start: first, end: endOfMonth(month) });
const weekdays = Array.from({ length: 7 }, (_, i) => format(addDays(startOfWeek(first, { weekStartsOn: 1 }), i), 'EEEEE', { locale }));
const today = new Date();
return (
<InsightCard
className={className}
label={t('activeDays.title', { defaultValue: 'Most active days' })}
value={total}
unit={unit}
action={
<RangeSwitcher
label={monthLabel(month, i18n.language)}
onPrevious={() => onMonthChange(shiftMonth(month, -1))}
onNext={() => onMonthChange(shiftMonth(month, 1))}
/>
}
>
<div className="rounded-2xl bg-secondary p-3">
<div className="mb-1 grid grid-cols-7 text-center text-xs text-muted-foreground">
{weekdays.map((w, i) => (
<span key={i}>{w}</span>
))}
</div>
<div role="grid" className="grid grid-cols-7 gap-y-2 text-center">
{Array.from({ length: lead }, (_, i) => (
<span key={`b${i}`} />
))}
{days.map((d) => {
const progress = getDay(d);
const isSelected = !!selected && isSameDay(d, selected);
return (
<button
key={d.toISOString()}
type="button"
disabled={!progress}
aria-pressed={isSelected}
aria-label={format(d, 'PPP', { locale })}
onClick={() => onSelect?.(d)}
className={cn(
'mx-auto flex flex-col items-center gap-1 rounded-xl px-1 py-1 outline-none transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none',
isSelected && 'bg-muted',
)}
>
<span className={cn('text-xs tabular-nums', isSameDay(d, today) ? 'font-semibold text-primary' : 'text-foreground')}>
{d.getDate()}
</span>
{progress ? (
<ActivityRings size={26} thickness={3} gap={1} rings={progress.map((value, i) => ({ label: String(i), value, max: 1 }))} />
) : (
<span className="size-[26px]" />
)}
</button>
);
})}
</div>
</div>
</InsightCard>
);
}Usage
import { MostActiveDaysCard } from "@/components/ui/most-active-days-card"Exports
MostActiveDaysCard
Dependencies
date-fns@^4.4.0(npm)@vcare/activity-rings(registry)@vcare/calendar-locale(registry)@vcare/i18n(registry)@vcare/insight-card(registry)@vcare/range-switcher(registry)@vcare/utils(registry)
Raw item: /r/most-active-days-card.json