Skip to main content

Documentation Index

Fetch the complete documentation index at: https://araf.badr.co.id/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Metric Cards are used to display key quantitative data on dashboards. Each card shows one primary metric, equipped with a trend indicator (positive/negative), and an optional action button to view a detailed report.
Views 24 hours
2,000
↑ 100
Views 24 hours
2,000
↑ 100
Views 24 hours
2,000
↗ 100%vs last month
Views 24 hours
2,000
↗ 100%vs last month

Installation

npm install @araf-ds/core

Usage

import { MetricCard } from "@araf-ds/core";

export default function Dashboard() {
  return (
    <MetricCard
      type="chart"
      label="Views 24 hours"
      value="2,000"
      trend="positive"
      change={100}
      changeLabel="vs last month"
      actions
      onViewReport={() => router.push("/reports/views")}
    />
  );
}

Type Variants

Metric Cards have 4 types that determine how the metric is visualized.
The most compact type — displays only the label, metric number, and a trend badge aligned to the bottom-right of the number. Ideal for simple metrics without additional visual context.
Views 24 hours
2,000
↑ 100
Bounce Rate
4,120
↓ 40
<MetricCard
  type="simple"
  label="Views 24 hours"
  value="2,000"
  trend="positive"
  change={100}
/>

Actions

The actions prop adds a “View report” button at the bottom of the card, which can be used to navigate to a detailed report page.

actions=false (default)

Views 24 hours
2,000
↑ 100

actions=true

Views 24 hours
2,000
↑ 100
View report →
// With action button
<MetricCard
  type="simple"
  label="Views 24 hours"
  value="2,000"
  trend="positive"
  change={100}
  actions
  onViewReport={() => router.push("/reports/views")}
/>

Trend Indicator

Every Metric Card displays a trend indicator to show the change compared to the previous period.

Badge (Simple & Icon 01)

↑ 100 Positive↓ 40 Negative
StateBackgroundTextIcon
Positive#ECFDF3 (Success/50)#027A48 (Success/700)arrow-up
Negative#FEF3F2 (Error/50)#B42318 (Error/700)arrow-down

Change Text (Icon 02 & Chart)

↗ 100% vs last month↘ 12% vs last month
StateColorIcon
Positive#16A34A (Green/07)arrow-up-right
Negative#B42318 (Error/700)arrow-down-right

Breakpoints

Card width is 388px, with 24px padding on all sides.
PropertyValue
Width388px
Padding24px
Metric number36px Inter SemiBold
Label14–16px Inter Medium
Chart128×64px
Featured icon48×48px

Design Tokens

Card

TokenValue
Background#FFFFFF
Border radius8px
Padding24px
Shadow0px 1px 3px rgba(16,24,40,0.1) + 0px 1px 2px rgba(16,24,40,0.06)

Typography

ElementFontSizeWeightColor
Label (Simple/Icon 01)Inter14px500#71717A
Label (Icon 02/Chart)Inter16px500#011829
Metric numberInter36px600#011829
Change textInter14px500#16A34A / #B42318
Context labelInter14px500#71717A
TrendBackgroundBorder
Positive#22C55E8px solid #16A34A
NegativeColor matching the metric type8px solid border (darker shade)
TrendBackgroundBorderIcon color
Positive#DBEAFE8px solid #EFF6FF#1D4ED8
Negative#FEE2E28px solid #FFF1F2#DC2626

API Reference

MetricCard

type
"simple" | "icon-01" | "icon-02" | "chart"
required
The display type of the metric card.
label
string
required
The metric label text, displayed above the number.
value
string | number
required
The primary metric value displayed large (e.g. "2,000", "89%").
trend
"positive" | "negative"
required
The direction of the metric change — determines the color and icon of the trend indicator.
change
number
required
The numeric change value (e.g. 100 → displayed as ↑ 100 or 100%).
changeLabel
string
default:"\"vs last month\""
The descriptive text for the change. Only shown on icon-02 and chart types.
icon
ReactNode
The icon displayed in the featured icon area. Required for icon-01 and icon-02 types.
chartData
number[]
Data array for the sparkline chart. Required for the chart type.
actions
boolean
default:"false"
If true, displays a “View report” button at the bottom of the card (Desktop only).
onViewReport
() => void
Callback fired when the “View report” button is clicked. Required when actions is true.
breakpoint
"desktop" | "mobile"
default:"\"desktop\""
The rendering breakpoint of the card. Mobile does not support the actions prop.
className
string
Additional class name for custom styling.

Accessibility

  • Use a descriptive aria-label on the card for screen readers, e.g. aria-label="Views 24 hours: 2,000, up 100 from the previous period"
  • Trend icons should include aria-hidden="true" since they are already represented by the change text
  • The “View report” button must have clear text or an aria-label if it only shows an icon
  • Ensure the trend badge color contrast meets WCAG AA (green #027A48 on #ECFDF3 ✓)
  • The sparkline chart should include role="img" and an aria-label describing the trend

Do’s & Don’ts

Do

  • Use one metric per card
  • Ensure changeLabel provides clear context (e.g. “vs last week”)
  • Choose the chart type for metrics with significant fluctuations that need to be visualized
  • Arrange cards in a 3–4 column grid on desktop
  • Use the icon-01 type for metrics with a clear visual category (sales, traffic, etc.)

Don't

  • Don’t display more than one large number per card
  • Don’t use the chart type for static data (with no change over time)
  • Don’t let value get too long — truncate if needed (e.g. 2.3M not 2,312,400)
  • Don’t hide the trend indicator — always provide change context
  • Don’t use actions=true without a working onViewReport handler