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

saturation

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

The Gist

import { saturation } from '@weser/theme'

const halfSaturated = saturation('red', 50)
const variableSaturation = saturation('var(--background)', 75)

Parameters

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

Returns

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

Import Alias

For convenience, we also export a shorthand import alias.

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