hex-color-converter

Lightweight module for converting RGB(A) values to hexadecimal colors

Usage no npm install needed!

<script type="module">
  import hexColorConverter from 'https://cdn.skypack.dev/hex-color-converter';
</script>

README

hex-color-converter

GitHub Workflow Status (branch) Code Climate coverage npm js-standard-style

Lightweight module for converting RGB(A) values to hexadecimal colors

Install

npm i hex-color-converter

Usage

const converter = require('hex-color-converter')

const hex = converter('rgba(255, 255, 255, 0.5)')
console.log(hex) // => #FFFFFF80

Documentation

Convert RGB values to hexadecimal color values

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)')

Convert RGBA values to hexadecimal color values

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)')

Contributing

Contributors are welcome, feel free to submit a new pull request to help improve hex-color-converter.