Skip to main content

alpha

function

Set the alpha/opacity of a color.

function alpha(color: string, opacity: number): string

Import

import { alpha } from '@modular/sdk/theme';

Notes

returns
The color with modified alpha as rgba() string
throws
Error if the color format is invalid or opacity is out of range
example
```ts alpha('#ff0000', 0.5) // => 'rgba(255, 0, 0, 0.5)' alpha('rgb(0, 255, 0)', 0.8) // => 'rgba(0, 255, 0, 0.8)' ```