Import
import { Stat } from '@dnb/eufemia'
Description
Stat contains components for prominent values with a label, where typography and visual emphasis are part of the component.
Available components
-
Stat.Rootrenders a definition list (dl).-
Stat.Labelrenders descriptive text with dedicated typography and color for metric context (dt). -
Stat.Contentrenders the main value as a definition description (dd).
-
-
Stat.Amountis the base value formatter built on the NumberFormat formatting logic. -
Stat.CurrencyandStat.Percentare convenience wrappers aroundStat.Amount.- It adds typography-specific properties such as
fontSize,fontWeightandcolorizeBySign, along withmainSizeandauxiliarySizeas well asmainWeightandauxiliaryWeightthat can be used to customize the visual emphasis of the different parts of the value (currency symbol or percent sign).
- It adds typography-specific properties such as
-
Stat.Trendrenders explicit+/-indicators with red/green background states and screen-reader text. -
Stat.Ratingrenders a star rating (defaults to 5 stars) and colorizes stars based onvalue. -
Stat.Inforenders supporting text with a smaller, muted style.
Accessibility
-
Stat.Rootprovides semantic definition-list markup (dl), whereStat.Labelis rendered asdtandStat.Contentasdd. -
If the label also acts as a section heading, use a heading element inside
Stat.Label(for exampleH3) to preserve a meaningful heading outline. -
Use
srLabelto prepend context in the screen-reader text only, for example turning1,234 krintoRevenue 1,234 krfor screen readers. -
When e.g.
signDisplay="always"is used, the sign is rendered as a separate visual element with CSS spacing, while the accessible text stays based on the formatted number string. -
All Stat variants keep dedicated accessibility handling.
Currency,Percent, andTrenduse a dedicated screen-reader value (.dnb-sr-only) based on the formatted content.Ratinguses an accessible label (role="img"+aria-label) that includes value and max.