@spa-tools/utilities
rgbaToHex
The rgbaToHex
function converts an rgba color string to a hex color string.
Usage
import { rgbaToHex } from '@spa-tools/utilities';
const hexColor = rgbaToHex('rgba(255, 0, 0, 0.5)');
console.log(hexColor);
// --> '#ff000080'
Arguments
Name | Type | Required? | Default | Description |
---|---|---|---|---|
rgba | string | yes | - | RGBA color string |
opacity | number | no | 1 | Opacity color value |
Returns
string
- The color in hex format.