Lightweight module for converting RGB(A) values to hexadecimal colors
npm i hex-color-converter
const converter = require('hex-color-converter')
const hex = converter('rgba(255, 255, 255, 0.5)')
console.log(hex) // => #FFFFFF80
To convert RGB values to a hexadecimal color value pass the RGB string to converter
function. RGB strings should be formatted as rgb(255, 255, 255)
converter('rgb(255, 255, 255)')
To convert RGBA values to a hexadecimal color value pass the RGBA string to converter
function. RGBA strings should be formatted as rgba(255, 255, 255, 0.5)
converter('rgb(255, 255, 255, 0.5)')
Contributors are welcome, feel free to submit a new pull request to help improve hex-color-converter.