fetaUI
GitHub

Metric Card

One number with its trend, a period switch, and the segments behind it.

FreeWeb and MobileMotion

Preview

npx shadcn add @fetaui/metric-card
Playground

Revenue

$51,612

6.8%vs previous 30 days
Sep 15Previous periodOct 14
Revenue, vs previous 30 days
DayValuePrevious
Tue, Sep 15$1,660$1,470
Wed, Sep 16$1,700$1,530
Thu, Sep 17$1,690$1,510
Fri, Sep 18$1,650$1,490
Sat, Sep 19$1,630$1,530
Sun, Sep 20$1,670$1,510
Mon, Sep 21$1,640$1,460
Tue, Sep 22$1,680$1,500
Wed, Sep 23$1,670$1,520
Thu, Sep 24$1,720$1,500
Fri, Sep 25$1,740$1,540
Sat, Sep 26$1,810$1,530
Sun, Sep 27$1,880$1,560
Mon, Sep 28$1,900$1,580
Tue, Sep 29$1,890$1,590
Wed, Sep 30$1,895$1,570
Thu, Oct 1$1,900$1,600
Fri, Oct 2$1,930$1,590
Sat, Oct 3$1,904$1,640
Sun, Oct 4$1,950$1,620
Mon, Oct 5$1,910$1,680
Tue, Oct 6$1,990$1,660
Wed, Oct 7$1,930$1,650
Thu, Oct 8$1,910$1,640
Fri, Oct 9$1,905$1,650
Sat, Oct 10$1,920$1,660
Sun, Oct 11$1,950$1,680
Mon, Oct 12$1,990$1,690
Tue, Oct 13$2,040$1,710
Wed, Oct 14$2,040$1,680
Overview

Revenue

$51,612

6.8%vs previous 30 days
Sep 15Previous periodOct 14
Revenue, vs previous 30 days
DayValuePrevious
Tue, Sep 15$1,660$1,470
Wed, Sep 16$1,700$1,530
Thu, Sep 17$1,690$1,510
Fri, Sep 18$1,650$1,490
Sat, Sep 19$1,630$1,530
Sun, Sep 20$1,670$1,510
Mon, Sep 21$1,640$1,460
Tue, Sep 22$1,680$1,500
Wed, Sep 23$1,670$1,520
Thu, Sep 24$1,720$1,500
Fri, Sep 25$1,740$1,540
Sat, Sep 26$1,810$1,530
Sun, Sep 27$1,880$1,560
Mon, Sep 28$1,900$1,580
Tue, Sep 29$1,890$1,590
Wed, Sep 30$1,895$1,570
Thu, Oct 1$1,900$1,600
Fri, Oct 2$1,930$1,590
Sat, Oct 3$1,904$1,640
Sun, Oct 4$1,950$1,620
Mon, Oct 5$1,910$1,680
Tue, Oct 6$1,990$1,660
Wed, Oct 7$1,930$1,650
Thu, Oct 8$1,910$1,640
Fri, Oct 9$1,905$1,650
Sat, Oct 10$1,920$1,660
Sun, Oct 11$1,950$1,680
Mon, Oct 12$1,990$1,690
Tue, Oct 13$2,040$1,710
Wed, Oct 14$2,040$1,680
Day

Revenue

$1,904

