Stat Card
A recipe: one figure, how it changed and whether that is good news — a Card holding a description list, its numbers written by a Number Ticker. No component of its own.
Usage
Usage
import { Component, ViewEncapsulation } from '@angular/core';import { ScCard, ScCardBody, ScNumberTicker } from '@semantic-components/ui';
interface Stat { readonly label: string; readonly value: number; readonly format: Intl.NumberFormatOptions; readonly change: number; readonly changeFormat: Intl.NumberFormatOptions; /** The way that is good news: up (revenue), or down (costs). */How it is made
A Card's body holds a dl: the label is the dt, the value and the change are dds. Each number is a Number Ticker, written by Intl in the locale with your format — currency, percent, compact — and counting to its value as the card appears. The change takes signDisplay: 'exceptZero' (+20.1%, −4.3%, 0); its colour is yours, from whether the change is good news: up for revenue, down for costs.
import { ScCard, ScCardBody, ScNumberTicker } from '@semantic-components/ui';<div scCard> <div scCardBody> <dl> <dt>Revenue</dt> <dd><span scNumberTicker [value]="45231.89" [format]="{ style: 'currency', currency: 'USD' }"></span></dd> <dd class="text-success"> <span scNumberTicker [value]="0.201" [format]="{ style: 'percent', signDisplay: 'exceptZero' }"></span> from last month </dd> </dl> </div></div>Accessibility
- A description list: the label names the value and the change. Screen readers get each number's value, never the numbers on the way.
- The sign is read («plus 20.1 percent»); colour alone says good or bad — say it in words too where it matters (a sr-only «good»).
Examples
Dashboard
import { Component, ViewEncapsulation } from '@angular/core';import { ScCard, ScCardBody, ScNumberTicker } from '@semantic-components/ui';import { SiActivityIcon, SiCreditCardIcon, SiDollarSignIcon, SiUsersIcon,} from '@semantic-icons/lucide-icons';
interface Stat {Good news
import { Component, ViewEncapsulation } from '@angular/core';import { ScCard, ScCardBody, ScNumberTicker } from '@semantic-components/ui';
interface Stat { readonly label: string; readonly value: number; readonly format: Intl.NumberFormatOptions; readonly change: number; readonly changeFormat: Intl.NumberFormatOptions; /** The way that is good news: up (revenue), or down (costs). */RTL
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScCard, ScCardBody, ScNumberTicker } from '@semantic-components/ui';
interface Stat { readonly label: string; readonly value: number; readonly format: Intl.NumberFormatOptions; readonly change: number; readonly changeFormat: Intl.NumberFormatOptions;