Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Display

Stat

A dashboard metric with independent direction, tone, context, and loading state.

Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.

Interactive showcase

Revenue

€48,200

12.5%this month

Orders

384

8.2%this month

Install

Run in your project
bunx --bun @getweini/cli@latest add stat

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Revenue

€48,200

12.5%this month

Orders

384

8.2%this month

Refund rate

1.8%

0.4%this month
Vue
<script setup lang="ts">
import Stat from './components/ui/stat/Stat.vue'
</script>

<template>
  <div class="grid w-full max-w-3xl gap-4 sm:grid-cols-3">
    <Stat label="Revenue" value="€48,200" change="12.5%" direction="up" description="this month" />
    <Stat label="Orders" :value="384" change="8.2%" direction="up" description="this month" />
    <Stat
      label="Refund rate"
      value="1.8%"
      change="0.4%"
      direction="down"
      tone="positive"
      description="this month"
    />
  </div>
</template>

Stat keeps a metric, optional trend, supporting text, icon slot, and loading state in one consistent dashboard surface.

When to use it

Dashboard KPI

Show one primary measure with its period-over-period change.

Operational summary

Build a responsive metric grid with matching loading geometry.

More examples

Positive decrease

Set tone independently when a downward trend is desirable.

Positive decrease
<script setup lang="ts">
import Stat from './components/ui/stat/Stat.vue'
</script>

<template>
  <Stat
    label="Refund rate"
    value="1.8%"
    change="0.4%"
    direction="down"
    tone="positive"
    description="from last month"
  />
</template>

Loading metric

Reserve the final card layout while data loads.

Loading metric
<script setup lang="ts">
import Stat from './components/ui/stat/Stat.vue'
</script>

<template>
  <Stat label="Monthly revenue" loading aria-label="Loading monthly revenue" />
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Stat

Complete API for Stat
NameType or signatureDefaultWhat it does
asprop"div" | "section" | "article" | undefined"div"Choose the HTML element or Vue component used for this control.
labelpropstring | undefinedNot setVisible or accessible name for this item.
valuepropstring | number | undefinedNot setValue represented by this control or option.
descriptionpropstring | undefinedNot setControls the description behavior of Stat.
changepropstring | undefinedNot setControls the change behavior of Stat.
directionprop"up" | "down" | "neutral" | undefined"neutral"Choose the direction in which this control lays out or moves.
toneprop"neutral" | "positive" | "negative" | undefinedNot setControls the tone behavior of Stat.
iconpropComponent | undefinedNot setIcon content shown with this control.
loadingpropboolean | undefinedNot setShow that an action is in progress and prevent repeat activation.
sizeprop"sm" | "md" | "lg" | undefined"md"Choose the visual size. Medium is the usual default where available.
iconslot(() => unknown) | undefinedOptionalContent for the icon area of Stat.
labelslot(() => unknown) | undefinedOptionalContent for the label area of Stat.
valueslot(() => unknown) | undefinedOptionalContent for the value area of Stat.
trendslot((props: { direction: NonNullable<StatProps["direction"]>; tone: string; }) => unknown) | undefinedOptionalContent for the trend area of Stat.
descriptionslot(() => unknown) | undefinedOptionalContent for the description area of Stat.
Public type definitions
Public types
// packages/frameworks/vue/components/stat/types.ts
import type { Component } from 'vue'

export interface StatProps {
  as?: 'div' | 'section' | 'article'
  label?: string
  value?: string | number
  description?: string
  change?: string
  direction?: 'up' | 'down' | 'neutral'
  tone?: 'positive' | 'negative' | 'neutral'
  icon?: Component
  loading?: boolean
  size?: 'sm' | 'md' | 'lg'
}

Implementation notes

  • direction chooses the arrow; tone chooses whether the change is positive, negative, or neutral.
  • Use the value, trend, description, and icon slots when a metric needs richer formatting than the shortcut props.

Accessibility and localization

  • Use section or article when the metric is a meaningful document region, and give a loading-only stat an accessible name.

Source contract and editing guidance