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>

HTML

CSS only — static markup The exact markup the component renders, generated at build time. Use it with dssoca/vanilla.css — see Plain HTML & CSS.

html
<div class="ss-metric">
  <div class="label">Requests</div>
  <div class="val" role="status" aria-live="polite">1,204</div>
  <div class="delta positive" role="img" aria-label="increased +4.2%">
    <span aria-hidden="true">↑ +4.2%</span>
  </div>
</div>

Props

PropTypeDefaultDescription
labelstring—Required. Metric label.
valuestring | number—Required. The metric value.
prefixstring—Leading unit (e.g. $ / €); rendered faint.
suffixstring—Trailing unit/suffix; rendered faint.
deltastring—Delta 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.
deltaLabelstring—Comparison-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.
chartSnippet—Slot below the delta — drop in a <Sparkline> here.
size'sm' | 'md' | 'lg'—Per-instance size override; inherits the ancestor `data-size-variant` when unset.
↑↓ navigate · ↵ open · esc close

Keyboard shortcuts

No shortcuts registered

Shortcuts added through the dssoca registry will show up here.

Single-key shortcuts