@zero-deps/hex-2-rgb
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

hex-2-rgb

Zero dependencies 😍

Super lightweight typescript helper function to convert hexes of format #RRGGBB to rgb of value rgb(x,y,z) or rgba(x,y,z,a).

Installation

npm install @zero-deps/hex-2-rgb

Usage

import { hex2rgb } from '@zero-deps/hex-2-rgb'

const rgb = hex2rgb('#000000')
console.log(rgb) // rgba(0, 0, 0)

const rgba = hex2rgb('#FFFFFF', 0.5)
console.log(rgba) // rgba(255, 255, 255, 0.5)

Size limit

Smaller than 500 bytes (commonjs, minified and gzipped). Smaller than 150 bytes (EMS, minified and gzipped).

Size Limit controls the size.

/@zero-deps/hex-2-rgb/

    Package Sidebar

    Install

    npm i @zero-deps/hex-2-rgb

    Weekly Downloads

    141

    Version

    2.2.0

    License

    ISC

    Unpacked Size

    4.98 kB

    Total Files

    11

    Last publish

    Collaborators

    • flofehrenbacher