@chriscodesthings/css-hex-color-to-rgba
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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 ]

Types

This package uses types from:

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...

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

65

Version

1.1.1

License

MIT

Unpacked Size

7.34 kB

Total Files

8

Last publish

Collaborators

  • chriscodesthings