# @ant-design/fast-color 中文文档

规范地址：https://npmcn.com/package/%40ant-design/fast-color/

版本：3\.0\.1
npm 元数据更新时间：2026-04-02T03:57:43.013Z
中文译文更新时间：2026-11-06T05:59:45.901Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ant-design/fast-color
原文对照：https://npmcn.com/package/%40ant-design/fast-color/?lang=original
项目主页：https://github.com/ant-design/fast-color
源码仓库：https://github.com/ant-design/fast-color

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：56.3 kB，19 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=8\.x
- 运行依赖：0 个
- 首次发布：2024-06-28T10:14:38.948Z
- 最新版本发布：2026-01-26T03:48:14.976Z
- 近 30 天下载量：14376010（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 1 个）

## 中文简介

快速和小颜色类

## 安装

```sh
npm install @ant-design/fast-color
```

也可以使用：`pnpm add @ant-design/fast-color`、`yarn add @ant-design/fast-color`、`bun add @ant-design/fast-color`

## README

# @ 蚂蚁- 设计/ 快速- 颜色

快取颜色课.

[![NPM version](http://img.shields.io/npm/v/@ant-design/fast-color.svg?style=flat-square)](http://npmjs.org/package/@ant-design/fast-color) [![npm download](https://img.shields.io/npm/dm/@ant-design/fast-color.svg?style=flat-square)](https://npmjs.org/package/@ant-design/fast-color) [![build status](https://github.com/ant-design/fast-color/actions/workflows/main.yml/badge.svg)](https://github.com/ant-design/fast-color/actions/workflows/main.yml) [![Test coverage](https://img.shields.io/codecov/c/github/ant-design/fast-color/main.svg?style=flat-square)](https://codecov.io/gh/ant-design/fast-color/branch/main) [![bundle size](https://badgen.net/bundlephobia/minzip/@ant-design/fast-color)](https://bundlephobia.com/result?p=@ant-design/fast-color) [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi)

## 安装

[![@ant-design/fast-color](https://nodei.co/npm/@ant-design/fast-color.png)](https://npmjs.org/package/@ant-design/fast-color)

## 使用量

```js
import { FastColor } from '@ant-design/fast-color';

// input
new FastColor('#666'); // short hex
new FastColor('#66ccff'); // hex
new FastColor('#66ccffaa'); // hex with alpha
new FastColor('rgba(102, 204, 255, .5)'); // old css rgb syntax
new FastColor('rgb(102 204 255 / .5)'); // new css rgb syntax
new FastColor('hsl(270, 60, 40, .5)'); // old css hsl syntax, with or without unit
new FastColor('hsl(270deg 60% 40% / 50%)'); // new css hsl syntax, with or without unit
new FastColor({ r: 102, g: 204, b: 255, a: 0.5 }); // rgb object
new FastColor({ h: 270, s: 0.6, l: 0.4, a: 0.5 }); // hsl object
new FastColor({ h: 270, s: 0.6, v: 0.4, a: 0.5 }); // hsv object

// clone
const color = new FastColor('#66ccff');
const color2 = new FastColor(color); // clone via constructor
const color3 = color2.clone(); // call clone method

// output
color.toHexString(); // #66ccff
color.toRgb(); // Object { r: 102, g: 204, b: 255, a: 1 }
color.toRgbString(); // rgb(102,204,255)
color.toHsl(); // Object { h: 200, s: 0.6, l: 0.7, a: 1 }
color.toHslString(); // hsl(200,60%,70%)
color.toHsv(); // Object { h: 200, s: 0.6, v: 1, a: 1 }
```

## 兼容性

| 浏览器 | IE / 边缘 | 火花 | 颜色 | 萨法里 | 电子 |
| --- | :-: | :-: | :-: | :-: | :-: |
| 支持版本 | ![](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png)  
IE11,边缘 | ![](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png)  
最近 | ![](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png)  
最近 | ![](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png)  
最近 | ![](https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png)  
最近 |

## API 密码

开始

## 许可证

@ant-design/快取-color根据麻省理工学院的许可发布.

## 常见问题

### @ant-design/fast-color 是什么？

快速和小颜色类

### 如何安装 @ant-design/fast-color？

在项目目录运行 npm install @ant-design/fast-color，或使用 pnpm add / yarn add / bun add。

### @ant-design/fast-color 支持 TypeScript 吗？

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

### @ant-design/fast-color 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @ant-design/fast-color 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=8\.x。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @ant-design/fast-color 可以商用吗？

@ant-design/fast-color 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ant-design/fast-color 的下载量有多少？

根据 npm 官方下载统计，@ant-design/fast-color 在 2026/10/06 – 2026/11/04 这 30 天内被下载 14,376,010 次，日均约 479,200 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ant-design/fast-color 还在维护吗？

最新版本 3\.0\.1 发布于 2026/01/26（9 个月前）；至今共发布 18 个版本，其中过去 12 个月发布了 1 个；首次发布于 2024/06/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

