MetricCard handbook

v1.0.0 · @snowui-design-system/components

Overview

Display one dashboard metric and an optional change. This component does not fetch data or calculate changes.

When to use it

Arrange multiple MetricCard components for a dashboard; use Card for general content. The caller provides values and comparisons. Use emphasis to select the primary value and trend to describe its direction.

Quick start

<script lang="ts">  import { MetricCard } from '@snowui-design-system/components';</script> <MetricCard label="Orders" value="694" change="+22.41%" trend="positive" /><MetricCard label="Orders" value="694" change="+22.41%" trend="positive" emphasis="value" />

API

Keyword Type Default Description
label string Required Metric name
value string Required Formatted current value
change string — Formatted change; without it the current value is primary
emphasis 'value' | 'change' "change" Select the current value or change as the primary value
trend 'positive' | 'negative' | 'neutral' "neutral" Visual state of the initial sign; the caller supplies the value and its meaning
No data

Other compatible Props are inherited from Card. The component owns children, contentFill, contentHug, and scrollable.

Usage boundaries and details

Card is the actual host. Callers own layout and formatted values. Empty values display "-", real zero remains visible, and omitting change removes its region. The default background is Background/3, configurable through --snowui-metric-card-background-override. With emphasis="change", change is on the left and the current value on the right. Include a sign or text to convey direction without color alone. MetricCard does not fetch data or calculate comparisons and supports SSR.

Use in AI conversations

Use the public label, value, change, emphasis, and trend Props with caller-provided metrics. The component does not read data or trigger business actions. If the host cannot run the component and its styles, use text instead. No specific conversation host has been verified.

MetricCard style overrides

First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.

Variable Purpose and default reference
--snowui-card-background-override Background (default surface/1)
--snowui-metric-card-background-override default: var(--background-3)
No data

Design guide · Tokens · Composition

MetricCard types and states

Required Props: label, value.

Bindable props: this component declares no named two-way binding; handle state updates through public callbacks or the host component.

Inherited: Omit<ComponentProps<typeof Card>, 'children' | 'contentFill' | 'contentHug' | 'scrollable'>. See the base component’s public documentation; omitted fields are excluded.

Shared Frame API · Return to API

The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.