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

lightness

A small utility function that sets the lightness of a CSS color value to an absolute percentage.
It uses the hsl color model to do so.

The Gist

import { lightness } from '@weser/theme'

const halfLight = lightness('red', 50)
const variableLightness = lightness('var(--background)', 25)

Parameters

ParameterTypeDescription
valuestringThe CSS color value to set the lightness.
percent0-100The absolute lightness value as percentage.

Returns

(string) A string that references a CSS color value with the lightness set to the specified percentage.

Import Alias

For convenience, we also export a shorthand import alias.

import { l } from '@weser/theme'
On this page