1.0.1 • Published 2 years ago
rgba-to-hex-colors v1.0.1
rgba-to-hex-colors
rgba-to-hex-colors is a helper to convert RGBA Color String to Hex color string and back
Example
'rgba(255, 255, 255)' ==> '#FFFFFF'
'#FFFFFF' ==> 'rgba(255,255,255,0)'
Methods
Method | Function |
---|---|
rgbToHex | Convert RGBA to Hex color string |
hexToRgb | Convert Hex to RGBA color string |
How to use
rgbToHex
const { rgbToHex } = require('rgba-to-hex-colors');
const hexColor = rgbToHex('rgba(255, 255, 255)');
// expected output: string '#FFFFFF'
hexToRgb
const { hexToRgb } = require('rgba-to-hex-colors');
const hexColor = hexToRgb('#FFFFFF');
// expected output: string 'rgba(255,255,255,0)'