Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rgb-hex

sindresorhus1mMIT4.1.0TypeScript support: included

Convert RGB(A) color to HEX

rgb, hex, color, colour, convert, conversion, converter

readme

rgb-hex

Convert RGB(A) color to HEX

Install

$ npm install rgb-hex

Usage

import rgbHex from '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'