dssoca docs
GitHub repository

MetricTile

Single KPI value with delta.

A labelled metric with optional prefix/suffix units and a directional delta. `trend` colours the delta by sentiment independently of the arrow `dir` (a rising error rate is negative), with an optional `deltaLabel`, an emphasis chip, a `loading` skeleton, and a `chart` snippet slot for hosting a <Sparkline>.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { MetricTile, Sparkline } from 'dssoca';
</script>

<MetricTile label="req/min" value="142" delta="12%" dir="up"
  deltaLabel="vs prev 7d">
  {#snippet chart()}
    <Sparkline data={[3, 7, 4, 9, 6, 11]} trend="auto" fluid />
  {/snippet}
</MetricTile>

Props

PropTypeDefaultDescription
labelstringRequired. Metric label.
valuestring | numberRequired. The metric value.
prefixstringLeading unit (e.g. $ / €); rendered faint.
suffixstringTrailing unit/suffix; rendered faint.
deltastringDelta text (the arrow is added from `dir`).
dir'up' | 'down''up'Arrow direction.
trend'positive' | 'negative' | 'neutral'Sentiment colour for the delta, decoupled from `dir`. Defaults so up reads positive / down negative.
deltaLabelstringComparison-period label rendered faint after the delta ("vs prev 7d").
emphasisbooleanfalseRender the delta as a soft sentiment chip (non-colour redundancy).
loadingbooleanfalseSkeleton/loading state: hides the real value behind aria-hidden bars.
chartSnippetSlot below the delta — drop in a <Sparkline> here.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.