JGuang

Statistic

Statistic · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Statistic

Display statistic number.

When To Use

  • When want to highlight some data.
  • When want to display statistic data with description.

Examples

  • Basic · basic
  • Unit · unit
  • Animated number · animated
  • In Card · card
  • Timer · timer
  • Custom semantic dom styling · style-class

API

Common props ref:Common props

Statistic

PropertyDescriptionTypeDefaultVersionGlobal Config
classNamesCustomize class for each semantic structure inside the Statistic component. Supports object or function.Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-6.0.0
decimalSeparatorThe decimal separatorstring.×
formatterCustomize value display logic(value) => ReactNode-×
groupSeparatorGroup separatorstring,×
loadingLoading status of Statisticbooleanfalse4.8.0×
precisionThe precision of input valuenumber-×
prefixThe prefix node of valueReactNode-×
stylesCustomize inline style for each semantic structure inside the Statistic component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-6.0.0
suffixThe suffix node of valueReactNode-×
titleDisplay titleReactNode-×
valueDisplay valuestring | number-×
valueStyleSet value section style, please use styles.content insteadCSSProperties-×

Statistic.Countdown <Badge type="error">Deprecated</Badge>

<Antd component="Alert" title="When using version >= 5.25.0, Please use Statistic.Timer instead." type="warning" banner="true"></Antd>

PropertyDescriptionTypeDefaultVersion
formatFormat as dayjsstringHH:mm:ss
prefixThe prefix node of valueReactNode-
suffixThe suffix node of valueReactNode-
titleDisplay titleReactNode-
valueSet target countdown timenumber-
valueStyleSet value section styleCSSProperties-
onFinishTrigger when time's up() => void-
onChangeTrigger when time's changing(value: number) => void--

Statistic.Timer <Badge>5.25.0+</Badge>

PropertyDescriptionTypeDefaultVersion
typeTimer direction, count down or count upcountdown | countup-
formatFormat as dayjsstringHH:mm:ss
prefixThe prefix node of valueReactNode-
suffixThe suffix node of valueReactNode-
titleDisplay titleReactNode-
valueTarget time for countdown, or start time for countup (timestamp in ms)number-
valueStyleSet value section styleCSSProperties-
onFinishTrigger when time's up, only called when type is countdown() => void-
onChangeTrigger when time's changing(value: number) => void-

Semantic DOM

Statistic supports root, header, title, content, value, prefix, and suffix semantic DOM nodes.

Semantic nodeNative descriptionVersion
rootRoot element with reset styles and overall container styles for statistic component6.0.0
headerHeader element with bottom padding and title area layout styles6.0.0
titleTitle element with text color, font size and other title text display styles6.0.0
prefixPrefix element with inline-block display, right margin and other prefix content layout styles6.0.0
contentContent element with layout and alignment styles for the prefix, value and suffix area6.0.0
valueValue element with text color, font size, font family and other statistic number display styles6.4.0
suffixSuffix element with inline-block display, left margin and other suffix content layout styles6.0.0

Semantic description source: vendor/components/statistic/demo/_semantic.tsx

Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

TokenTypeNative description
titleFontSizenumberTitle font size
contentFontSizenumber | stringContent font size

Declaration source: vendor/components/statistic/style/index.ts

import type { CSSObject } from '@ant-design/cssinjs';

import { resetComponent } from '../../style';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

export interface ComponentToken {
  /**
   * @desc 标题字体大小
   * @descEN Title font size
   */
  titleFontSize: number;
  /**
   * @desc 内容字体大小
   * @descEN Content font size
   */
  contentFontSize: number | string;
}

interface StatisticToken extends FullToken<'Statistic'> {}

Shared native props

Tips: The following generic properties apply to most antd components; those not supported are described separately.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

Install and reproduce an example

npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

  • vendor/components/statistic/Countdown.tsx
  • vendor/components/statistic/Number.tsx
  • vendor/components/statistic/Statistic.tsx
  • vendor/components/statistic/Timer.tsx
  • vendor/components/statistic/index.tsx
  • vendor/components/statistic/style/index.ts
  • vendor/components/statistic/utils.ts

Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.