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

darken

A small utility function that darkens a CSS color value by a relative amount.
It uses the hsl color model to do so.

The Gist

import { darken } from '@weser/theming'

const darkerRed = darken('red', 0.5)
const darkerVariable = alpha('var(--background)', 0.5)

Parameters

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

Returns

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

On this page