Theme
/ API Reference / Color Manipulation
Theme
/ API Reference / Color Manipulation

transparentize

A small utility function that decreases the alpha (opacity) of a CSS color value by a relative amount.
It uses the hsl color model to do so.

The Gist

import { transparentize } from '@weser/theme'

const moreTransparent = transparentize('red', 0.2)
const transparentVariable = transparentize('var(--background)', 0.5)

Parameters

ParameterTypeDescription
valuestringThe CSS color value to decrease the alpha.
amount0-1The relative amount to decrease the alpha.

Returns

(string) A string that references a CSS color value with the alpha decreased.

On this page