@crossfox/react-animated-number

中文文档
1.0.18发布于 2023/10/10Apache-2.0TypeScriptES Module零依赖近 30 天下载 5098

A lightweight JavaScript component designed for creating smooth and visually appealing animated transitions between different states or values, enhancing user experience in web applications.

原始使用文档
文档目录6 节
  1. Demo:
  2. Install
  3. Author
  4. Props
  5. ClassName status
  6. Example

React animated number by CrossFox

npm version Blazing Fast gzip size NPM downloads license

A lightweight, blazing-fast React component that's easy to use and works with React 16.8 and higher.

  • 📦 <1kb mini library
  • 🌟 Easy to use
  • ⚡ High performance
  • 🔗 No dependency

Demo:

View demo here

Install

npm install @crossfox/react-animated-number
yarn add @crossfox/react-animated-number

Author

Props

NameTypeDefault ValueDescriptionVersion
valuenumber0Current value, triggers animation on change1.00
roundnumber0Number of decimal places1.00
durationnumber1000Animation duration(ms)1.00
classNamestring0You can add custom classes1.00
showArrowbooleanfalseDisplay an arrow to the left of the number indicating growth or decline1.00
reserveMinusSpacebooleanfalseAdds a space for the minus sign1.00
reservenumber0Reserves space for the number1.00
alignstring"left"Reservation direction. Available only as 'left', in other cases 'right'1.00
prefixstring""Adds text to be placed before the number. For example, '$100'1.00
suffixstring""Adds text to be placed after the number. For example, '1000 UAH'1.00
ratestring60Number of updates per second1.00
tagNamestringdivTag to be created for the number.1.00
onFinishfunctionfunction(
oldValue,
value,
$el
)
Event triggers after the animation is complete. Returns the old number, current number, and the element node.1.00

ClassName status

ClassNameDescription
is-progressAdded during the animation
is-incrementNotifies that the number has increased
is-decrementNotifies that the number has decreased

Example

import React, { useState } from 'react';
import AnimatedNumber from '@crossfox/react-animated-number';

const App = () => {
    const [value, setValue] = useState(0)
    const onClickRandom = () => setValue(Math.random() * 10000 >> 0)
    return (<>
        <button onClick={onClickRandom}>Random value</button>
        <AnimatedNumber value={value}/>
    </>)
}

版本与发布记录

@crossfox/react-animated-number 共发布 18 个版本,首次发布于 2023/09/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.18latest2023/10/103 年前
1.0.172023/10/103 年前
1.0.162023/10/033 年前
1.0.152023/10/033 年前
1.0.142023/09/263 年前
1.0.132023/09/213 年前

关于 @crossfox/react-animated-number 的常见问题

@crossfox/react-animated-number 是什么?

A lightweight JavaScript component designed for creating smooth and visually appealing animated transitions between different states or values, enhancing user experience in web applications.

如何安装 @crossfox/react-animated-number?

在项目目录运行 npm install @crossfox/react-animated-number,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.8.0 || ^17.0.0 || ^18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@crossfox/react-animated-number 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crossfox/react-animated-number 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crossfox/react-animated-number 可以商用吗?

@crossfox/react-animated-number 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@crossfox/react-animated-number 的下载量有多少?

根据 npm 官方下载统计,@crossfox/react-animated-number 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,098 次,日均约 170 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crossfox/react-animated-number 还在维护吗?

最新版本 1.0.18 发布于 2023/10/10(3 年前);至今共发布 18 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/09/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。