@ant-design/fast-color

中文文档
3.0.1发布于 2026/01/26MITTypeScriptESM + CJS零依赖近 30 天下载 1437.6万

fast and small color class

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Compatibility
  4. API
  5. License

@ant-design/fast-color

Fast color class.

NPM version npm download build status Test coverage bundle size dumi

Install

@ant-design/fast-color

Usage

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 }

Compatibility

浏览器IE / EdgeFirefoxChromeSafariElectron
支持版本
IE11, Edge

最近2个版本

最近2个版本

最近2个版本

最近2个版本

API

TODO

License

@ant-design/fast-color is released under the MIT license.

版本与发布记录

@ant-design/fast-color 共发布 18 个版本,首次发布于 2024/06/28;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.1latest2026/01/269 个月前
3.0.02025/03/211.6 年前
2.0.62024/08/062 年前
2.0.52024/08/052 年前
2.0.42024/07/242 年前
2.0.32024/07/202 年前

关于 @ant-design/fast-color 的常见问题

@ant-design/fast-color 是什么?

fast and small color class

如何安装 @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 和提交记录判断。