1.1.0 • Published 1 month ago

@chriscodesthings/css-hex-color-to-rgba v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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

Converts a CSS hex color code to RGBA values

Description

Converts a CSS hex color code to an array containing red, green, blue and alpha values.

See...


Install

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

Use

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

console.log(cssHexColorToRGBA("#6495ed"));
// => [ 100, 149, 237, 1 ]

Syntax

cssHexColorToRGBA(color);

Parameters

  • color: a CSS hex color code

Return Value

Returns an array containing the [red, green, blue, alpha] values of color.

Red, green and blue values are in the range 0-255. Alpha value is in the range 0-1.

Examples

// switch colour to rgba
const rgba = cssHexColorToRGBA(color);

See Also...