blob: 528c91a4feba39c2a26a9dcf333a384b444cce06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# rgb-hex [](https://travis-ci.org/sindresorhus/rgb-hex)
> Convert RGB(A) color to HEX
## Install
```
$ npm install rgb-hex
```
## Usage
```js
const rgbHex = require('rgb-hex');
rgbHex(65, 131, 196);
//=> '4183c4'
rgbHex('rgb(40, 42, 54)');
//=> '282a36'
rgbHex(65, 131, 196, 0.2);
//=> '4183c433'
rgbHex(40, 42, 54, '75%');
//=> '282a36bf'
rgbHex('rgba(40, 42, 54, 75%)');
//=> '282a36bf'
```
## Related
- [rgb-hex-cli](https://github.com/sindresorhus/rgb-hex-cli) - CLI for this module
- [hex-rgb](https://github.com/sindresorhus/hex-rgb) - Convert HEX color to RGB
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
|