Statistic

Display statistic number.

When To Use#

  • When want to highlight some data.

  • When want to display statistic data with description.

Examples

Active Users
112,893
Account Balance (CNY)
112,893.00

Simplest Usage.

expand codeexpand code
import { Statistic, Row, Col, Button } from 'antd';

ReactDOM.render(
  <Row gutter={16}>
    <Col span={12}>
      <Statistic title="Active Users" value={112893} />
    </Col>
    <Col span={12}>
      <Statistic title="Account Balance (CNY)" value={112893} precision={2} />
      <Button style={{ marginTop: 16 }} type="primary">
        Recharge
      </Button>
    </Col>
  </Row>,
  mountNode,
);
Active
11.28%
Idle
9.30%

Display statistic data in Card.

expand codeexpand code
import { Statistic, Card, Row, Col, Icon } from 'antd';

ReactDOM.render(
  <div style={{ background: '#ECECEC', padding: '30px' }}>
    <Row gutter={16}>
      <Col span={12}>
        <Card>
          <Statistic
            title="Active"
            value={11.28}
            precision={2}
            valueStyle={{ color: '#3f8600' }}
            prefix={<Icon type="arrow-up" />}
            suffix="%"
          />
        </Card>
      </Col>
      <Col span={12}>
        <Card>
          <Statistic
            title="Idle"
            value={9.3}
            precision={2}
            valueStyle={{ color: '#cf1322' }}
            prefix={<Icon type="arrow-down" />}
            suffix="%"
          />
        </Card>
      </Col>
    </Row>
  </div>,
  mountNode,
);
Feedback
1,128
Unmerged
93/ 100

Add unit through prefix and suffix.

expand codeexpand code
import { Statistic, Row, Col, Icon } from 'antd';

ReactDOM.render(
  <Row gutter={16}>
    <Col span={12}>
      <Statistic title="Feedback" value={1128} prefix={<Icon type="like" />} />
    </Col>
    <Col span={12}>
      <Statistic title="Unmerged" value={93} suffix="/ 100" />
    </Col>
  </Row>,
  mountNode,
);
Countdown
48:00:29
Million Seconds
48:00:29:998
Day Level
2 天 0 时 0 分 29 秒

Countdown component.

expand codeexpand code
import { Statistic, Row, Col } from 'antd';

const { Countdown } = Statistic;
const deadline = Date.now() + 1000 * 60 * 60 * 24 * 2 + 1000 * 30; // Moment is also OK

function onFinish() {
  console.log('finished!');
}

ReactDOM.render(
  <Row gutter={16}>
    <Col span={12}>
      <Countdown title="Countdown" value={deadline} onFinish={onFinish} />
    </Col>
    <Col span={12}>
      <Countdown title="Million Seconds" value={deadline} format="HH:mm:ss:SSS" />
    </Col>
    <Col span={24} style={{ marginTop: 32 }}>
      <Countdown title="Day Level" value={deadline} format="D  H  m  s 秒" />
    </Col>
  </Row>,
  mountNode,
);

API#

Statistic#

PropertyDescriptionTypeDefaultVersion
decimalSeparatordecimal separatorstring.3.13.0
formattercustomize value display logic(value) => ReactNode-3.13.0
groupSeparatorgroup separatorstring,3.13.0
precisionprecision of input valuenumber-3.13.0
prefixprefix node of valuestring | ReactNode-3.13.0
suffixsuffix node of valuestring | ReactNode-3.13.0
titleDisplay titlestring | ReactNode-3.13.0
valueDisplay valuestring | number-3.13.0
valueStyleSet value css stylestyle-3.13.0

Statistic.Countdown#

PropertyDescriptionTypeDefaultVersion
formatFormat as momentstring'HH:mm:ss'3.13.0
onFinishTrigger when time's up() => void-3.14.0
prefixprefix node of valuestring | ReactNode-3.13.0
suffixsuffix node of valuestring | ReactNode-3.13.0
titleDisplay titlestring | ReactNode-3.13.0
valueSet target countdown timenumber | moment-3.13.0
valueStyleSet value css stylestyle-3.13.0
PopoverTree