Installation
Section titled “Installation”- Package
@bigbang/ui- Import
import { StatCard } from '@bigbang/ui';- Source
- StatCard.tsx
- Storybook
- StatCard · Playground
StatCard is in the @bigbang/ui package. Installation and style files are the same as for Button; see the Button code tab.
import { StatCard } from '@bigbang/ui';
<StatCard label="Total items" value="1.280" delta={{ value: '8 %', direction: 'up' }} period="vs last month"/>;The part prop types are exported too: StatCardLabelProps, StatCardValueProps, StatCardDeltaProps, StatCardPeriodProps, StatCardTrendProps, StatCardInfoProps.
label- Description
- What the number measures, such as "Total items". It names the group. Omit it when you compose
children. - Type
string
value- Description
- The figure, pre-formatted by the app with
Intl; StatCard never formats numbers.null,undefinedor an empty string shows a dash andnoDataLabel. - Type
ReactNode
delta- Description
- Change against the previous period: a pre-formatted value, its direction and an optional sentiment.
- Type
StatCardDelta
period- Description
- What the change is measured against, such as "vs last month".
- Type
string
trend- Description
- A sparkline or small chart. It is decorative and hidden from assistive technology unless the child has
role="img"or anaria-label. - Type
ReactNode
info- Description
- Help text under the figure, such as how the number is counted.
- Type
ReactNode
loading- Description
- Shows placeholders for the value and the change, marks the card
aria-busyand announcesloadingLabel. - Type
boolean- Default
false
variant- Description
- Surface of the card, passed to Card.
- Type
'outlined' | 'elevated' | 'filled'- Default
'outlined'
loadingLabel- Description
- Text read while loading. Defaults to the library string "Yükleniyor" or "Loading".
- Type
string
noDataLabel- Description
- Reason read next to the dash when there is no value. Defaults to the library string "bilgi yok" or "no information".
- Type
string
className- Description
- For layout only: margins, width and grid placement. Do not use it to change colour or padding.
- Type
string
children- Description
- Custom layout from
StatCard.Label,StatCard.Value,StatCard.Delta,StatCard.Period,StatCard.TrendandStatCard.Info. When set, it replaces the layout built from the props above. - Type
ReactNode
Native attributes (id, aria-*) pass through to the root element. The delta object carries value, direction, sentiment and label.
Use the props for the common case and the parts for a custom layout. When you pass children, they replace the layout built from the props; loading and hidden reach the parts from the root.
| Part | Element | Props |
|---|---|---|
StatCard.Label |
<p> |
Native attributes. It names the group; the root sets its id. |
StatCard.Value |
<div> |
Native attributes. It shows its own state while loading, hidden and without a value. |
StatCard.Delta |
<span> |
value, direction, sentiment, label. |
StatCard.Period |
<span> |
Native attributes. |
StatCard.Trend |
<div> |
Native attributes. Unlabelled content becomes aria-hidden. |
StatCard.Info |
<p> |
Native attributes. |
Data attributes
Section titled “Data attributes”data-stat-card: on the root (the root also carries Card’sdata-component="card"anddata-variant).data-part:label,value,delta,period,trend,info.data-direction,data-sentiment: on thedeltapart.
Custom layout
Section titled “Custom layout”<StatCard> <StatCard.Label>Total items</StatCard.Label> <StatCard.Value>1.280</StatCard.Value> <StatCard.Delta value="8 %" direction="up" /> <StatCard.Period>vs last month</StatCard.Period></StatCard>