@chriscodesthings/rgba-color-to-css-hex

1.0.1 • Public • Published

rgba-color-to-css-hex · Test workflow status NPM Version License: MIT

Converts an RGB or RGBA color to a CSS hex color code

Install

npm install --save @chriscodesthings/rgba-color-to-css-hex

Use

import rgbaColorToCSSHex from '@chriscodesthings/rgba-color-to-css-hex';

console.log(rgbaColorToCSSHex([100, 149, 237, 0.5])); // cornflowerblue with 50% transparency
// => #6495ed7f

Syntax

rgbaColorToCSSHex([r, g, b, a]);

Parameters

  • r, g, b: red, green and blue values in the range 0-255
  • a (optional): alpha value in the range 0-1

Return Value

Returns a string containing a CSS hex color code converted from the RGBA values.

Description

Does what it says on the tin.

Readme

Keywords

Package Sidebar

Install

npm i @chriscodesthings/rgba-color-to-css-hex

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.11 kB

Total Files

6

Last publish

Collaborators

  • chriscodesthings