Skip to content

Stat ​

Metric card: label, value, colored change, context, small chart and optional link. Numbers are formatted in the current language.

Usage ​

Value and change ​

vue
<SuStat
  label="Revenue"
  :value="48250"
  :format="{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }"
  :delta="0.124"
  delta-label="vs last month"
  :icon="BanknotesIcon"
/>

A numeric delta is a ratio formatted as a percentage: 0.124 gives "+12.4%". Pass text for another unit (delta="−18 min"): its sign gives the direction.

A favorable decrease ​

vue
<SuStat label="Response time" value="2 h 14" delta="−18 min" invert-trend />

invert-trend colors a decrease green and an increase red: costs, delays, error rates.

vue
<SuStat label="Visits" :value="18430" :delta="0.08" to="/stats/visits" :loading="pending">
  <template #chart>
    <MySparkline :data="series" />
  </template>
</SuStat>

With to or href, the whole card becomes a link: don't put other interactive elements inside it.

API ​

Props ​

PropTypeDefaultDescription
labelstring-Label
valuestring | number-Value; a number is formatted (format)
formatIntl.NumberFormatOptions-Value format
deltanumber | string-Change: ratio (0.124 → +12.4%) or text shown as is
deltaFormatIntl.NumberFormatOptionssigned percentageChange format
trend'up' | 'down' | 'neutral'sign of deltaChange direction
invertTrendbooleanfalseA decrease is good news
deltaLabelstring-Context ("vs last month")
iconComponent-Decorative icon
tostring | RouteLocationRaw-Router link (whole card)
hrefstring-Link (whole card)
loadingbooleanfalseSkeleton instead of the value, aria-busy

Slots ​

SlotDescription
valueValue content
chartSmall chart
footerBottom of the card

Accessibility ​

  • The change direction is read ("Up", "Down", "Unchanged"): color and arrow do not carry the information alone.
  • Tabular figures (font-variant-numeric): values stay aligned from one card to the next.
  • A decorative small chart should have aria-hidden="true"; if it conveys information, give it a text alternative.

Publié sous licence MIT.