Sat, Oct 3 · 4% above the daily average
Sep 15Previous periodOct 14
Revenue, vs previous 30 days
DayValuePrevious
Tue, Sep 15$1,660$1,470
Wed, Sep 16$1,700$1,530
Thu, Sep 17$1,690$1,510
Fri, Sep 18$1,650$1,490
Sat, Sep 19$1,630$1,530
Sun, Sep 20$1,670$1,510
Mon, Sep 21$1,640$1,460
Tue, Sep 22$1,680$1,500
Wed, Sep 23$1,670$1,520
Thu, Sep 24$1,720$1,500
Fri, Sep 25$1,740$1,540
Sat, Sep 26$1,810$1,530
Sun, Sep 27$1,880$1,560
Mon, Sep 28$1,900$1,580
Tue, Sep 29$1,890$1,590
Wed, Sep 30$1,895$1,570
Thu, Oct 1$1,900$1,600
Fri, Oct 2$1,930$1,590
Sat, Oct 3$1,904$1,640
Sun, Oct 4$1,950$1,620
Mon, Oct 5$1,910$1,680
Tue, Oct 6$1,990$1,660
Wed, Oct 7$1,930$1,650
Thu, Oct 8$1,910$1,640
Fri, Oct 9$1,905$1,650
Sat, Oct 10$1,920$1,660
Sun, Oct 11$1,950$1,680
Mon, Oct 12$1,990$1,690
Tue, Oct 13$2,040$1,710
Wed, Oct 14$2,040$1,680
Segment

Revenue

$51,612

6.8%vs previous 30 days
Sep 15Previous periodOct 14
Revenue, vs previous 30 days
DayValuePrevious
Tue, Sep 15$1,660$1,470
Wed, Sep 16$1,700$1,530
Thu, Sep 17$1,690$1,510
Fri, Sep 18$1,650$1,490
Sat, Sep 19$1,630$1,530
Sun, Sep 20$1,670$1,510
Mon, Sep 21$1,640$1,460
Tue, Sep 22$1,680$1,500
Wed, Sep 23$1,670$1,520
Thu, Sep 24$1,720$1,500
Fri, Sep 25$1,740$1,540
Sat, Sep 26$1,810$1,530
Sun, Sep 27$1,880$1,560
Mon, Sep 28$1,900$1,580
Tue, Sep 29$1,890$1,590
Wed, Sep 30$1,895$1,570
Thu, Oct 1$1,900$1,600
Fri, Oct 2$1,930$1,590
Sat, Oct 3$1,904$1,640
Sun, Oct 4$1,950$1,620
Mon, Oct 5$1,910$1,680
Tue, Oct 6$1,990$1,660
Wed, Oct 7$1,930$1,650
Thu, Oct 8$1,910$1,640
Fri, Oct 9$1,905$1,650
Sat, Oct 10$1,920$1,660
Sun, Oct 11$1,950$1,680
Mon, Oct 12$1,990$1,690
Tue, Oct 13$2,040$1,710
Wed, Oct 14$2,040$1,680
State
Icons animation
Motion

Installation

Terminal· bash
 npx shadcn add @fetaui/metric-card

Accessibility

  • The chart is a slider whose value reads the day and amount.
  • A hidden table carries every day for screen readers.
  • A segment row uses aria-pressed.
  • The trend Badge carries a direction glyph, not only colour.

Motion

  • The line and area draw left to right over 600 ms on first view.
  • Changing the period morphs the line in 400 ms and rolls the digits.
  • The crosshair follows the pointer and snaps to the nearest day.
  • Focusing a segment fades other rows to 40% and other bars to 30% in 150 ms.
  • With reduced motion, charts appear at final values and digits swap in place.

Responsive behavior

  • 448 px on Web and 358 px on Mobile.
  • On Mobile, the period switch and segment values grow to touch size.

Performance

  • The chart width comes from one ResizeObserver, disconnected on unmount, and paths recompute only when the period or width changes.
  • Every period resamples to 30 points, so the line morphs instead of remounting.
  • The draw runs once on entering the viewport, as a clip on the SVG.

Note for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Import MetricCard from @/components/fetaui/metric-card and pass periods. Each needs value, delta, compare, current, previous, labels, from, to and segments.
  • current and labels line up by index, and events[].index points into current.
  • defaultDay and defaultSegment set the starting state, for docs. Pointer and keyboard take over from there.
  • Segments past the third share one tone. format defaults to whole dollars. Composes Card, Badge, ToggleGroup and Separator.

Related