Apple Activity Card
Activity rings inspired by Apple Watch — hover a ring to dim the rest, counts roll up in sync, and the ring pulses when it hits its goal.
Apple Activity Card
Activity rings inspired by Apple Watch — hover a ring to dim the rest, counts roll up in sync, and the ring pulses when it hits its goal.
The card displays concentric activity rings showing progress toward daily goals. Each ring draws in sequence with a staggered delay, counts roll up to match the ring progress, and when a ring reaches its goal the end cap pulses. Rings that exceed their goal continue drawing a second lap in a brighter shade with a shadowed end cap showing it passes over the first lap. Hover or focus any ring to dim the others, highlighting that activity in both the ring display and the numeric legend.
Installation
Install the component with the Craft-UI Blocks CLI — it drops apple-activity-card.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add apple-activity-cardpnpm dlx mvpblocks add apple-activity-cardyarn dlx mvpblocks add apple-activity-cardbunx mvpblocks add apple-activity-cardFile Structure
The CLI saves the component to your project's components/ui folder:
Import the default export from @/components/ui/apple-activity-card. The activity data shape is exported as ActivityData.
Usage
AppleActivityCard is a client component and every prop is optional — with no props it renders sample activity data showing Move, Exercise, and Stand rings. Drop it into any section:
"use client";
import AppleActivityCard from "@/components/ui/apple-activity-card";
export function ActivitySection() {
return <AppleActivityCard />;
}Pass your own activity data with the activities prop, ordered from outermost ring to innermost. Each ring needs a label, colors, size, current value, target, and unit:
const myActivities = [
{
label: "MOVE",
color: "#FF2D55",
colorEnd: "#FF6B8B",
size: 200,
current: 479,
target: 800,
unit: "CAL",
},
{
label: "EXERCISE",
color: "#A3F900",
colorEnd: "#C5FF4D",
size: 160,
current: 42,
target: 30,
unit: "MIN",
},
{
label: "STAND",
color: "#04C7DD",
colorEnd: "#4DDFED",
size: 120,
current: 6,
target: 12,
unit: "HR",
},
];
<AppleActivityCard activities={myActivities} />Customize the title and heading level to fit your page outline:
<AppleActivityCard
title="Today's Progress"
titleAs="h3"
activities={myActivities}
/>Use className to adjust the card's styling or width:
<AppleActivityCard
activities={myActivities}
className="max-w-2xl bg-zinc-50 dark:bg-zinc-900"
/>Theming
The card uses zinc tones for backgrounds and labels. The title is text-zinc-900 (dark:text-white), activity labels are text-zinc-600 (dark:text-zinc-400), and the track behind each ring is text-zinc-200/60 (dark:text-zinc-800/60).
Each activity ring is painted with the color and colorEnd values from its data object, creating a gradient from start to end. In light mode, neon hues are capped at 80% lightness using oklch color space to ensure they remain visible on white backgrounds. The gradient deepens instead of fading. In dark mode, the full color values are used.
Activity counts in the legend inherit their ring's color, but are darkened in light mode to meet 3:1 contrast for large text: oklch(from var(--activity-color) 0.6 c h). The unit labels are zinc-toned to stay secondary.
When a ring exceeds its goal, the second lap uses the colorEnd value for a brighter appearance with a drop shadow, matching Apple Watch's behavior.
Animations
- Ring draw: Each ring draws its arc over
1.2swith an ease-out curve, staggered180msapart so they appear in sequence. The count rolls up in sync, landing exactly on the real value when the ring completes. - Goal pulse: When a ring reaches 100%, the end cap pulses outward with a
560msanimation, scaling from1to2.4while fading from0.6opacity to0. - Overflow lap: Rings that exceed their goal continue drawing a second lap over an additional
0.6s. The overflow arc uses thecolorEndcolor with a shadowed end cap that appears to pass over the first lap. The component caps progress at three laps to keep the visualization legible. - Fade in: The entire card fades in with a
0.5sease-out when it scrolls into view. The title slides down from-12px, the rings scale up from0.96, and the legend slides in from the right. - Hover dim: When hovering or focusing a ring, all other rings fade to
25%opacity over200msease-out. The corresponding legend item remains full opacity while others fade to40%. - Reduced motion: When
prefers-reduced-motionis set, rings snap to their final state immediately with no draw animation or scale effects. Fades are preserved but slides and scales are removed.
How it works
Each ring is drawn as an SVG <circle> with stroke-dasharray and stroke-dashoffset controlling how much of the circumference is visible. The paintRing function writes progress directly to the DOM via setAttribute, bypassing React's render cycle so the animation can run at 60fps on a smooth requestAnimationFrame loop powered by Motion's animate function.
Progress is tracked in "laps" — 1.0 means the ring reached its goal. Values past the goal keep counting: 1.5 means 150% of the target. The first lap draws on the base circle, and any overflow past 1.0 draws on a second circle laid on top with a shadowed end cap that rotates with the progress angle, creating the effect of the ring passing over itself.
The count-up animation is synchronized with the ring draw: the onUpdate callback calculates an intermediate count by interpolating between 0 and the real value, proportional to the current progress. When the ring completes, the count lands exactly on the target number.
The hover system uses React state to track which ring is active. Hovering a ring's track or focusing it with the keyboard sets the active index, dimming all other rings and legend items via a CSS opacity transition. The legend items are tied to the same state, so hovering a label dims the corresponding ring.
The component uses useInView with a -40px margin to trigger animations slightly before the card fully enters the viewport, and once: true so rings don't redraw on every scroll. A ref on each ring's SVG elements lets the draw function access them directly without querying the DOM.
The count-up targets are kept in a separate ref array and passed to both the ring component and the legend, allowing the ring to write its animated count into the legend's <span> while React handles only the static layout.
Props
Prop
Type
ActivityData Object
Prop
Type
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: motion (for ring draw animations and staggered entrance).
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on