Theming
/ API Reference / Color Manipulation
Theming
/ API Reference / Color Manipulation

alpha

A small utility function that applies an alpha channel to a CSS color value.
It uses the hsl color model to do so.

The Gist

import { alpha } from '@weser/theming'

const transparentRed = alpha('red', 0.5)
const transparentVariable = alpha('var(--background)', 0.5)

Parameters

ParameterTypeDescription
valuestringThe CSS color value to apply the alpha to.
alpha0-1The alpha value as a float from 0 to 1.

Returns

(string) A string that references a CSS color value with an alpha channel applied.

Import Alias

For convenience, we also export a shorthand import alias.

import { a } from '@weser/theming'
On this page