Skip to content

Instantly share code, notes, and snippets.

@callmetwan
Created November 20, 2020 03:17
Show Gist options
  • Save callmetwan/61e1690feccd9a6448d139158733f127 to your computer and use it in GitHub Desktop.
Save callmetwan/61e1690feccd9a6448d139158733f127 to your computer and use it in GitHub Desktop.
JS adjustable RGBA opacity
function adjustRgbaOpacity(color: string, opacity: number) {
color.replace(/[^,]+(?=\))/, opacity);
}
const rgba = 'rgba(255, 255, 255, 1)';
const rgbargba = adjustRgbaOpacity(color, .5);
https://stackoverflow.com/a/8179549/2124039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment