# @hi-ui/counter

> A sub-package for @hi-ui/hiui.

Latest version **5.0.0** (published 2026-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hi-ui/counter
pnpm add @hi-ui/counter
yarn add @hi-ui/counter
bun add @hi-ui/counter
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-06-06 |
| First published | 2021-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 157.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 879 |
| Author | HiUI |
| Maintainers | sivan, solarjoker, lanzhi_lee, zhouyun |

## Links

- npm: https://www.npmjs.com/package/@hi-ui/counter
- Repository: https://github.com/XiaoMi/hiui
- Homepage: https://github.com/XiaoMi/hiui/tree/master/packages/ui/counter#readme
- Issues: https://github.com/XiaoMi/hiui/issues
- npm.io page: https://npm.io/package/@hi-ui/counter

## Dependencies (9)

- [@hi-ui/env](https://npm.io/package/@hi-ui/env.md) ^5.0.0
- [@hi-ui/icons](https://npm.io/package/@hi-ui/icons.md) ^5.0.0
- [@hi-ui/classname](https://npm.io/package/@hi-ui/classname.md) ^5.0.0
- [number-precision](https://npm.io/package/number-precision.md) ^1.5.0
- [@hi-ui/use-latest](https://npm.io/package/@hi-ui/use-latest.md) ^5.0.0
- [@hi-ui/use-toggle](https://npm.io/package/@hi-ui/use-toggle.md) ^5.0.0
- [@hi-ui/type-assertion](https://npm.io/package/@hi-ui/type-assertion.md) ^5.0.0
- [@hi-ui/use-merge-semantic](https://npm.io/package/@hi-ui/use-merge-semantic.md) ^5.0.0
- [@hi-ui/use-uncontrolled-state](https://npm.io/package/@hi-ui/use-uncontrolled-state.md) ^5.0.0

## Recent versions

- 5.0.0 (latest) — 2026-06-06
- 5.0.0-rc.0 (rc) — 2026-06-02
- 5.0.0-experimental.2 (experimental) — 2026-03-08
- 5.0.0-canary.9 (canary) — 2026-03-08
- 5.0.0-alpha.0 (alpha) — 2025-09-29
- 4.1.3-beta.0 (beta) — 2023-05-30
- 4.0.0-beta.22 (feature) — 2022-07-13
- 5.0.0-experimental.1 — 2026-02-12
- 5.0.0-canary.8 — 2026-02-12
- 5.0.0-experimental.0 — 2026-02-05
- 5.0.0-canary.7 — 2025-12-15
- 5.0.0-canary.6 — 2025-12-03
- 5.0.0-canary.5 — 2025-11-19
- 5.0.0-canary.4 — 2025-11-12
- 5.0.0-canary.3 — 2025-08-21
- … 74 more at https://npm.io/package/@hi-ui/counter/versions

## README

# Counter 数字加减器

## 使用示例

<!-- Inject Stories -->

## Props

| 参数          | 说明             | 类型    | 可选值                       | 默认值 |
| ------------- | ---------------- | ------- | ---------------------------- | ------ |
| value         | 设置当前值       | number  | -                            | -      |
| defaultValue  | 设置默认值       | number  | -                            | 0      |
| step          | 每次改变值的大小 | number  | -                            | -      |
| min           | 最小值           | number  | -                            | -      |
| max           | 最大值           | number  | -                            | -      |
| disabled      | 是否禁用         | boolean | true \| false                | false  |
| autoFocus     | 开启自动聚焦     | boolean | true \| false                | false  |
| appearance    | 设置展现形式     | string  | 'line' \| 'filled'           | 'line' |
| size          | 设置尺寸         | string  | 'xs' \| 'sm' \| 'md' \| 'lg' | 'md'   |
| changeOnWheel | 开启滑轮改值     | boolean | true \| false                | false  |

## Events

| 名称     | 说明           | 类型                    | 参数              | 返回值 |
| -------- | -------------- | ----------------------- | ----------------- | ------ |
| onChange | 改变值时的回调 | (value: number) => void | value: 改变后的值 | -      |

## CHANGELOG

| 参数          | 变更类型                        | 变更内容                                                   | 解决的问题                                                                            |
| ------------- | ------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| propName      | feature \| deprecated \| update | 变更了什么                                                 | 之前是什么样子，解决什么问题                                                          |
| ----          | ----                            | ----                                                       | ----                                                                                  |
| onChange      | update                          | (evt: Event, value: number)=>void -> (value: number)=>void | 1. onChange 来源众多，触发事件并不一致；2. 之前暴露的也是假的事件对象，不符合前端认知 |
| autoFocus     | feature                         | 表单控件组件统一支持是否自动聚焦                           |
| appearance    | feature                         | UI 适配线面型                                              |
| size          | feature                         | UI 适配不同 Size                                           |
| changeOnWheel | feature                         | 强化功能，控制滑轮改值                                     |

---
_Source: https://npm.io/package/@hi-ui/counter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
