Skip to main content

rgba

Creates an RGBA color object from a variety of common color encodings.

Accepted color formats include CSS color strings with hex, rgb(), hsl(), or lab() encodings, as well as RGB, RGBA, and ColorWithColorSpace objects. Alpha defaults to 1 (opaque) if not provided in the input. If supplied, alphaOverride takes precedence over alpha encoded in color. If a string encoding cannot be parsed, an error will be thrown.

Examples:

const layoutGrid = {
pattern: 'GRID',
sectionSize: 1,
color: figma.util.rgba('rgb(25% 25% 25% / 0.5)')
}

You can alias this function for more concise code:

const rgba = figma.util.rgba
const color = rgba('rgb(25% 25% 25% / 0.5)')

Signature​

rgba(color: string | RGBWithColorSpace | RGBAWithColorSpace | ColorWithColorSpace, alphaOverride?: number): RGBAWithColorSpace

Parameters​

color​

A CSS color string, RGB object, RGBA object, or ColorWithColorSpace.

alphaOverride​

An optional alpha value that takes precedence over alpha encoded in color.