# @arco-design/color

> ArcoDesign color utils

Latest version **0.4.0** (published 2021-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arco-design/color
pnpm add @arco-design/color
yarn add @arco-design/color
bun add @arco-design/color
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2021-10-25 |
| First published | 2021-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | misterluffy, yinkaihui, arcodesign-bot, n0rush, kiraxy, flsion, pjy, bytednpm |
| Keywords | ArcoDesign, Color, utils |

## Links

- npm: https://www.npmjs.com/package/@arco-design/color
- npm.io page: https://npm.io/package/@arco-design/color

## Dependencies (1)

- [color](https://npm.io/package/color.md) ^3.1.3

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.4.0 (latest) — 2021-10-25

## README

# ArcoDesign Color

ArcoDesign Color Utils. 

For a given color, a gradient swatch containing ten colors is generated with an algorithm. This works for both light and dark modes.

## Usage

```bash
npm i @arco-design/color
```

```js
import { generate, presetColor } from '@arco-design/color';

console.log(generate('#123456'));

console.log(presetColor);
// {
//   red: {...},
//   orangered: {...},
//   orange: {...},
//   gold: {...},
//   yellow: {...},
//   lime: {...},
//   green: {...},
//   cyan: {...},
//   blue: {...},
//   arcoblue: {...},
//   purple: {...},
//   pinkpurple: {...},
//   magenta: {...},
//   gray: {...}
// }
```

## API

### generate(color: string, options: Object);

#### options.index {number | 1-10}

Index (starting from 1) of the gradient colors to be generated.

#### options.list {boolean}

Whether to generate color array containing the ten colors.

#### options.dark

Whether to generate colors for dark mode.

#### options.format {'hex' | 'rgb' | 'hsl'}

Color format.
### getPresetColors {Function}

Contains 14 preset sets of colors.

* `red`
* `orangered`
* `orange`
* `gold`
* `yellow`
* `lime`
* `green`
* `cyan`
* `blue`
* `arcoblue`
* `purple`
* `pinkpurple`
* `magenta`
* `gray`

```js
const { red } = getPresetColors();

console.log(red.light);
console.log(red.dark);
console.log(red.primary);
```

### getRgbStr(color: string)

For a given color, get the r, g, b value in string

```js
getRgbStr('#F53F3F') // 245,63,63
```

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